From 45c2daa61228d198800e2e63ba9be20d90e2a8f9 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 23 Feb 2021 09:21:40 +0100 Subject: [PATCH] sfdisk: support for type="partition type name" For example: # echo 'size=10MiB, type="linux usr x86"' | sfdisk /dev/sdc ... New situation: Device Start End Sectors Size Type /dev/sdc1 2048 22527 20480 10M Linux /usr (x86) Signed-off-by: Karel Zak --- disk-utils/sfdisk.8 | 7 ++++++- disk-utils/sfdisk.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 index 0c1453e8d8..6e92bf8f5e 100644 --- a/disk-utils/sfdisk.8 +++ b/disk-utils/sfdisk.8 @@ -467,6 +467,10 @@ as a shortcut as a first possibility in partitioning scripts although on other p Since v2.36 libfdisk supports partition type aliases as extension to shortcuts. The alias is a simple human readable word (e.g. "linux"). +Since v2.37 libfdisk supports partition type names on input, ignoring the case +of the characters and all non-alphanumeric and non-digit characters in the name +(e.g. "Linux /usr x86" is the same as "linux usr-x86"). + Supported shortcuts and aliases: .TP .B L - alias 'linux' @@ -550,7 +554,8 @@ GPT partition name. .TP .BI type= code A hexadecimal number (without 0x) for an MBR partition, a GUID for a GPT partition, -or a shortcut as for unnamed-fields format. +a shortcut as for unnamed-fields format or a type name (e.g. type="Linux /usr (x86)"). +See above the section about the unnamed-fields format for more details. For backward compatibility the \fBId=\fR field has the same meaning. .SH EMPTY DISK LABEL .B sfdisk diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 963cc745c2..193dcebfc1 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -1165,6 +1165,7 @@ static int command_parttype(struct sfdisk *sf, int argc, char **argv) type = fdisk_label_advparse_parttype(lb, typestr, FDISK_PARTTYPE_PARSE_DATA | FDISK_PARTTYPE_PARSE_ALIAS + | FDISK_PARTTYPE_PARSE_NAME | FDISK_PARTTYPE_PARSE_SHORTCUT); if (!type) errx(EXIT_FAILURE, _("failed to parse %s partition type '%s'"), -- 2.47.3