Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hd-image: add support for specifying byte value used for filling #274

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions genimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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");
Expand Down
1 change: 1 addition & 0 deletions genimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion image-hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading