diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-05-07 07:52:21 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-05-07 12:40:42 +0200 |
commit | 3af6d35b01343b9adbae51ef179fe9bc6817a7ec (patch) | |
tree | 451d9ba480e55b6beebb18afe98987ef7dbf540d /image-hd.c | |
parent | 9370489c3cd3e8587f77d4b78e8d067898315f03 (diff) | |
download | genimage-3af6d35b01343b9adbae51ef179fe9bc6817a7ec.tar.gz genimage-3af6d35b01343b9adbae51ef179fe9bc6817a7ec.tar.xz |
image-hd: add option to extend the image to the full size
This can be useful when the image is used directly, e.g. with qemu.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'image-hd.c')
-rw-r--r-- | image-hd.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -33,6 +33,7 @@ struct hdimage { uint32_t disksig; const char *disk_uuid; cfg_bool_t gpt; + cfg_bool_t fill; }; struct mbr_partition_entry { @@ -379,6 +380,14 @@ static int hdimage_generate(struct image *image) } } + if (hd->fill) { + ret = extend_file(image, image->size); + if (ret) { + image_error(image, "failed to fill the image.\n"); + return ret; + } + } + if (hd->partition_table) { if (hd->gpt) { ret = hdimage_insert_gpt(image, &image->partitions); @@ -414,6 +423,7 @@ static int hdimage_setup(struct image *image, cfg_t *cfg) hd->extended_partition = cfg_getint(cfg, "extended-partition"); hd->disksig = strtoul(cfg_getstr(cfg, "disk-signature"), NULL, 0); hd->gpt = cfg_getbool(cfg, "gpt"); + hd->fill = cfg_getbool(cfg, "fill"); hd->disk_uuid = cfg_getstr(cfg, "disk-uuid"); if (hd->extended_partition > 4) { @@ -564,6 +574,7 @@ cfg_opt_t hdimage_opts[] = { CFG_BOOL("partition-table", cfg_true, CFGF_NONE), CFG_INT("extended-partition", 0, CFGF_NONE), CFG_BOOL("gpt", cfg_false, CFGF_NONE), + CFG_BOOL("fill", cfg_false, CFGF_NONE), CFG_END() }; |