summaryrefslogtreecommitdiff
path: root/extras/volume_id
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-11-21 18:28:56 +0100
committerKay Sievers <kay.sievers@suse.de>2005-11-21 18:28:56 +0100
commitcfd0fc66054cb7eab4989d214e4f8552dc2bf0b8 (patch)
treeee281b3359b57bfa41c540511693ec12058dec7c /extras/volume_id
parent8813e55c74d8224a361f62fc8c9f01591dfb58d3 (diff)
libvolume_id: fix weird fat volume recognition
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Diffstat (limited to 'extras/volume_id')
-rw-r--r--extras/volume_id/libvolume_id/fat.c31
-rw-r--r--extras/volume_id/libvolume_id/volume_id.h2
2 files changed, 15 insertions, 18 deletions
diff --git a/extras/volume_id/libvolume_id/fat.c b/extras/volume_id/libvolume_id/fat.c
index 26d0fe74ab..cea5b8cff2 100644
--- a/extras/volume_id/libvolume_id/fat.c
+++ b/extras/volume_id/libvolume_id/fat.c
@@ -161,48 +161,45 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
return -1;
if (memcmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
- goto valid;
+ goto magic;
if (memcmp(vs->type.fat32.magic, "FAT32 ", 8) == 0)
- goto valid;
+ goto magic;
if (memcmp(vs->type.fat.magic, "FAT16 ", 8) == 0)
- goto valid;
+ goto magic;
if (memcmp(vs->type.fat.magic, "MSDOS", 5) == 0)
- goto valid;
+ goto magic;
if (memcmp(vs->type.fat.magic, "FAT12 ", 8) == 0)
- goto valid;
+ goto magic;
- /*
- * There are old floppies out there without a magic, so we check
- * for well known values and guess if it's a fat volume
- */
+ /* some old floppies don't have a magic, so we expect the boot code to match */
/* boot jump address check */
if ((vs->boot_jump[0] != 0xeb || vs->boot_jump[2] != 0x90) &&
vs->boot_jump[0] != 0xe9)
return -1;
- /* heads check */
- if (vs->heads == 0)
+magic:
+ /* reserverd sector count */
+ if (!vs->reserved)
return -1;
- /* cluster size check*/
- if (vs->sectors_per_cluster == 0 ||
- (vs->sectors_per_cluster & (vs->sectors_per_cluster-1)))
+ /* fat count*/
+ if (!vs->fats)
return -1;
/* media check */
if (vs->media < 0xf8 && vs->media != 0xf0)
return -1;
- /* fat count*/
- if (vs->fats != 2)
+ /* cluster size check*/
+ if (vs->sectors_per_cluster == 0 ||
+ (vs->sectors_per_cluster & (vs->sectors_per_cluster-1)))
return -1;
-valid:
/* sector size check */
sector_size = le16_to_cpu(vs->sector_size);
if (sector_size != 0x200 && sector_size != 0x400 &&
diff --git a/extras/volume_id/libvolume_id/volume_id.h b/extras/volume_id/libvolume_id/volume_id.h
index 3e3acbde9f..ad65fe5438 100644
--- a/extras/volume_id/libvolume_id/volume_id.h
+++ b/extras/volume_id/libvolume_id/volume_id.h
@@ -14,7 +14,7 @@
#include <stdint.h>
#include <stddef.h>
-#define VOLUME_ID_VERSION 54
+#define VOLUME_ID_VERSION 55
#define VOLUME_ID_LABEL_SIZE 64
#define VOLUME_ID_UUID_SIZE 36