mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-25 23:52:17 +00:00
btrfs-progs: mkfs: validate device uuid set on command line
We need to validate the device uuid the same way as the fsid: $ ./mkfs.btrfs --device-uuid 18eabcf0-6766-4fbf-b366-71b4ae725b2- img btrfs-progs v6.5.2 See https://btrfs.readthedocs.io for more information. ERROR: could not parse device UUID: 18eabcf0-6766-4fbf-b366-71b4ae725b2- Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d8032c3b8b
commit
9908894102
19
mkfs/main.c
19
mkfs/main.c
@ -1381,10 +1381,6 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||
error("the option -r is limited to a single device");
|
||||
goto error;
|
||||
}
|
||||
if (strlen(dev_uuid) != 0 && device_count > 1) {
|
||||
error("the option --device-uuid is limited to a single device");
|
||||
goto error;
|
||||
}
|
||||
if (shrink_rootdir && source_dir == NULL) {
|
||||
error("the option --shrink must be used with --rootdir");
|
||||
goto error;
|
||||
@ -1404,6 +1400,21 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (*dev_uuid) {
|
||||
uuid_t dummy_uuid;
|
||||
|
||||
if (uuid_parse(dev_uuid, dummy_uuid) != 0) {
|
||||
error("could not parse device UUID: %s", dev_uuid);
|
||||
goto error;
|
||||
}
|
||||
/* We allow non-unique device uuid for single device filesystem. */
|
||||
if (device_count != 1 && !test_uuid_unique(dev_uuid)) {
|
||||
error("the option --device-uuid %s can be used only for a single device filesystem",
|
||||
dev_uuid);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < device_count; i++) {
|
||||
file = argv[optind++];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user