[PATCH] bug fix: improve DOS partition table recognition
Colin Watson
cjwatson at ubuntu.com
Wed May 28 11:12:51 UTC 2008
* libparted/labels/dos.c (msdos_probe): Make Parted's partition-table
recognition code use the same technique that is used by the Linux
kernel and by util-linux's fdisk. I.e., accept it whenever all four
boot indicators are 0 or 0x80, rather than using the FAT file system-
recognizing heuristic.
More analysis here:
http://thread.gmane.org/gmane.comp.gnu.parted.devel/2142/focus=3D2154
Reported by David Bala=C5=BEic here:
https://bugs.launchpad.net/ubuntu/+source/parted/+bug/232175
http://thread.gmane.org/gmane.comp.gnu.parted.devel/2142
---
libparted/labels/dos.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index e513a05..81d8600 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -192,14 +192,16 @@ msdos_probe (const PedDevice *dev)
if (PED_LE16_TO_CPU (part_table->magic) !=3D MSDOS_MAGIC)
goto probe_fail;
- /* if this is a FAT fs, fail here. Note that the Smart Boot Manager
- * Loader (SBML) signature indicates a partition table, not a file
- * system.
+ /* If this is a FAT fs, fail here. Checking for the FAT signature
+ * has some false positives; instead, do what the Linux kernel does
+ * and ensure that each partition has a boot indicator that is
+ * either 0 or 0x80.
*/
- if ((!strncmp (part_table->boot_code + 0x36, "FAT", 3)
- && strncmp (part_table->boot_code + 0x40, "SBML", 4) !=3D 0)
- || !strncmp (part_table->boot_code + 0x52, "FAT", 3))
- goto probe_fail;
+ for (i =3D 0; i < 4; i++) {
+ if (part_table->partitions[i].boot_ind !=3D 0
+ && part_table->partitions[i].boot_ind !=3D 0x80)
+ goto probe_fail;
+ }
/* If this is a GPT disk, fail here */
for (i =3D 0; i < 4; i++) {
--
1.5.6.rc0.30.g51263
More information about the parted-devel
mailing list