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