summaryrefslogtreecommitdiffstats
path: root/fdisks/utils.c
diff options
context:
space:
mode:
authorDavidlohr Bueso2012-09-27 09:50:27 +0200
committerKarel Zak2012-09-27 13:38:14 +0200
commit766d5156c43b784700d28d1c1141008b2bf35ed7 (patch)
tree18fb6ef0dde41c5152369a973c71bb4349e0b659 /fdisks/utils.c
parentfdisk: cleanup debug messages and comments (diff)
downloadkernel-qcow2-util-linux-766d5156c43b784700d28d1c1141008b2bf35ed7.tar.gz
kernel-qcow2-util-linux-766d5156c43b784700d28d1c1141008b2bf35ed7.tar.xz
kernel-qcow2-util-linux-766d5156c43b784700d28d1c1141008b2bf35ed7.zip
fdisk: add GPT support
This patch allows fdisk to handle GUID partition tables, based on the latest UEFI specifications version 2.3.1, from June 27th, 2012. The following operations are supported: - Probing (detects both protective and hybrid MBRs) - Writing to disk - Listing used partitions - Adding partitions - Deleting partitions - Data integrity verifications (for both headers and partitions). A few considerations: - Currently we do not fix invalid primary headers -- we just abort! - Header checksums are updated upon every change (ie: add/delete partitions), this allows us to mathematically verify the changes on-the-fly, and not only when writing to disk, like most other related tools do. - We are extremly picky when writing to disk, any error aborts the opeartion. - When creating a new partition, the following GUIDs are available: http://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs For test cases, the gpt.img from libblkid tests, scsi_debug and my own hard drive (/dev/sda) were used. For the image, all operations were tested successfully, and for /dev/sda all except write, which was not tested - hey, I'm not suicidal! [kzak@redhat.com: - add get/set partition type functions - use unified on strings based table for partition types - add partition type to table list function] Tested-and-reviewed-by: Petr Uzel <petr.uzel@suse.cz> Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/utils.c')
-rw-r--r--fdisks/utils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fdisks/utils.c b/fdisks/utils.c
index 0e15875e5..a206631d8 100644
--- a/fdisks/utils.c
+++ b/fdisks/utils.c
@@ -40,6 +40,7 @@ int fdisk_debug_mask;
*/
static const struct fdisk_label *labels[] =
{
+ &gpt_label,
&dos_label,
&sun_label,
&sgi_label,
@@ -653,8 +654,9 @@ struct fdisk_parttype *fdisk_parse_parttype(
/* maybe specified by order number */
errno = 0;
i = strtol(str, &end, 0);
- if (errno == 0 && *end == '\0' && i < (int) fdisk_get_nparttypes(cxt)) {
- ret = &types[i];
+ if (errno == 0 && *end == '\0' && i > 0
+ && i - 1 < (int) fdisk_get_nparttypes(cxt)) {
+ ret = &types[i - 1];
goto done;
}
}