1#ifndef _UAPI_LINUX_MSDOS_FS_H
2#define _UAPI_LINUX_MSDOS_FS_H
3
4#include <linux/types.h>
5#include <linux/magic.h>
6#include <asm/byteorder.h>
7
8
9
10
11
12#define SECTOR_SIZE 512
13#define SECTOR_BITS 9
14#define MSDOS_DPB (MSDOS_DPS)
15#define MSDOS_DPB_BITS 4
16#define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
17#define MSDOS_DPS_BITS 4
18#define MSDOS_LONGNAME 256
19#define CF_LE_W(v) le16_to_cpu(v)
20#define CF_LE_L(v) le32_to_cpu(v)
21#define CT_LE_W(v) cpu_to_le16(v)
22#define CT_LE_L(v) cpu_to_le32(v)
23
24#define MSDOS_ROOT_INO 1
25#define MSDOS_FSINFO_INO 2
26
27#define MSDOS_DIR_BITS 5
28
29
30#define FAT_MAX_DIR_ENTRIES (65536)
31#define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
32
33#define ATTR_NONE 0
34#define ATTR_RO 1
35#define ATTR_HIDDEN 2
36#define ATTR_SYS 4
37#define ATTR_VOLUME 8
38#define ATTR_DIR 16
39#define ATTR_ARCH 32
40
41
42#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
43
44#define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
45
46#define CASE_LOWER_BASE 8
47#define CASE_LOWER_EXT 16
48
49#define DELETED_FLAG 0xe5
50#define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
51
52#define FAT_LFN_LEN 255
53#define MSDOS_NAME 11
54#define MSDOS_SLOTS 21
55#define MSDOS_DOT ". "
56#define MSDOS_DOTDOT ".. "
57
58#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
59 MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
60
61
62#define FAT_START_ENT 2
63
64
65#define MAX_FAT12 0xFF4
66#define MAX_FAT16 0xFFF4
67#define MAX_FAT32 0x0FFFFFF6
68#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
69 MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
70
71
72#define BAD_FAT12 0xFF7
73#define BAD_FAT16 0xFFF7
74#define BAD_FAT32 0x0FFFFFF7
75
76
77#define EOF_FAT12 0xFFF
78#define EOF_FAT16 0xFFFF
79#define EOF_FAT32 0x0FFFFFFF
80
81#define FAT_ENT_FREE (0)
82#define FAT_ENT_BAD (BAD_FAT32)
83#define FAT_ENT_EOF (EOF_FAT32)
84
85#define FAT_FSINFO_SIG1 0x41615252
86#define FAT_FSINFO_SIG2 0x61417272
87#define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
88 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
89
90#define FAT_STATE_DIRTY 0x01
91
92struct __fat_dirent {
93 long d_ino;
94 __kernel_off_t d_off;
95 unsigned short d_reclen;
96 char d_name[256];
97};
98
99
100
101
102#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct __fat_dirent[2])
103#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct __fat_dirent[2])
104
105#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
106#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
107
108#define FAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x13, __u32)
109
110struct fat_boot_sector {
111 __u8 ignored[3];
112 __u8 system_id[8];
113
114 __u8 sector_size[2];
115 __u8 sec_per_clus;
116 __le16 reserved;
117 __u8 fats;
118 __u8 dir_entries[2];
119 __u8 sectors[2];
120 __u8 media;
121 __le16 fat_length;
122 __le16 secs_track;
123 __le16 heads;
124 __le32 hidden;
125 __le32 total_sect;
126
127 union {
128 struct {
129
130 __u8 drive_number;
131 __u8 state;
132
133 __u8 signature;
134 __u8 vol_id[4];
135 __u8 vol_label[11];
136 __u8 fs_type[8];
137
138 } fat16;
139
140 struct {
141
142 __le32 length;
143 __le16 flags;
144
145 __u8 version[2];
146
147 __le32 root_cluster;
148
149 __le16 info_sector;
150 __le16 backup_boot;
151 __le16 reserved2[6];
152
153 __u8 drive_number;
154 __u8 state;
155
156 __u8 signature;
157 __u8 vol_id[4];
158 __u8 vol_label[11];
159 __u8 fs_type[8];
160
161 } fat32;
162 };
163};
164
165struct fat_boot_fsinfo {
166 __le32 signature1;
167 __le32 reserved1[120];
168 __le32 signature2;
169 __le32 free_clusters;
170 __le32 next_cluster;
171 __le32 reserved2[4];
172};
173
174struct msdos_dir_entry {
175 __u8 name[MSDOS_NAME];
176 __u8 attr;
177 __u8 lcase;
178 __u8 ctime_cs;
179 __le16 ctime;
180 __le16 cdate;
181 __le16 adate;
182 __le16 starthi;
183 __le16 time,date,start;
184 __le32 size;
185};
186
187
188struct msdos_dir_slot {
189 __u8 id;
190 __u8 name0_4[10];
191 __u8 attr;
192 __u8 reserved;
193 __u8 alias_checksum;
194 __u8 name5_10[12];
195 __le16 start;
196 __u8 name11_12[4];
197};
198
199#endif
200