summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--image-hd.c11
-rwxr-xr-xtest/basic-images.test2
-rw-r--r--test/hdimage.config1
3 files changed, 13 insertions, 1 deletions
diff --git a/image-hd.c b/image-hd.c
index 1f80ae7..2f32b8b 100644
--- a/image-hd.c
+++ b/image-hd.c
@@ -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()
};
diff --git a/test/basic-images.test b/test/basic-images.test
index 9b53b45..35f1bfb 100755
--- a/test/basic-images.test
+++ b/test/basic-images.test
@@ -193,7 +193,7 @@ exec_test_set_prereq sfdisk
test_expect_success fdisk,sfdisk "hdimage" "
setup_test_images &&
run_genimage hdimage.config test.hdimage &&
- check_size images/test.hdimage 9442816 &&
+ check_size images/test.hdimage 10485760 &&
# check the this identifier
fdisk -l images/test.hdimage | grep identifier: > hdimage.fdisk &&
# check partitions; filter output to handle different sfdisk versions
diff --git a/test/hdimage.config b/test/hdimage.config
index 7287b6d..3785432 100644
--- a/test/hdimage.config
+++ b/test/hdimage.config
@@ -1,6 +1,7 @@
image test.hdimage {
hdimage {
align = 1M
+ fill = true
disk-signature = 0x12345678
}
partition part1 {