Messages in this thread Patch in this message | | | Date | Sat, 22 May 2004 19:45:23 +0200 | From | Andries Brouwer <> | Subject | [PATCH] Re: rfc: test whether a device has a partition table |
| |
On Sat, May 22, 2004 at 05:14:24PM +0200, Uwe Bonnes wrote:
> Yes, the test for 0x80/0 is sufficant.
Good.
> + if ( (p->boot_ind != 0x80) && (p->boot_ind!= 0x0)) > + return 0;
You'll need a "put_dev_sector(sect);" as well. Say,
--- msdos.c~ 2003-12-18 03:58:58 +++ msdos.c 2004-05-22 19:38:00 @@ -389,8 +389,23 @@ put_dev_sector(sect); return 0; } + + /* + * Now that the 55aa signature is present, this is probably + * either the boot sector of a FAT filesystem or a DOS-type + * partition table. Reject this in case the boot indicator + * is not 0 or 0x80. + */ p = (struct partition *) (data + 0x1be); + for (slot = 1; slot <= 4; slot++, p++) { + if (p->boot_ind != 0 && p->boot_ind != 0x80) { + put_dev_sector(sect); + return 0; + } + } + #ifdef CONFIG_EFI_PARTITION + p = (struct partition *) (data + 0x1be); for (slot = 1 ; slot <= 4 ; slot++, p++) { /* If this is an EFI GPT disk, msdos should ignore it. */ if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) { @@ -398,8 +413,8 @@ return 0; } } - p = (struct partition *) (data + 0x1be); #endif + p = (struct partition *) (data + 0x1be); /* * Look for partitions in two passes: Andries
[Linus, Andrew - I have no objections against this.]
- 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/
| |