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