diff options
author | Karel Zak | 2007-05-31 14:31:51 +0200 |
---|---|---|
committer | Karel Zak | 2007-06-05 10:40:14 +0200 |
commit | 5dbff4c0eb7c326e21891b6ce4f123ba96511f87 (patch) | |
tree | 0d49f7da1065d4c772b38e455260f5ac0731eb4d /fdisk/fdisk.c | |
parent | fdisk: Makefile.am refactoring (diff) | |
download | kernel-qcow2-util-linux-5dbff4c0eb7c326e21891b6ce4f123ba96511f87.tar.gz kernel-qcow2-util-linux-5dbff4c0eb7c326e21891b6ce4f123ba96511f87.tar.xz kernel-qcow2-util-linux-5dbff4c0eb7c326e21891b6ce4f123ba96511f87.zip |
fdisk: add GPT detection code
The GPT (GUID Partition Table) is unsupported by fdisk, sfdisk and
cfdisk. Unfortunately, the fdisk doesn't complain about GPT.. that's
dangerous, because user is able to blindly edit PT with unexpected
results.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r-- | fdisk/fdisk.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index c4f6458c3..ecaac90eb 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -34,6 +34,8 @@ #include <linux/blkpg.h> #endif +#include "gpt.h" + static void delete_partition(int i); #define hex_val(c) ({ \ @@ -2372,6 +2374,14 @@ is_ide_cdrom_or_tape(char *device) { } static void +gpt_warning(char *dev) +{ + if (dev && gpt_probe_signature_devname(dev)) + fprintf(stderr, _("\nWARNING: GPT (GUID Partition Table) detected on '%s'! " + "The util fdisk doesn't support GPT. Use GNU Parted.\n\n"), dev); +} + +static void try(char *device, int user_specified) { int gb; @@ -2381,6 +2391,7 @@ try(char *device, int user_specified) { if (!user_specified) if (is_ide_cdrom_or_tape(device)) return; + gpt_warning(device); if ((fd = open(disk_device, type_open)) >= 0) { gb = get_boot(try_only); if (gb > 0) { /* I/O error */ @@ -2440,6 +2451,8 @@ unknown_command(int c) { printf(_("%c: unknown command\n"), c); } + + int main(int argc, char **argv) { int j, c; @@ -2544,6 +2557,7 @@ main(int argc, char **argv) { for (j = optind; j < argc; j++) { disk_device = argv[j]; + gpt_warning(disk_device); if ((fd = open(disk_device, type_open)) < 0) fatal(unable_to_open); if (disksize(fd, &size)) @@ -2564,6 +2578,7 @@ main(int argc, char **argv) { else fatal(usage2); + gpt_warning(disk_device); get_boot(fdisk); if (osf_label) { |