chiark / gitweb /
volume_id: always check for all filesystem types and skip conflicting results
[elogind.git] / extras / volume_id / lib / fat.c
index 95735c2d2d4f87e31843751d5d0667024caf4673..2d98b65b50e7e2dca2bb51aaaaab061d2d7901c0 100644 (file)
@@ -281,10 +281,6 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off, uint64_t size)
        if (buf == NULL)
                return -1;
 
-       /* check signature */
-       if (buf[510] != 0x55 || buf[511] != 0xaa)
-               return -1;
-
        vs = (struct vfat_super_block *) buf;
        if (memcmp(vs->sysid, "NTFS", 4) == 0)
                return -1;
@@ -305,6 +301,10 @@ int volume_id_probe_vfat(struct volume_id *id, uint64_t off, uint64_t size)
        if (memcmp(vs->type.fat.magic, "FAT12   ", 8) == 0)
                goto magic;
 
+       /* check signature */
+       if (buf[510] != 0x55 || buf[511] != 0xaa)
+               return -1;
+
        /* some old floppies don't have a magic, expect the boot jump address to match */
        if ((vs->boot_jump[0] != 0xeb || vs->boot_jump[2] != 0x90) &&
             vs->boot_jump[0] != 0xe9)
@@ -497,6 +497,7 @@ fat32:
 found:
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
        id->type = "vfat";
-
+       /* we think this is fat, but we make sure no other signatures are found */
+       id->force_unique_result = 1;
        return 0;
 }