aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions
diff options
context:
space:
mode:
authorFrank Seidel <fseidel@suse.de>2008-04-28 05:16:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:47 -0400
commit0607fd02587a6b4b086dc746d63123c1f284db68 (patch)
treeca9ea867ee8a93c9e2e706a2911019c16b0794e1 /fs/partitions
parent73f20e58b1d586e9f6d3ddc3aad872829aca7743 (diff)
fat: detect media without partition table correctly
I received a complaint that some FAT formated medias (e.g. sd memory cards) trigger a "unknown partition table" message even though there is no partition table and they work correctly, while in general (when e.g. formated with mkdosfs or even Windows Vista) this message is not shown. Currently this seems only to happen when the medias get formatted with Windows XP (and possibly Win 2000). Then the boot indicator byte contains garbage (part of text message) and so do the other parts checked by msdos_paritition which then later triggers this message. References: novell bug #364365 Most fat formatted media without partition table contains zeros in the boot indication and the other tested bytes and so falls through the checks in msdos_partition, leading it to return with 1 (all is fine). But some (e.g. WinXP formatted) fat fomated medias don't use boot_ind and so the check fails and causes a "unkown partition table" warning eventhough there is none and everything would be fine. This additional check directly verifies if there is a fat formatted medium without a partition table. Signed-off-by: Frank Seidel <fseidel@suse.de> Cc: Andreas Dilger <adilger@sun.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/partitions')
-rw-r--r--fs/partitions/msdos.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c
index 5567ec0d03a3..796511886f28 100644
--- a/fs/partitions/msdos.c
+++ b/fs/partitions/msdos.c
@@ -18,7 +18,7 @@
18 * 18 *
19 * Re-organised Feb 1998 Russell King 19 * Re-organised Feb 1998 Russell King
20 */ 20 */
21 21#include <linux/msdos_fs.h>
22 22
23#include "check.h" 23#include "check.h"
24#include "msdos.h" 24#include "msdos.h"
@@ -419,6 +419,7 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
419 Sector sect; 419 Sector sect;
420 unsigned char *data; 420 unsigned char *data;
421 struct partition *p; 421 struct partition *p;
422 struct fat_boot_sector *fb;
422 int slot; 423 int slot;
423 424
424 data = read_dev_sector(bdev, 0, &sect); 425 data = read_dev_sector(bdev, 0, &sect);
@@ -444,8 +445,21 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
444 p = (struct partition *) (data + 0x1be); 445 p = (struct partition *) (data + 0x1be);
445 for (slot = 1; slot <= 4; slot++, p++) { 446 for (slot = 1; slot <= 4; slot++, p++) {
446 if (p->boot_ind != 0 && p->boot_ind != 0x80) { 447 if (p->boot_ind != 0 && p->boot_ind != 0x80) {
447 put_dev_sector(sect); 448 /*
448 return 0; 449 * Even without a valid boot inidicator value
450 * its still possible this is valid FAT filesystem
451 * without a partition table.
452 */
453 fb = (struct fat_boot_sector *) data;
454 if (slot == 1 && fb->reserved && fb->fats
455 && fat_valid_media(fb->media)) {
456 printk("\n");
457 put_dev_sector(sect);
458 return 1;
459 } else {
460 put_dev_sector(sect);
461 return 0;
462 }
449 } 463 }
450 } 464 }
451 465