msdos_fs.h
001: #ifndef _LINUX_MSDOS_FS_H
002: #define _LINUX_MSDOS_FS_H
003:
004: #include <linux/types.h>
005: #include <linux/magic.h>
006: #include <asm/byteorder.h>
007:
008:
009:
010:
011:
012: #define SECTOR_SIZE 512
013: #define SECTOR_BITS 9
014: #define MSDOS_DPB (MSDOS_DPS)
015: #define MSDOS_DPB_BITS 4
016: #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
017: #define MSDOS_DPS_BITS 4
018: #define MSDOS_LONGNAME 256
019: #define CF_LE_W(v) le16_to_cpu(v)
020: #define CF_LE_L(v) le32_to_cpu(v)
021: #define CT_LE_W(v) cpu_to_le16(v)
022: #define CT_LE_L(v) cpu_to_le32(v)
023:
024:
025: #define MSDOS_ROOT_INO 1
026: #define MSDOS_DIR_BITS 5
027:
028:
029: #define FAT_MAX_DIR_ENTRIES (65536)
030: #define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
031:
032: #define ATTR_NONE 0
033: #define ATTR_RO 1
034: #define ATTR_HIDDEN 2
035: #define ATTR_SYS 4
036: #define ATTR_VOLUME 8
037: #define ATTR_DIR 16
038: #define ATTR_ARCH 32
039:
040:
041: #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
042:
043: #define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
044:
045: #define CASE_LOWER_BASE 8
046: #define CASE_LOWER_EXT 16
047:
048: #define DELETED_FLAG 0xe5
049: #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
050:
051: #define FAT_LFN_LEN 255
052: #define MSDOS_NAME 11
053: #define MSDOS_SLOTS 21
054: #define MSDOS_DOT ". "
055: #define MSDOS_DOTDOT ".. "
056:
057: #define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
058: MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
059:
060:
061: #define FAT_START_ENT 2
062:
063:
064: #define MAX_FAT12 0xFF4
065: #define MAX_FAT16 0xFFF4
066: #define MAX_FAT32 0x0FFFFFF6
067: #define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
068: MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
069:
070:
071: #define BAD_FAT12 0xFF7
072: #define BAD_FAT16 0xFFF7
073: #define BAD_FAT32 0x0FFFFFF7
074:
075:
076: #define EOF_FAT12 0xFFF
077: #define EOF_FAT16 0xFFFF
078: #define EOF_FAT32 0x0FFFFFFF
079:
080: #define FAT_ENT_FREE (0)
081: #define FAT_ENT_BAD (BAD_FAT32)
082: #define FAT_ENT_EOF (EOF_FAT32)
083:
084: #define FAT_FSINFO_SIG1 0x41615252
085: #define FAT_FSINFO_SIG2 0x61417272
086: #define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
087: && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
088:
089: struct __fat_dirent {
090: long d_ino;
091: __kernel_off_t d_off;
092: unsigned short d_reclen;
093: char d_name[256];
094: };
095:
096:
097:
098:
099: #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct __fat_dirent[2])
100: #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct __fat_dirent[2])
101:
102: #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
103: #define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
104:
105: struct fat_boot_sector {
106: __u8 ignored[3];
107: __u8 system_id[8];
108:
109: __u8 sector_size[2];
110: __u8 sec_per_clus;
111: __le16 reserved;
112: __u8 fats;
113: __u8 dir_entries[2];
114: __u8 sectors[2];
115: __u8 media;
116: __le16 fat_length;
117: __le16 secs_track;
118: __le16 heads;
119: __le32 hidden;
120: __le32 total_sect;
121:
122:
123: __le32 fat32_length;
124: __le16 flags;
125: __u8 version[2];
126: __le32 root_cluster;
127: __le16 info_sector;
128: __le16 backup_boot;
129: __le16 reserved2[6];
130: };
131:
132: struct fat_boot_fsinfo {
133: __le32 signature1;
134: __le32 reserved1[120];
135: __le32 signature2;
136: __le32 free_clusters;
137: __le32 next_cluster;
138: __le32 reserved2[4];
139: };
140:
141: struct msdos_dir_entry {
142: __u8 name[MSDOS_NAME];
143: __u8 attr;
144: __u8 lcase;
145: __u8 ctime_cs;
146: __le16 ctime;
147: __le16 cdate;
148: __le16 adate;
149: __le16 starthi;
150: __le16 time,date,start;
151: __le32 size;
152: };
153:
154:
155: struct msdos_dir_slot {
156: __u8 id;
157: __u8 name0_4[10];
158: __u8 attr;
159: __u8 reserved;
160: __u8 alias_checksum;
161: __u8 name5_10[12];
162: __le16 start;
163: __u8 name11_12[4];
164: };
165:
166: #endif
167:
© Andrew Scott 2006 -
2025,
All Rights Reserved