aboutsummaryrefslogtreecommitdiffstats
path: root/fat_fs.h
diff options
context:
space:
mode:
authorLiu Aleaxander <Aleaxander@gmail.com>2009-05-16 15:07:00 +0800
committerLiu Aleaxander <Aleaxander@gmail.com>2009-05-16 15:07:00 +0800
commit487239a50776f619e41ce5a2c9f2f9db6038b8f4 (patch)
treedd80e5227ba97205be86b8b4829b192ae2d3e243 /fat_fs.h
parentfdae58f8e25461c8e44c15afd6172ca5428ca8d2 (diff)
downloaddevel-487239a50776f619e41ce5a2c9f2f9db6038b8f4.tar.gz
devel-487239a50776f619e41ce5a2c9f2f9db6038b8f4.tar.xz
devel-487239a50776f619e41ce5a2c9f2f9db6038b8f4.zip
Add fat file system stuffle
Diffstat (limited to 'fat_fs.h')
-rw-r--r--fat_fs.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/fat_fs.h b/fat_fs.h
new file mode 100644
index 0000000..a15bd82
--- /dev/null
+++ b/fat_fs.h
@@ -0,0 +1,111 @@
+#ifndef _FAT_FS_H
+#define _FAT_FS_H
+
+#include "types.h"
+
+
+#define FAT_DIR_ENTRY_SIZE 32
+
+#define FAT_ATTR_READ_ONLY 0x01
+#define FAT_ATTR_HIDDEN 0x02
+#define FAT_ATTR_SYSTEM 0x04
+#define FAT_ATTR_VOLUME_ID 0x08
+#define FAT_ATTR_DIRECTORY 0x10
+#define FAT_ATTR_ARCHIVE 0x20
+
+#define FAT_MAXFILE 256
+
+#define FAT_ATTR_LONG_NAME (FAT_ATTR_READ_ONLY \
+ | FAT_ATTR_HIDDEN \
+ | FAT_ATTR_SYSTEM \
+ | FAT_ATTR_VOLUME_ID)
+
+#define FAT_ATTR_VALID (FAT_ATTR_READ_ONLY \
+ | FAT_ATTR_HIDDEN \
+ | FAT_ATTR_SYSTEM \
+ | FAT_ATTR_DIRECTORY \
+ | FAT_ATTR_ARCHIVE)
+
+/*
+ * The fat file system structures
+ */
+
+struct fat_bpb {
+ __u8 jmp_boot[3];
+ __u8 oem_name[8];
+ __u16 sector_size;
+ __u8 bxSecPerClust;
+ __u16 bxResSectors;
+ __u8 bxFATs;
+ __u16 bxRootDirEnts;
+ __u16 bxSectors;
+ __u8 media;
+ __u16 bxFATsecs;
+ __u16 sectors_per_track;
+ __u16 num_heads;
+ __u32 num_hidden_sectors;
+ __u32 bsHugeSectors;
+
+ union {
+ struct {
+ __u8 num_ph_drive;
+ __u8 reserved;
+ __u8 boot_sig;
+ __u32 num_serial;
+ __u8 label[11];
+ __u8 fstype[8];
+ } __attribute__ ((packed)) fat12_16;
+
+ struct {
+ __u32 bxFATsecs_32;
+ __u16 extended_flags;
+ __u16 fs_version;
+ __u32 root_cluster;
+ __u16 fs_info;
+ __u16 backup_boot_sector;
+ __u8 reserved[12];
+ __u8 num_ph_drive;
+ __u8 reserved1;
+ __u8 boot_sig;
+ __u32 num_serial;
+ __u8 label[11];
+ __u8 fstype[8];
+ } __attribute__ ((packed)) fat32;
+
+ } __attribute__ ((packed)) u;
+
+} __attribute__ ((packed));
+
+
+
+struct fat_dir_entry {
+ __u8 name[11];
+ __u8 attr;
+ __u8 nt_reserved;
+ __u8 c_time_tenth;
+ __u16 c_time;
+ __u16 c_date;
+ __u16 a_date;
+ __u16 first_cluster_high;
+ __u16 w_time;
+ __u16 w_date;
+ __u16 first_cluster_low;
+ __u32 file_size;
+} __attribute__ ((packed));
+
+
+
+struct fat_long_name_entry {
+ __u8 id;
+ __u16 name1[5];
+ __u8 attr;
+ __u8 reserved;
+ __u8 checksum;
+ __u16 name2[6];
+ __u16 first_cluster;
+ __u16 name3[2];
+} __attribute__ ((packed));
+
+
+
+#endif /* fat_fs.h */