diff options
author | Karel Zak | 2014-10-02 14:44:49 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-07 14:55:32 +0200 |
commit | 95085ec5d6c3f68641892279c2e10d24eb713ebd (patch) | |
tree | 42343125f5193f77ad116620e9cab298f08975b6 /libfdisk/src/dos.c | |
parent | sfdisk: cleanup option names (diff) | |
download | kernel-qcow2-util-linux-95085ec5d6c3f68641892279c2e10d24eb713ebd.tar.gz kernel-qcow2-util-linux-95085ec5d6c3f68641892279c2e10d24eb713ebd.tar.xz kernel-qcow2-util-linux-95085ec5d6c3f68641892279c2e10d24eb713ebd.zip |
libfdisk: (dos) use script label-id
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/dos.c')
-rw-r--r-- | libfdisk/src/dos.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 0448cc940..3e940c693 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -614,8 +614,8 @@ static int dos_get_disklabel_id(struct fdisk_context *cxt, char **id) static int dos_create_disklabel(struct fdisk_context *cxt) { - unsigned int id; - int rc; + unsigned int id = 0; + int rc, has_id = 0; assert(cxt); assert(cxt->label); @@ -623,8 +623,21 @@ static int dos_create_disklabel(struct fdisk_context *cxt) DBG(LABEL, ul_debug("DOS: creating new disklabel")); + if (cxt->script) { + char *end = NULL; + const char *s = fdisk_script_get_header(cxt->script, "label-id"); + + if (s) { + errno = 0; + id = strtol(s, &end, 16); + if (!errno && end && s < end) + has_id = 1; + } + } + /* random disk signature */ - random_get_bytes(&id, sizeof(id)); + if (!has_id) + random_get_bytes(&id, sizeof(id)); dos_init(cxt); rc = fdisk_init_firstsector_buffer(cxt); |