diff options
author | Karel Zak | 2019-08-08 10:34:27 +0200 |
---|---|---|
committer | Karel Zak | 2019-08-08 10:34:27 +0200 |
commit | 08474fde6669d89f5b77653ba9d378fc16e19903 (patch) | |
tree | 3a3e89150cd8ab1f9653aa2f6330195c280f6511 /libfdisk | |
parent | tests: use subtests for mountpoint(1) (diff) | |
download | kernel-qcow2-util-linux-08474fde6669d89f5b77653ba9d378fc16e19903.tar.gz kernel-qcow2-util-linux-08474fde6669d89f5b77653ba9d378fc16e19903.tar.xz kernel-qcow2-util-linux-08474fde6669d89f5b77653ba9d378fc16e19903.zip |
libfdisk: (script) support shortcuts in the type= field
The unnamed-field format supports partition type shortcuts:
",1MiB,L'
but for named-field format it requires full type:
(mbr) "size=1MiB,type=83"
(gpt) "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"
This patch implements type shortcuts also for named-field format:
"size=1MiB,type=L"
to make it more user-friendly and unified.
Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk')
-rw-r--r-- | libfdisk/src/script.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c index 3db76c87b..a28983dba 100644 --- a/libfdisk/src/script.c +++ b/libfdisk/src/script.c @@ -61,6 +61,8 @@ struct fdisk_script { force_label : 1; /* label: <name> specified */ }; +static struct fdisk_parttype *translate_type_shortcuts(struct fdisk_script *dp, char *str); + static void fdisk_script_free_header(struct fdisk_scriptheader *fi) { @@ -1054,8 +1056,11 @@ static int parse_line_nameval(struct fdisk_script *dp, char *s) rc = next_string(&p, &type); if (rc) break; - pa->type = fdisk_label_parse_parttype( - script_get_label(dp), type); + + pa->type = translate_type_shortcuts(dp, type); + if (!pa->type) + pa->type = fdisk_label_parse_parttype( + script_get_label(dp), type); free(type); if (!pa->type) { |