From: Karel Zak Date: Tue, 12 Mar 2013 10:58:34 +0000 (+0100) Subject: fdisk: improve MBR detection X-Git-Tag: v2.23-rc1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ed268d0a780fb0a2c6e0a8888d167f37d5f1da0;p=thirdparty%2Futil-linux.git fdisk: improve MBR detection Signed-off-by: Karel Zak --- diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c index 34465ef327..e2ec0d3b4b 100644 --- a/fdisks/fdiskdoslabel.c +++ b/fdisks/fdiskdoslabel.c @@ -428,6 +428,10 @@ static int dos_reset_alignment(struct fdisk_context *cxt) return 0; } +/* TODO: move to include/pt-dos.h and share with libblkid */ +#define AIX_MAGIC_STRING "\xC9\xC2\xD4\xC1" +#define AIX_MAGIC_STRLEN (sizeof(AIX_MAGIC_STRING) - 1) + static int dos_probe_label(struct fdisk_context *cxt) { size_t i; @@ -437,6 +441,10 @@ static int dos_probe_label(struct fdisk_context *cxt) assert(cxt->label); assert(fdisk_is_disklabel(cxt, DOS)); + /* ignore disks with AIX magic number */ + if (memcmp(cxt->firstsector, AIX_MAGIC_STRING, AIX_MAGIC_STRLEN) == 0) + return 0; + if (!mbr_is_valid_magic(cxt->firstsector)) return 0;