Re: rfc: test whether a device has a partition table
From: Uwe Bonnes
Date: Sat May 22 2004 - 10:15:24 EST
>>>>> "Andries" == Andries Brouwer <Andries.Brouwer@xxxxxx> writes:
Andries> What do you mean by "floppy as second partition"?
Sorry, I mean as second device realized in the stick. On my R50 Laptop
without a floppy drive, when the USB stick is plugged in, it appears as
Floppy "A:" in the boot process.
>> Find appended a patch that does the 0x00/0x80 "boot flag"
>> checks. Please discuss and consider for inclusion into the kernel.
>> +#define BOOT_IND(p) (get_unaligned(&p->boot_ind)) #define SYS_IND(p)
>> (get_unaligned(&p->sys_ind))
Andries> Hmm. get_unaligned() for a single byte? I see no reason for
Andries> these two macros. Also, it is a good habit to parenthesize
Andries> macro parameters.
I must admit that I didn't dig deeper what "get_unaligned" really means. From
what you tell, I understand that the macro is not needed, and the compare
would do if ((&p->sys_ind != 0x80) && (&p->sys_ind != 0x0)) should work too.
>> + /* + Some consistancy check for a valid partition table
...
Andries> I have no objections.
Andries> Does it in your case suffice to check for 0 / 0x80 only
Andries> (without testing nr_bootable)?
Yes, the test for 0x80/0 is sufficant. Testing nr_bootable was only paranoid...
Andries> I would prefer to omit that test, until there is at least one
Andries> person who shows a boot sector where it is needed.
Find appeneded the revised patch.
--
Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
--- linux-2.6.6/fs/partitions/msdos-sav.c 2004-05-10 04:32:52.000000000 +0200
+++ linux-2.6.6/fs/partitions/msdos.c 2004-05-22 17:14:08.000000000 +0200
@@ -389,6 +389,17 @@
put_dev_sector(sect);
return 0;
}
+
+ /*
+ Some consistancy check for a valid partition table
+ Boot indicator must either be 0x80 or 0x0 on all primary partitions
+ */
+ p = (struct partition *) (data + 0x1be);
+ for (slot = 1 ; slot <= 4 ; slot++, p++) {
+ if ( (p->boot_ind != 0x80) && (p->boot_ind!= 0x0))
+ return 0;
+ }
+
p = (struct partition *) (data + 0x1be);
#ifdef CONFIG_EFI_PARTITION
for (slot = 1 ; slot <= 4 ; slot++, p++) {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/