summaryrefslogtreecommitdiff
path: root/include/fat.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/fat.h')
-rw-r--r--include/fat.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/include/fat.h b/include/fat.h
index 2c951e7d79..a099f531ca 100644
--- a/include/fat.h
+++ b/include/fat.h
@@ -29,6 +29,13 @@
#define FAT16BUFSIZE (FATBUFSIZE/2)
#define FAT32BUFSIZE (FATBUFSIZE/4)
+#define SECTOR_SIZE 512
+#define BYTE_PER_SEC 512
+#define RESERVED_CNT 32
+#define DOS_PART_TBL_OFFSET 0x1be
+#define DOS_PART_MAGIC_OFFSET 0x1fe
+#define DOS_FS_TYPE_OFFSET 0x36
+#define DOS_FS32_TYPE_OFFSET 0x52
/* Filesystem identifiers */
#define FAT12_SIGN "FAT12 "
@@ -87,6 +94,88 @@
#define CHECK_CLUST(x, fatsize) ((x) <= 1 || \
(x) >= ((fatsize) != 32 ? 0xfff0 : 0xffffff0))
+#define mk1(p, x) \
+ (p) = (__u8)(x)
+
+#define mk2(p, x) \
+ (p)[0] = (__u8)(x), \
+ (p)[1] = (__u8)((x) >> 010)
+
+#define mk4(p, x) \
+ (p)[0] = (__u8)(x), \
+ (p)[1] = (__u8)((x) >> 010), \
+ (p)[2] = (__u8)((x) >> 020), \
+ (p)[3] = (__u8)((x) >> 030)
+
+struct bs {
+ __u8 jmp[3]; /* bootstrap entry point */
+ __u8 oem[9]; /* OEM name and version */
+};
+
+struct bsbpb {
+ __u8 bps[2]; /* bytes per sector */
+ __u8 spc; /* sectors per cluster */
+ __u8 res[2]; /* reserved sectors */
+ __u8 nft; /* number of FATs */
+ __u8 rde[2]; /* root directory entries */
+ __u8 sec[2]; /* total sectors */
+ __u8 mid; /* media descriptor */
+ __u8 spf[2]; /* sectors per FAT */
+ __u8 spt[2]; /* sectors per track */
+ __u8 hds[2]; /* drive heads */
+ __u8 hid[4]; /* hidden sectors */
+ __u8 bsec[6]; /* big total sectors */
+};
+
+/* For FAT32 */
+struct bsxbpb {
+ __u8 bspf[4]; /* big sectors per FAT */
+ __u8 xflg[2]; /* FAT control flags */
+ __u8 vers[2]; /* file system version */
+ __u8 rdcl[4]; /* root directory start cluster */
+ __u8 infs[2]; /* file system info sector */
+ __u8 bkbs[2]; /* backup boot sector */
+ __u8 rsvd[12]; /* reserved */
+};
+
+struct bsx {
+ __u8 drv; /* drive number */
+ __u8 rsvd; /* reserved */
+ __u8 sig; /* extended boot signature */
+ __u8 volid[4]; /* volume ID number */
+ __u8 label[11]; /* volume label */
+ __u8 type[8]; /* file system type */
+};
+
+struct de {
+ __u8 namext[11]; /* name and extension */
+ __u8 attr; /* attributes */
+ __u8 rsvd[10]; /* reserved */
+ __u8 time[2]; /* creation time */
+ __u8 date[2]; /* creation date */
+ __u8 clus[2]; /* starting cluster */
+ __u8 size[4]; /* size */
+};
+
+struct bpb {
+ __u32 bps; /* bytes per sector */
+ __u32 spc; /* sectors per cluster */
+ __u32 res; /* reserved sectors */
+ __u32 nft; /* number of FATs */
+ __u32 rde; /* root directory entries */
+ __u32 sec; /* total sectors */
+ __u32 mid; /* media descriptor */
+ __u32 spf; /* sectors per FAT */
+ __u32 spt; /* sectors per track */
+ __u32 hds; /* drive heads */
+ __u32 hid; /* hidden sectors */
+ __u32 bsec; /* big total sectors */
+ __u32 bspf; /* big sectors per FAT */
+ __u32 rdcl; /* root directory start cluster */
+ __u32 infs; /* file system info sector */
+ __u32 bkbs; /* backup boot sector */
+};
+
typedef struct boot_sector {
__u8 ignored[3]; /* Bootstrap code */
char system_id[8]; /* Name of fs */