0001
0002 #ifndef _UAPI_LINUX_MSDOS_FS_H
0003 #define _UAPI_LINUX_MSDOS_FS_H
0004
0005 #include <linux/types.h>
0006 #include <linux/magic.h>
0007 #include <asm/byteorder.h>
0008
0009
0010
0011
0012
0013 #ifndef SECTOR_SIZE
0014 #define SECTOR_SIZE 512
0015 #endif
0016 #define SECTOR_BITS 9
0017 #define MSDOS_DPB (MSDOS_DPS)
0018 #define MSDOS_DPB_BITS 4
0019 #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
0020 #define MSDOS_DPS_BITS 4
0021 #define MSDOS_LONGNAME 256
0022 #define CF_LE_W(v) le16_to_cpu(v)
0023 #define CF_LE_L(v) le32_to_cpu(v)
0024 #define CT_LE_W(v) cpu_to_le16(v)
0025 #define CT_LE_L(v) cpu_to_le32(v)
0026
0027 #define MSDOS_ROOT_INO 1
0028 #define MSDOS_FSINFO_INO 2
0029
0030 #define MSDOS_DIR_BITS 5
0031
0032
0033 #define FAT_MAX_DIR_ENTRIES (65536)
0034 #define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
0035
0036 #define ATTR_NONE 0
0037 #define ATTR_RO 1
0038 #define ATTR_HIDDEN 2
0039 #define ATTR_SYS 4
0040 #define ATTR_VOLUME 8
0041 #define ATTR_DIR 16
0042 #define ATTR_ARCH 32
0043
0044
0045 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
0046
0047 #define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
0048
0049 #define CASE_LOWER_BASE 8
0050 #define CASE_LOWER_EXT 16
0051
0052 #define DELETED_FLAG 0xe5
0053 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
0054
0055 #define FAT_LFN_LEN 255
0056 #define MSDOS_NAME 11
0057 #define MSDOS_SLOTS 21
0058 #define MSDOS_DOT ". "
0059 #define MSDOS_DOTDOT ".. "
0060
0061
0062 #define FAT_START_ENT 2
0063
0064
0065 #define MAX_FAT12 0xFF4
0066 #define MAX_FAT16 0xFFF4
0067 #define MAX_FAT32 0x0FFFFFF6
0068
0069
0070 #define BAD_FAT12 0xFF7
0071 #define BAD_FAT16 0xFFF7
0072 #define BAD_FAT32 0x0FFFFFF7
0073
0074
0075 #define EOF_FAT12 0xFFF
0076 #define EOF_FAT16 0xFFFF
0077 #define EOF_FAT32 0x0FFFFFFF
0078
0079 #define FAT_ENT_FREE (0)
0080 #define FAT_ENT_BAD (BAD_FAT32)
0081 #define FAT_ENT_EOF (EOF_FAT32)
0082
0083 #define FAT_FSINFO_SIG1 0x41615252
0084 #define FAT_FSINFO_SIG2 0x61417272
0085 #define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1 \
0086 && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
0087
0088 #define FAT_STATE_DIRTY 0x01
0089
0090 struct __fat_dirent {
0091 long d_ino;
0092 __kernel_off_t d_off;
0093 unsigned short d_reclen;
0094 char d_name[256];
0095 };
0096
0097
0098
0099
0100 #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct __fat_dirent[2])
0101 #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct __fat_dirent[2])
0102
0103 #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
0104 #define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
0105
0106 #define FAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x13, __u32)
0107
0108 struct fat_boot_sector {
0109 __u8 ignored[3];
0110 __u8 system_id[8];
0111
0112 __u8 sector_size[2];
0113 __u8 sec_per_clus;
0114 __le16 reserved;
0115 __u8 fats;
0116 __u8 dir_entries[2];
0117 __u8 sectors[2];
0118 __u8 media;
0119 __le16 fat_length;
0120 __le16 secs_track;
0121 __le16 heads;
0122 __le32 hidden;
0123 __le32 total_sect;
0124
0125 union {
0126 struct {
0127
0128 __u8 drive_number;
0129 __u8 state;
0130
0131 __u8 signature;
0132 __u8 vol_id[4];
0133 __u8 vol_label[MSDOS_NAME];
0134 __u8 fs_type[8];
0135
0136 } fat16;
0137
0138 struct {
0139
0140 __le32 length;
0141 __le16 flags;
0142
0143 __u8 version[2];
0144
0145 __le32 root_cluster;
0146
0147 __le16 info_sector;
0148 __le16 backup_boot;
0149 __le16 reserved2[6];
0150
0151 __u8 drive_number;
0152 __u8 state;
0153
0154 __u8 signature;
0155 __u8 vol_id[4];
0156 __u8 vol_label[MSDOS_NAME];
0157 __u8 fs_type[8];
0158
0159 } fat32;
0160 };
0161 };
0162
0163 struct fat_boot_fsinfo {
0164 __le32 signature1;
0165 __le32 reserved1[120];
0166 __le32 signature2;
0167 __le32 free_clusters;
0168 __le32 next_cluster;
0169 __le32 reserved2[4];
0170 };
0171
0172 struct msdos_dir_entry {
0173 __u8 name[MSDOS_NAME];
0174 __u8 attr;
0175 __u8 lcase;
0176 __u8 ctime_cs;
0177 __le16 ctime;
0178 __le16 cdate;
0179 __le16 adate;
0180 __le16 starthi;
0181 __le16 time,date,start;
0182 __le32 size;
0183 };
0184
0185
0186 struct msdos_dir_slot {
0187 __u8 id;
0188 __u8 name0_4[10];
0189 __u8 attr;
0190 __u8 reserved;
0191 __u8 alias_checksum;
0192 __u8 name5_10[12];
0193 __le16 start;
0194 __u8 name11_12[4];
0195 };
0196
0197 #endif