Jim Meyering <[EMAIL PROTECTED]> wrote: > Colin Watson <[EMAIL PROTECTED]> wrote: > ... >> Please consider the following patch, which does basically the same >> thing. I think it's sufficiently trivial (and obvious based on other >> implementations) to be non-copyrightable, but I can do assignment >> paperwork if you feel you need it. >> >> With this patch, the supplied boot sector prints as follows: >> >> $ LD_LIBRARY_PATH=`pwd`/libparted/.libs parted/.libs/parted ~/parted-test >> WARNING: You are not superuser. Watch out for permissions. >> GNU Parted 1.8.8.1.30-c31f >> Using /home/cjwatson/parted-test >> Welcome to GNU Parted! Type 'help' to view a list of commands. >> (parted) print >> Model: (file) >> Disk /home/cjwatson/parted-test: 1573MB >> Sector size (logical/physical): 512B/512B >> Partition Table: msdos >> >> Number Start End Size Type File system Flags >> 1 16.4kB 751MB 751MB primary boot >> 2 751MB 1027MB 276MB primary >> >> Signed-off-by: Colin Watson <[EMAIL PROTECTED]>
Thanks again, Colin, I've edited the log entry and pushed the following, along with a test (coming up in a separate message). From d732a2b78255d62162fab57b552a3f069b53f33f Mon Sep 17 00:00:00 2001 From: Colin Watson <[EMAIL PROTECTED]> Date: Wed, 28 May 2008 12:12:51 +0100 Subject: [PATCH] bug fix: improve DOS partition table recognition MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit * 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=2154 Reported by David Balažic 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) != 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) != 0) - || !strncmp (part_table->boot_code + 0x52, "FAT", 3)) - goto probe_fail; + for (i = 0; i < 4; i++) { + if (part_table->partitions[i].boot_ind != 0 + && part_table->partitions[i].boot_ind != 0x80) + goto probe_fail; + } /* If this is a GPT disk, fail here */ for (i = 0; i < 4; i++) { -- 1.5.6.rc0.30.g51263 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

