summaryrefslogtreecommitdiff
path: root/lib/blkid
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-08-23 22:11:01 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-08-24 17:24:18 -0400
commit78d89cda680498957e4ad78602751d1f905cee08 (patch)
treebe9842075ca80de6227635950945a6b316eb59ed /lib/blkid
parent30ab7f4c65bd32a7d24f53e8c87ed5b5ae757626 (diff)
downloade2fsprogs-78d89cda680498957e4ad78602751d1f905cee08.tar.gz
libblkid: Fix false detection of DFSee created filesystems.
OS/2 and DFSee creates a pseudo FAT-12/16 header in the first 512 bytes of a filesystem which looks enough like a FAT-12/16 to fool blkid. Part of this is because we don't require ms_magic or vs_magic to be the strings "FAT12 ", "FAT16 ", or "FAT32 ", since some FAT filesystem formatters don't set ms_magic or vs_magic. To address this, we explicitly test for "JFS " and "HPFS " in ms_magic, and if they are found, we assume the filesystem is definitely not a FAT filesystem. Addresses-Launchpad-Bug: #255255 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/blkid')
-rw-r--r--lib/blkid/probe.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index e2d8a257..225116a4 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -566,25 +566,38 @@ static int probe_fat_nomagic(struct blkid_probe *probe,
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
{
- struct vfat_super_block *vs;
+ struct msdos_super_block *ms;
- vs = (struct vfat_super_block *)buf;
+ ms = (struct msdos_super_block *)buf;
/* heads check */
- if (vs->vs_heads == 0)
+ if (ms->ms_heads == 0)
return 1;
/* cluster size check*/
- if (vs->vs_cluster_size == 0 ||
- (vs->vs_cluster_size & (vs->vs_cluster_size-1)))
+ if (ms->ms_cluster_size == 0 ||
+ (ms->ms_cluster_size & (ms->ms_cluster_size-1)))
return 1;
/* media check */
- if (vs->vs_media < 0xf8 && vs->vs_media != 0xf0)
+ if (ms->ms_media < 0xf8 && ms->ms_media != 0xf0)
return 1;
/* fat counts(Linux kernel expects at least 1 FAT table) */
- if (!vs->vs_fats)
+ if (!ms->ms_fats)
+ return 1;
+
+ /*
+ * OS/2 and apparently DFSee will place a FAT12/16-like
+ * pseudo-superblock in the first 512 bytes of non-FAT
+ * filesystems --- at least JFS and HPFS, and possibly others.
+ * So we explicitly check for those filesystems at the
+ * FAT12/16 filesystem magic field identifier, and if they are
+ * present, we rule this out as a FAT filesystem, despite the
+ * FAT-like pseudo-header.
+ */
+ if ((memcmp(ms->ms_magic, "JFS ", 8) == 0) ||
+ (memcmp(ms->ms_magic, "HPFS ", 8) == 0))
return 1;
return probe_fat(probe, id, buf);