List the free unpartitioned areas on all or the specified devices.
*--part-attrs* _device partition-number_ [__attributes__]::
-Change the GPT partition attribute bits. If _attributes_ is not specified, then print the current partition settings. The _attributes_ argument is a comma- or space-delimited list of bits numbers or bit names. For example, the string "RequiredPartition,50,51" sets three bits. The currently supported attribute bits are:
+Change the GPT partition attribute bits. If _attributes_ is not specified, then print the current partition settings. The _attributes_ argument is a comma- or space-delimited list of bits numbers or bit names. For example, the string "RequiredPartition,50,51" sets three bits. Bit numbers may be given in decimal, octal, or hexadecimal (for example "0x2" is equivalent to "2" or "LegacyBIOSBootable"). The currently supported attribute bits are:
+
*Bit 0 (RequiredPartition)*;;
If this bit is set, the partition is required for the platform to function. The creator of the partition indicates that deletion or modification of the contents can result in loss of platform features or failure for the platform to boot or operate. The system cannot function normally if this partition is removed, and it should be considered part of the hardware of the system.
*Bits 3-47*;;
Undefined and must be zero. Reserved for expansion by future versions of the UEFI specification.
*Bits 48-63*;;
-Reserved for GUID specific use. The use of these bits will vary depending on the partition type. For example Microsoft uses bit 60 to indicate read-only, 61 for shadow copy of another partition, 62 for hidden partitions and 63 to disable automount.
+Reserved for GUID specific use. The use of these bits will vary depending on the partition type. For example Microsoft uses bit 60 to indicate read-only, 61 for shadow copy of another partition, 62 for hidden partitions and 63 to disable automount. The "GUID:" prefix (e.g. "GUID:60") is accepted for these bits but is restricted to the 48-63 range.
*--part-label* _device partition-number_ [__label__]::
Change the GPT partition name (label). If _label_ is not specified, then print the current partition label.
while (p && *p) {
int bit = -1;
+ const char *item;
while (isblank(*p)) p++;
if (!*p)
break;
+ item = p;
DBG(GPT, ul_debug(" item '%s'", p));
if (strncmp(p, GPT_ATTRSTR_REQ,
bit = GPT_ATTRBIT_NOBLOCK;
p += sizeof(GPT_ATTRSTR_NOBLOCK) - 1;
- /* GUID:<bit> as well as <bit> */
+ /* GUID:<bit> as well as <bit>. Bare numeric input accepts
+ * the named-flag bits (0..2) and the GUID-specific range
+ * (48..63). The GUID: prefix is the documented namespace
+ * for 48..63 only. Bits 3..47 are reserved by UEFI. */
} else if (isdigit((unsigned char) *p)
|| (strncmp(p, "GUID:", 5) == 0
&& isdigit((unsigned char) *(p + 5)))) {
char *end = NULL;
+ int is_guid = (*p == 'G');
- if (*p == 'G')
+ if (is_guid)
p += 5;
errno = 0;
bit = strtol(p, &end, 0);
- if (errno || !end || end == str
- || bit < GPT_ATTRBIT_GUID_FIRST
- || bit >= GPT_ATTRBIT_GUID_FIRST + GPT_ATTRBIT_GUID_COUNT)
+ if (errno || !end || end == p)
bit = -1;
- else
+ else if (bit >= GPT_ATTRBIT_GUID_FIRST
+ && bit < GPT_ATTRBIT_GUID_FIRST + GPT_ATTRBIT_GUID_COUNT)
+ p = end;
+ else if (!is_guid && bit >= GPT_ATTRBIT_REQ
+ && bit <= GPT_ATTRBIT_LEGACY)
p = end;
+ else
+ bit = -1;
}
if (bit < 0) {
- fdisk_warnx(cxt, _("unsupported GPT attribute bit '%s'"), p);
+ fdisk_warnx(cxt, _("unsupported GPT attribute bit '%s'"), item);
return -EINVAL;
}
--- /dev/null
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
+LegacyBIOSBootable
--- /dev/null
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
+LegacyBIOSBootable GUID:60
--- /dev/null
+
+The partition table has been altered.
+Calling ioctl() to re-read partition table.
+Syncing disks.
+RequiredPartition NoBlockIOProtocol LegacyBIOSBootable
--- /dev/null
+unsupported GPT attribute bit '5'
+sfdisk: <removed>: partition 2: failed to set partition attributes
ts_finalize_subtest
+ts_init_subtest "attrs-numeric-named"
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "0,1,2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "attrs-numeric-mixed"
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "2,GUID:60" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "attrs-numeric-hex"
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "0x2" >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_fdisk_clean $TS_DEVICE
+udevadm settle
+ts_finalize_subtest
+
+
+ts_init_subtest "attrs-reserved"
+$TS_CMD_SFDISK --part-attrs ${TS_DEVICE} 2 "5" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_fdisk_clean $TS_DEVICE
+ts_finalize_subtest
+
+
ts_init_subtest "read-dump"
$TS_CMD_WIPEFS -a ${TS_DEVICE} &> /dev/null
udevadm settle