Messages in this thread | | | Date | Sat, 22 May 2004 14:56:33 +0200 | From | Andries Brouwer <> | Subject | Re: rfc: test whether a device has a partition table |
| |
On Sat, May 22, 2004 at 01:18:34PM +0200, Uwe Bonnes wrote:
> around last september there was a discussion about the linux kernel > recognizing "supperfloppys" as disks with bogus partition tables.
Yes - already had forgotten about that - thanks for reviving
> Linux Torvalds wrote at one point in the discussion:
> >I don't mind the 0x00/0x80 "boot flag" checks - those look fairly > > obvious and look reasonably safe to add to the partitioning code. > > The discussion seemed to fade out with no visible result, and for example my > USB stick "ID 0d7d:1420 Apacer" with a floppy as second partition gets > recognized as: > SCSI device sdc: 2880 512-byte hdwr sectors (1 MB) > sdc: Write Protect is off > sdc: sdc1 sdc2 sdc3 sdc4
What do you mean by "floppy as second partition"?
> 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))
Hmm. get_unaligned() for a single byte? I see no reason for these two macros. Also, it is a good habit to parenthesize macro parameters.
> + /* > + Some consistancy check for a valid partition table
consistency
> + Boot indicator must either be 0x80 or 0x0 on all primary partitions > + Only one partition may be marked bootable (0x80) > + */ > + p = (struct partition *) (data + 0x1be); > + for (slot = 1 ; slot <= 4 ; slot++, p++) { > + if ((BOOT_IND(p) != 0x80) && (BOOT_IND(p) != 0x0)) > + return 0; > + if (BOOT_IND(p) == 0x80) > + nr_bootable++; > + } > + if (nr_bootable > 1) > + return 0;
I have no objections.
Does it in your case suffice to check for 0 / 0x80 only (without testing nr_bootable)?
I would prefer to omit that test, until there is at least one person who shows a boot sector where it is needed.
Andries - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |