| Message ID | 20250604075427.880339-1-joakim.tjernlund@infinera.com |
|---|---|
| State | Accepted |
| Delegated to: | Stefano Babic |
| Headers | show |
| Series | Support MTD names in copy handler | expand |
Ping ? On Wed, 2025-06-04 at 09:54 +0200, 'Joakim Tjernlund' via swupdate wrote: > > CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL > nok.it/ext for additional information. > > > > with this one can do: > scripts:({ > name="u-boot"; > type = "copy"; > mtdname = "u-boot-b"; > installed-directly = true; > properties : { > copyfrom = "mtd:u-boot-a"; > type = "preinstall"; > chain = "raw"; > } > }); > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> > --- > handlers/copy_handler.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c > index bea0899e..9666bf32 100644 > --- a/handlers/copy_handler.c > +++ b/handlers/copy_handler.c > @@ -30,6 +30,7 @@ > #include "progress.h" > #include "handler.h" > #include "util.h" > +#include "flash.h" > #include "handler_helpers.h" > #include "installer.h" > > @@ -213,7 +214,15 @@ static int copy_image_file(struct img_type *img, void *data) > script_data = data; > > base_img = img; > - > + if(strlen(img->mtdname) ){ > + int mtdnum = get_mtd_from_name(img->mtdname); > + if (mtdnum < 0) { > + ERROR("Wrong MTD name in description: %s", > + img->mtdname); > + return -1; > + } > + snprintf(img->device, sizeof(img->device), "/dev/mtdblock%d", mtdnum); > + } > proplist = dict_get_list(&img->properties, "type"); > if (proplist) { > entry = LIST_FIRST(proplist); > @@ -236,7 +245,17 @@ static int copy_image_file(struct img_type *img, void *data) > ERROR("Missing source device, no copyfrom property"); > return -EINVAL; > } > - > + if (!strncmp("mtd:", entry->value, 4)) { > + int mtdnum = get_mtd_from_name(entry->value + 4); > + if (mtdnum < 0) { > + ERROR("Wrong MTD name in copyfrom: %s", > + entry->value); > + return -1; > + } > + free(entry->value); > + entry->value = malloc(20+1); /* to hold "/dev/mtdblockXX */ > + snprintf(entry->value, 20, "/dev/mtdblock%d", mtdnum); > + } > copyfrom = realpath(entry->value, NULL); > if (!copyfrom) { > ERROR("%s cannot be resolved", entry->value); > -- > 2.49.0 > > -- > You received this message because you are subscribed to the Google Groups "swupdate" group. > To unsubscribe from this group and stop receiving emails from it, send an email to > swupdate+unsubscribe@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/swupdate/20250604075427.880339-1-joakim.tjernlund%40infinera.com > .
Yet a ping ... On Sat, 2025-06-14 at 14:35 +0200, jocke at jocke wrote: > Ping ? > > On Wed, 2025-06-04 at 09:54 +0200, 'Joakim Tjernlund' via swupdate wrote: > > > > CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL > > nok.it/ext for additional information. > > > > > > > > with this one can do: > > scripts:({ > > name="u-boot"; > > type = "copy"; > > mtdname = "u-boot-b"; > > installed-directly = true; > > properties : { > > copyfrom = "mtd:u-boot-a"; > > type = "preinstall"; > > chain = "raw"; > > } > > }); > > > > Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> > > --- > > handlers/copy_handler.c | 23 +++++++++++++++++++++-- > > 1 file changed, 21 insertions(+), 2 deletions(-) > > > > diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c > > index bea0899e..9666bf32 100644 > > --- a/handlers/copy_handler.c > > +++ b/handlers/copy_handler.c > > @@ -30,6 +30,7 @@ > > #include "progress.h" > > #include "handler.h" > > #include "util.h" > > +#include "flash.h" > > #include "handler_helpers.h" > > #include "installer.h" > > > > @@ -213,7 +214,15 @@ static int copy_image_file(struct img_type *img, void *data) > > script_data = data; > > > > base_img = img; > > - > > + if(strlen(img->mtdname) ){ > > + int mtdnum = get_mtd_from_name(img->mtdname); > > + if (mtdnum < 0) { > > + ERROR("Wrong MTD name in description: %s", > > + img->mtdname); > > + return -1; > > + } > > + snprintf(img->device, sizeof(img->device), "/dev/mtdblock%d", mtdnum); > > + } > > proplist = dict_get_list(&img->properties, "type"); > > if (proplist) { > > entry = LIST_FIRST(proplist); > > @@ -236,7 +245,17 @@ static int copy_image_file(struct img_type *img, void *data) > > ERROR("Missing source device, no copyfrom property"); > > return -EINVAL; > > } > > - > > + if (!strncmp("mtd:", entry->value, 4)) { > > + int mtdnum = get_mtd_from_name(entry->value + 4); > > + if (mtdnum < 0) { > > + ERROR("Wrong MTD name in copyfrom: %s", > > + entry->value); > > + return -1; > > + } > > + free(entry->value); > > + entry->value = malloc(20+1); /* to hold "/dev/mtdblockXX */ > > + snprintf(entry->value, 20, "/dev/mtdblock%d", mtdnum); > > + } > > copyfrom = realpath(entry->value, NULL); > > if (!copyfrom) { > > ERROR("%s cannot be resolved", entry->value); > > -- > > 2.49.0 > > > > -- > > You received this message because you are subscribed to the Google Groups "swupdate" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to > > swupdate+unsubscribe@googlegroups.com. > > To view this discussion visit > > https://groups.google.com/d/msgid/swupdate/20250604075427.880339-1-joakim.tjernlund%40infinera.com > > .
Hi Joachim, On 25.07.25 18:07, 'Joakim Tjernlund (Nokia)' via swupdate wrote: > Yet a ping ... > > On Sat, 2025-06-14 at 14:35 +0200, jocke at jocke wrote: >> Ping ? Even pong, but I do not know what is supposed I should do. I merged this patch a while ago. Best regards, Stefano >> >> On Wed, 2025-06-04 at 09:54 +0200, 'Joakim Tjernlund' via swupdate wrote: >>> >>> CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL >>> nok.it/ext for additional information. >>> >>> >>> >>> with this one can do: >>> scripts:({ >>> name="u-boot"; >>> type = "copy"; >>> mtdname = "u-boot-b"; >>> installed-directly = true; >>> properties : { >>> copyfrom = "mtd:u-boot-a"; >>> type = "preinstall"; >>> chain = "raw"; >>> } >>> }); >>> >>> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> >>> --- >>> handlers/copy_handler.c | 23 +++++++++++++++++++++-- >>> 1 file changed, 21 insertions(+), 2 deletions(-) >>> >>> diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c >>> index bea0899e..9666bf32 100644 >>> --- a/handlers/copy_handler.c >>> +++ b/handlers/copy_handler.c >>> @@ -30,6 +30,7 @@ >>> #include "progress.h" >>> #include "handler.h" >>> #include "util.h" >>> +#include "flash.h" >>> #include "handler_helpers.h" >>> #include "installer.h" >>> >>> @@ -213,7 +214,15 @@ static int copy_image_file(struct img_type *img, void *data) >>> script_data = data; >>> >>> base_img = img; >>> - >>> + if(strlen(img->mtdname) ){ >>> + int mtdnum = get_mtd_from_name(img->mtdname); >>> + if (mtdnum < 0) { >>> + ERROR("Wrong MTD name in description: %s", >>> + img->mtdname); >>> + return -1; >>> + } >>> + snprintf(img->device, sizeof(img->device), "/dev/mtdblock%d", mtdnum); >>> + } >>> proplist = dict_get_list(&img->properties, "type"); >>> if (proplist) { >>> entry = LIST_FIRST(proplist); >>> @@ -236,7 +245,17 @@ static int copy_image_file(struct img_type *img, void *data) >>> ERROR("Missing source device, no copyfrom property"); >>> return -EINVAL; >>> } >>> - >>> + if (!strncmp("mtd:", entry->value, 4)) { >>> + int mtdnum = get_mtd_from_name(entry->value + 4); >>> + if (mtdnum < 0) { >>> + ERROR("Wrong MTD name in copyfrom: %s", >>> + entry->value); >>> + return -1; >>> + } >>> + free(entry->value); >>> + entry->value = malloc(20+1); /* to hold "/dev/mtdblockXX */ >>> + snprintf(entry->value, 20, "/dev/mtdblock%d", mtdnum); >>> + } >>> copyfrom = realpath(entry->value, NULL); >>> if (!copyfrom) { >>> ERROR("%s cannot be resolved", entry->value); >>> -- >>> 2.49.0 >>> >>> -- >>> You received this message because you are subscribed to the Google Groups "swupdate" group. >>> To unsubscribe from this group and stop receiving emails from it, send an email to >>> swupdate+unsubscribe@googlegroups.com. >>> To view this discussion visit >>> https://groups.google.com/d/msgid/swupdate/20250604075427.880339-1-joakim.tjernlund%40infinera.com >>> . >
diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c index bea0899e..9666bf32 100644 --- a/handlers/copy_handler.c +++ b/handlers/copy_handler.c @@ -30,6 +30,7 @@ #include "progress.h" #include "handler.h" #include "util.h" +#include "flash.h" #include "handler_helpers.h" #include "installer.h" @@ -213,7 +214,15 @@ static int copy_image_file(struct img_type *img, void *data) script_data = data; base_img = img; - + if(strlen(img->mtdname) ){ + int mtdnum = get_mtd_from_name(img->mtdname); + if (mtdnum < 0) { + ERROR("Wrong MTD name in description: %s", + img->mtdname); + return -1; + } + snprintf(img->device, sizeof(img->device), "/dev/mtdblock%d", mtdnum); + } proplist = dict_get_list(&img->properties, "type"); if (proplist) { entry = LIST_FIRST(proplist); @@ -236,7 +245,17 @@ static int copy_image_file(struct img_type *img, void *data) ERROR("Missing source device, no copyfrom property"); return -EINVAL; } - + if (!strncmp("mtd:", entry->value, 4)) { + int mtdnum = get_mtd_from_name(entry->value + 4); + if (mtdnum < 0) { + ERROR("Wrong MTD name in copyfrom: %s", + entry->value); + return -1; + } + free(entry->value); + entry->value = malloc(20+1); /* to hold "/dev/mtdblockXX */ + snprintf(entry->value, 20, "/dev/mtdblock%d", mtdnum); + } copyfrom = realpath(entry->value, NULL); if (!copyfrom) { ERROR("%s cannot be resolved", entry->value);
with this one can do: scripts:({ name="u-boot"; type = "copy"; mtdname = "u-boot-b"; installed-directly = true; properties : { copyfrom = "mtd:u-boot-a"; type = "preinstall"; chain = "raw"; } }); Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com> --- handlers/copy_handler.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)