image-*: Fix pathes with whitespaces

The different image handlers do not work with pathes containing whitespaces
whenever an external command is invoked. Escape all pathes with quotation
marks to make that work.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[mol: fix more image types]
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Sascha Hauer 2018-02-15 14:03:24 +01:00 committed by Michael Olbrich
parent 55f93159c2
commit cf20713886
10 changed files with 23 additions and 19 deletions

View File

@ -29,7 +29,7 @@ static int cpio_generate(struct image *image)
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
char *comp = cfg_getstr(image->imagesec, "compress");
ret = systemp(image, "(cd \"%s\" && find . | %s -H \"%s\" %s -o %s %s) > %s",
ret = systemp(image, "(cd '%s' && find . | %s -H '%s' %s -o %s %s) > '%s'",
mountpath(image),
get_opt("cpio"),
format, extraargs, comp[0] != '\0' ? "|" : "", comp,

View File

@ -26,7 +26,7 @@ static int cram_generate(struct image *image)
{
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
return systemp(image, "%s%s%s %s %s %s",
return systemp(image, "%s%s%s %s '%s' '%s'",
get_opt("mkcramfs"),
image->name ? " -n " : "",
image->name ? image->name : "", /* name */

View File

@ -30,7 +30,7 @@ static int ext2_generate(struct image *image)
const char *label = cfg_getstr(image->imagesec, "label");
const char *fs_timestamp = cfg_getstr(image->imagesec, "fs-timestamp");
ret = systemp(image, "%s -d %s --size-in-blocks=%lld -i 16384 %s %s",
ret = systemp(image, "%s -d '%s' --size-in-blocks=%lld -i 16384 '%s' %s",
get_opt("genext2fs"),
mountpath(image), image->size / 1024, imageoutfile(image),
extraargs);
@ -39,19 +39,19 @@ static int ext2_generate(struct image *image)
return ret;
if (features && features[0] != '\0') {
ret = systemp(image, "%s -O \"%s\" %s", get_opt("tune2fs"),
ret = systemp(image, "%s -O '%s' '%s'", get_opt("tune2fs"),
features, imageoutfile(image));
if (ret)
return ret;
}
if (label && label[0] != '\0') {
ret = systemp(image, "%s -L \"%s\" %s", get_opt("tune2fs"),
ret = systemp(image, "%s -L '%s' '%s'", get_opt("tune2fs"),
label, imageoutfile(image));
if (ret)
return ret;
}
ret = systemp(image, "%s -pvfD %s", get_opt("e2fsck"),
ret = systemp(image, "%s -pvfD '%s'", get_opt("e2fsck"),
imageoutfile(image));
/* e2fsck return 1 when the filesystem was successfully modified */

View File

@ -25,18 +25,22 @@
static int iso_generate(struct image *image)
{
int ret;
char *boot;
char *boot_image = cfg_getstr(image->imagesec, "boot-image");
char *bootargs = cfg_getstr(image->imagesec, "bootargs");
char *extraargs = cfg_getstr(image->imagesec, "extraargs");
char *input_charset = cfg_getstr(image->imagesec, "input-charset");
char *volume_id = cfg_getstr(image->imagesec, "volume-id");
ret = systemp(image, "%s -input-charset %s -R -hide-rr-moved %s %s %s -V '%s' %s -o %s %s",
if (boot_image)
xasprintf(&boot, "-b '%s' %s", boot_image, bootargs);
else
boot = "";
ret = systemp(image, "%s -input-charset %s -R -hide-rr-moved %s -V '%s' %s -o '%s' '%s'",
get_opt("genisoimage"),
input_charset,
boot_image ? "-b" : "",
boot_image ? boot_image : "",
boot_image ? bootargs : "",
boot,
volume_id,
extraargs,
imageoutfile(image),

View File

@ -29,7 +29,7 @@ static int jffs2_generate(struct image *image)
extraargs = cfg_getstr(image->imagesec, "extraargs");
ret = systemp(image, "%s --eraseblock=%d -d %s -o %s %s",
ret = systemp(image, "%s --eraseblock=%d -d '%s' -o '%s' %s",
get_opt("mkfsjffs2"),
image->flash_type->pebsize, mountpath(image), imageoutfile(image),
extraargs);

View File

@ -40,7 +40,7 @@ static int squash_generate(struct image *image)
else
snprintf(compression, sizeof(compression), "-comp %s", comp_setup);
return systemp(image, "%s %s %s -b %u -noappend %s %s",
return systemp(image, "%s '%s' '%s' -b %u -noappend %s %s",
get_opt("mksquashfs"),
mountpath(image), /* source dir */
imageoutfile(image), /* destination file */

View File

@ -32,7 +32,7 @@ static int tar_generate(struct image *image)
if (strstr(image->file, ".tar.bz2"))
comp = "j";
ret = systemp(image, "%s c%s -f %s -C %s .",
ret = systemp(image, "%s c%s -f '%s' -C '%s' .",
get_opt("tar"),
comp,
imageoutfile(image), mountpath(image));

View File

@ -76,7 +76,7 @@ static int ubi_generate(struct image *image)
fclose(fini);
ret = systemp(image, "%s -s %d -O %d -p %d -m %d -o %s %s %s",
ret = systemp(image, "%s -s %d -O %d -p %d -m %d -o '%s' '%s' %s",
get_opt("ubinize"),
image->flash_type->sub_page_size,
image->flash_type->vid_header_offset,

View File

@ -34,7 +34,7 @@ static int ubifs_generate(struct image *image)
else
max_leb_cnt = image->size / image->flash_type->lebsize;
ret = systemp(image, "%s -d %s -e %d -m %d -c %d -o %s %s",
ret = systemp(image, "%s -d '%s' -e %d -m %d -c %d -o '%s' %s",
get_opt("mkfsubifs"),
mountpath(image),
image->flash_type->lebsize,

View File

@ -33,7 +33,7 @@ static int vfat_generate(struct image *image)
if (ret)
return ret;
ret = systemp(image, "%s %s %s", get_opt("mkdosfs"),
ret = systemp(image, "%s %s '%s'", get_opt("mkdosfs"),
extraargs, imageoutfile(image));
if (ret)
return ret;
@ -48,7 +48,7 @@ static int vfat_generate(struct image *image)
while ((next = strchr(next, '/')) != NULL) {
*next = '\0';
/* ignore the error: mdd fails if the target exists. */
systemp(image, "%s -DsS -i %s ::%s",
systemp(image, "%s -DsS -i %s '::%s'",
get_opt("mmd"), imageoutfile(image), path);
*next = '/';
++next;
@ -56,7 +56,7 @@ static int vfat_generate(struct image *image)
image_info(image, "adding file '%s' as '%s' ...\n",
child->file, *target ? target : child->file);
ret = systemp(image, "%s -bsp -i %s %s ::%s",
ret = systemp(image, "%s -bsp -i '%s' '%s' '::%s'",
get_opt("mcopy"), imageoutfile(image),
file, target);
if (ret)
@ -65,7 +65,7 @@ static int vfat_generate(struct image *image)
if (!list_empty(&image->partitions))
return 0;
ret = systemp(image, "%s -bsp -i %s %s/* ::", get_opt("mcopy"),
ret = systemp(image, "%s -bsp -i '%s' '%s'/* ::", get_opt("mcopy"),
imageoutfile(image), mountpath(image));
return ret;
}