summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2019-09-04 09:46:55 +0000
committerGitHub <noreply@github.com>2019-09-04 09:46:55 +0000
commit3bd77db41229b731b2bd4eef244f0561e88af287 (patch)
tree6cb8d49da24066b0943924d120bdb29979c3f740
parentfe10a25f2e22b2f6461bb1736651dd2d81b3db44 (diff)
parent909c449011db54ef13d997833e5b7921ba0e7f56 (diff)
downloadgenimage-3bd77db41229b731b2bd4eef244f0561e88af287.tar.gz
genimage-3bd77db41229b731b2bd4eef244f0561e88af287.tar.xz
Merge pull request #66 from mniestroj/mbr-random-disk-signature
hdimage: use random mbr disk signature if not provided
-rw-r--r--README.rst4
-rw-r--r--image-hd.c8
2 files changed, 10 insertions, 2 deletions
diff --git a/README.rst b/README.rst
index e7c14e4..eac10ef 100644
--- a/README.rst
+++ b/README.rst
@@ -189,7 +189,9 @@ Options:
:extended-partition: Number of the extended partition. Contains the number of the
extended partition between 1 and 4 or 0 for automatic. Defaults
to 0.
-:disk-signature: 32 bit integer used as disk signature (offset 440 in the MBR)
+:disk-signature: 32 bit integer used as disk signature (offset 440 in the
+ MBR). Using a special value ``random`` will result in
+ using random 32 bit number.
:gpt: Boolean. If true, a GPT type partion table is written. If false
a DOS type partition table is written. Defaults to false.
:disk-uuid: UUID string used as disk id in GPT partitioning. Defaults to a
diff --git a/image-hd.c b/image-hd.c
index 204d601..93f29e2 100644
--- a/image-hd.c
+++ b/image-hd.c
@@ -416,12 +416,13 @@ static int hdimage_setup(struct image *image, cfg_t *cfg)
int has_extended, autoresize = 0;
unsigned int partition_table_entries = 0;
unsigned long long now = 0;
+ const char *disk_signature;
struct hdimage *hd = xzalloc(sizeof(*hd));
hd->align = cfg_getint_suffix(cfg, "align");
hd->partition_table = cfg_getbool(cfg, "partition-table");
hd->extended_partition = cfg_getint(cfg, "extended-partition");
- hd->disksig = strtoul(cfg_getstr(cfg, "disk-signature"), NULL, 0);
+ disk_signature = cfg_getstr(cfg, "disk-signature");
hd->gpt = cfg_getbool(cfg, "gpt");
hd->fill = cfg_getbool(cfg, "fill");
hd->disk_uuid = cfg_getstr(cfg, "disk-uuid");
@@ -456,6 +457,11 @@ static int hdimage_setup(struct image *image, cfg_t *cfg)
hd->disk_uuid = uuid_random();
}
+ if (!strcmp(disk_signature, "random"))
+ hd->disksig = random();
+ else
+ hd->disksig = strtoul(disk_signature, NULL, 0);
+
partition_table_entries = 0;
list_for_each_entry(part, &image->partitions, list) {
if (autoresize) {