libfdisk: (gpt) follow label-id from script
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
9138d6f972
commit
4b43f7c96b
|
@ -505,6 +505,7 @@ static int gpt_mknew_header(struct fdisk_context *cxt,
|
|||
struct gpt_header *header, uint64_t lba)
|
||||
{
|
||||
uint64_t first, last;
|
||||
int has_id = 0;
|
||||
|
||||
if (!cxt || !header)
|
||||
return -ENOSYS;
|
||||
|
@ -525,9 +526,17 @@ static int gpt_mknew_header(struct fdisk_context *cxt,
|
|||
header->last_usable_lba = cpu_to_le64(last);
|
||||
|
||||
gpt_mknew_header_common(cxt, header, lba);
|
||||
uuid_generate_random((unsigned char *) &header->disk_guid);
|
||||
swap_efi_guid(&header->disk_guid);
|
||||
|
||||
if (cxt->script) {
|
||||
const char *id = fdisk_script_get_header(cxt->script, "label-id");
|
||||
if (id && string_to_guid(id, &header->disk_guid) == 0)
|
||||
has_id = 1;
|
||||
}
|
||||
|
||||
if (!has_id) {
|
||||
uuid_generate_random((unsigned char *) &header->disk_guid);
|
||||
swap_efi_guid(&header->disk_guid);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -900,7 +900,7 @@ int test_apply(struct fdisk_test *ts, int argc, char *argv[])
|
|||
int rc;
|
||||
|
||||
cxt = fdisk_new_context();
|
||||
fdisk_assign_device(cxt, devname, 1);
|
||||
fdisk_assign_device(cxt, devname, 0);
|
||||
|
||||
dp = fdisk_new_script_from_file(cxt, scriptname);
|
||||
if (!dp)
|
||||
|
@ -925,6 +925,8 @@ int test_apply(struct fdisk_test *ts, int argc, char *argv[])
|
|||
done:
|
||||
fdisk_free_iter(itr);
|
||||
fdisk_unref_table(tb);
|
||||
|
||||
/*fdisk_write_disklabel(cxt);*/
|
||||
fdisk_unref_context(cxt);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue