diff --git a/README.rst b/README.rst index 4e64732..009af9a 100644 --- a/README.rst +++ b/README.rst @@ -122,7 +122,8 @@ Partition options: :image: The image file this partition shall be filled with :fill: Boolean specifying that all bytes of the partition should be explicitly initialized. Any bytes beyond the size of the specified - image will be set to 0. + image will be set to ``fill-value``. +:fill-value: Byte value used when ``fill`` is true, defaults to 0. :autoresize: Boolean specifying that the partition should be resized automatically. For UBI volumes this means that the ``autoresize`` flag is set. Only one volume can have this flag. diff --git a/genimage.c b/genimage.c index 357e431..d2219f6 100644 --- a/genimage.c +++ b/genimage.c @@ -102,6 +102,7 @@ static cfg_opt_t partition_opts[] = { CFG_BOOL("hidden", cfg_false, CFGF_NONE), CFG_BOOL("no-automount", cfg_false, CFGF_NONE), CFG_BOOL("fill", cfg_false, CFGF_NONE), + CFG_INT("fill-value", 0, CFGF_NONE), CFG_STR("image", NULL, CFGF_NONE), CFG_STR_LIST("holes", NULL, CFGF_NONE), CFG_BOOL("autoresize", 0, CFGF_NONE), @@ -403,6 +404,7 @@ static int parse_partitions(struct image *image, cfg_t *imagesec) part->hidden = cfg_getbool(partsec, "hidden"); part->no_automount = cfg_getbool(partsec, "no-automount"); part->fill = cfg_getbool(partsec, "fill"); + part->fill_value = cfg_getint(partsec, "fill-value"); part->image = cfg_getstr(partsec, "image"); part->autoresize = cfg_getbool(partsec, "autoresize"); part->in_partition_table = cfg_getbool(partsec, "in-partition-table"); diff --git a/genimage.h b/genimage.h index 055e294..4184170 100644 --- a/genimage.h +++ b/genimage.h @@ -45,6 +45,7 @@ struct partition { cfg_bool_t hidden; cfg_bool_t no_automount; cfg_bool_t fill; + unsigned char fill_value; const char *image; off_t imageoffset; struct list_head list; diff --git a/image-hd.c b/image-hd.c index 5839154..88783b3 100644 --- a/image-hd.c +++ b/image-hd.c @@ -609,7 +609,8 @@ static int hdimage_generate(struct image *image) return -E2BIG; } - ret = insert_image(image, child, part->fill ? part->size : child->size, part->offset, 0); + ret = insert_image(image, child, part->fill ? part->size : child->size, + part->offset, part->fill_value); if (ret) { image_error(image, "failed to write image partition '%s'\n", part->name);