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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-02-23 09:21:40 +01:00
parent 5353ba3f0d
commit 45c2daa612
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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'"),