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