chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
volume_id: provide a custom debug function
[elogind.git]
/
extras
/
volume_id
/
libvolume_id
/
fat.c
diff --git
a/extras/volume_id/libvolume_id/fat.c
b/extras/volume_id/libvolume_id/fat.c
index 26d0fe74ab3c042a978fb2de543b2dd2b3c7ed6c..4840a2a23c73f2c74b9328ea51a4bae5c75802d8 100644
(file)
--- a/
extras/volume_id/libvolume_id/fat.c
+++ b/
extras/volume_id/libvolume_id/fat.c
@@
-23,8
+23,7
@@
#include <errno.h>
#include <ctype.h>
#include <errno.h>
#include <ctype.h>
-#include "volume_id.h"
-#include "logging.h"
+#include "libvolume_id.h"
#include "util.h"
#define FAT12_MAX 0xff5
#include "util.h"
#define FAT12_MAX 0xff5
@@
-58,7
+57,7
@@
struct vfat_super_block {
uint8_t magic[8];
uint8_t dummy2[192];
uint8_t pmagic[2];
uint8_t magic[8];
uint8_t dummy2[192];
uint8_t pmagic[2];
- }
__attribute__((__packed__))
fat;
+ }
PACKED
fat;
struct fat32_super_block {
uint32_t fat32_length;
uint16_t flags;
struct fat32_super_block {
uint32_t fat32_length;
uint16_t flags;
@@
-73,9
+72,9
@@
struct vfat_super_block {
uint8_t magic[8];
uint8_t dummy2[164];
uint8_t pmagic[2];
uint8_t magic[8];
uint8_t dummy2[164];
uint8_t pmagic[2];
- }
__attribute__((__packed__))
fat32;
- }
__attribute__((__packed__))
type;
-}
__attribute__((__packed__))
;
+ }
PACKED
fat32;
+ }
PACKED
type;
+}
PACKED
;
struct vfat_dir_entry {
uint8_t name[11];
struct vfat_dir_entry {
uint8_t name[11];
@@
-89,7
+88,7
@@
struct vfat_dir_entry {
uint16_t date_write;
uint16_t cluster_low;
uint32_t size;
uint16_t date_write;
uint16_t cluster_low;
uint32_t size;
-}
__attribute__((__packed__))
;
+}
PACKED
;
static uint8_t *get_attr_volume_id(struct vfat_dir_entry *dir, unsigned int count)
{
static uint8_t *get_attr_volume_id(struct vfat_dir_entry *dir, unsigned int count)
{
@@
-161,48
+160,45
@@
int volume_id_probe_vfat(struct volume_id *id, uint64_t off)
return -1;
if (memcmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
return -1;
if (memcmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
- goto
valid
;
+ goto
magic
;
if (memcmp(vs->type.fat32.magic, "FAT32 ", 8) == 0)
if (memcmp(vs->type.fat32.magic, "FAT32 ", 8) == 0)
- goto
valid
;
+ goto
magic
;
if (memcmp(vs->type.fat.magic, "FAT16 ", 8) == 0)
if (memcmp(vs->type.fat.magic, "FAT16 ", 8) == 0)
- goto
valid
;
+ goto
magic
;
if (memcmp(vs->type.fat.magic, "MSDOS", 5) == 0)
if (memcmp(vs->type.fat.magic, "MSDOS", 5) == 0)
- goto
valid
;
+ goto
magic
;
if (memcmp(vs->type.fat.magic, "FAT12 ", 8) == 0)
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;
/* 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;
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;
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;
return -1;
-valid:
/* sector size check */
sector_size = le16_to_cpu(vs->sector_size);
if (sector_size != 0x200 && sector_size != 0x400 &&
/* sector size check */
sector_size = le16_to_cpu(vs->sector_size);
if (sector_size != 0x200 && sector_size != 0x400 &&