Home | History | Annotate | Download | only in linux
      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  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef _LINUX_MSDOS_FS_H
     13 #define _LINUX_MSDOS_FS_H
     14 
     15 #include <linux/magic.h>
     16 
     17 #include <asm/byteorder.h>
     18 
     19 #define SECTOR_SIZE 512
     20 #define SECTOR_BITS 9
     21 #define MSDOS_DPB (MSDOS_DPS)
     22 #define MSDOS_DPB_BITS 4
     23 #define MSDOS_DPS (SECTOR_SIZE / sizeof(struct msdos_dir_entry))
     24 #define MSDOS_DPS_BITS 4
     25 #define CF_LE_W(v) le16_to_cpu(v)
     26 #define CF_LE_L(v) le32_to_cpu(v)
     27 #define CT_LE_W(v) cpu_to_le16(v)
     28 #define CT_LE_L(v) cpu_to_le32(v)
     29 
     30 #define MSDOS_ROOT_INO 1
     31 #define MSDOS_DIR_BITS 5
     32 
     33 #define FAT_MAX_DIR_ENTRIES (65536)
     34 #define FAT_MAX_DIR_SIZE (FAT_MAX_DIR_ENTRIES << MSDOS_DIR_BITS)
     35 
     36 #define ATTR_NONE 0
     37 #define ATTR_RO 1
     38 #define ATTR_HIDDEN 2
     39 #define ATTR_SYS 4
     40 #define ATTR_VOLUME 8
     41 #define ATTR_DIR 16
     42 #define ATTR_ARCH 32
     43 
     44 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
     45 
     46 #define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
     47 
     48 #define CASE_LOWER_BASE 8
     49 #define CASE_LOWER_EXT 16
     50 
     51 #define DELETED_FLAG 0xe5
     52 #define IS_FREE(n) (!*(n) || *(n) == DELETED_FLAG)
     53 
     54 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
     55 
     56 #define MSDOS_MKMODE(a, m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
     57 
     58 #define MSDOS_NAME 11
     59 #define MSDOS_LONGNAME 256
     60 #define MSDOS_SLOTS 21
     61 #define MSDOS_DOT ".          "
     62 #define MSDOS_DOTDOT "..         "
     63 
     64 #define FAT_VALID_MEDIA(x) ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
     65 #define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 :   MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
     66 
     67 #define FAT_START_ENT 2
     68 
     69 #define MAX_FAT12 0xFF4
     70 #define MAX_FAT16 0xFFF4
     71 #define MAX_FAT32 0x0FFFFFF6
     72 #define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 :   MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
     73 
     74 #define BAD_FAT12 0xFF7
     75 #define BAD_FAT16 0xFFF7
     76 #define BAD_FAT32 0x0FFFFFF7
     77 
     78 #define EOF_FAT12 0xFFF
     79 #define EOF_FAT16 0xFFFF
     80 #define EOF_FAT32 0x0FFFFFFF
     81 
     82 #define FAT_ENT_FREE (0)
     83 #define FAT_ENT_BAD (BAD_FAT32)
     84 #define FAT_ENT_EOF (EOF_FAT32)
     85 
     86 #define FAT_FSINFO_SIG1 0x41615252
     87 #define FAT_FSINFO_SIG2 0x61417272
     88 #define IS_FSINFO(x) (le32_to_cpu((x)->signature1) == FAT_FSINFO_SIG1   && le32_to_cpu((x)->signature2) == FAT_FSINFO_SIG2)
     89 
     90 #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])
     91 #define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2])
     92 
     93 #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
     94 #define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)
     95 #define VFAT_IOCTL_GET_VOLUME_ID _IOR('r', 0x12, __u32)
     96 
     97 #define VFAT_SFN_DISPLAY_LOWER 0x0001
     98 #define VFAT_SFN_DISPLAY_WIN95 0x0002
     99 #define VFAT_SFN_DISPLAY_WINNT 0x0004
    100 #define VFAT_SFN_CREATE_WIN95 0x0100
    101 #define VFAT_SFN_CREATE_WINNT 0x0200
    102 
    103 struct fat_boot_sector {
    104  __u8 ignored[3];
    105  __u8 system_id[8];
    106  __u8 sector_size[2];
    107  __u8 sec_per_clus;
    108  __le16 reserved;
    109  __u8 fats;
    110  __u8 dir_entries[2];
    111  __u8 sectors[2];
    112  __u8 media;
    113  __le16 fat_length;
    114  __le16 secs_track;
    115  __le16 heads;
    116  __le32 hidden;
    117  __le32 total_sect;
    118 
    119  __le32 fat32_length;
    120  __le16 flags;
    121  __u8 version[2];
    122  __le32 root_cluster;
    123  __le16 info_sector;
    124  __le16 backup_boot;
    125  __le16 reserved2[6];
    126 };
    127 
    128 struct fat_boot_fsinfo {
    129  __le32 signature1;
    130  __le32 reserved1[120];
    131  __le32 signature2;
    132  __le32 free_clusters;
    133  __le32 next_cluster;
    134  __le32 reserved2[4];
    135 };
    136 
    137 struct fat_boot_bsx {
    138  __u8 drive;
    139  __u8 reserved1;
    140  __u8 signature;
    141  __u8 vol_id[4];
    142  __u8 vol_label[11];
    143  __u8 type[8];
    144 };
    145 #define FAT16_BSX_OFFSET 36
    146 #define FAT32_BSX_OFFSET 64
    147 
    148 struct msdos_dir_entry {
    149  __u8 name[MSDOS_NAME];
    150  __u8 attr;
    151  __u8 lcase;
    152  __u8 ctime_cs;
    153  __le16 ctime;
    154  __le16 cdate;
    155  __le16 adate;
    156  __le16 starthi;
    157  __le16 time,date,start;
    158  __le32 size;
    159 };
    160 
    161 struct msdos_dir_slot {
    162  __u8 id;
    163  __u8 name0_4[10];
    164  __u8 attr;
    165  __u8 reserved;
    166  __u8 alias_checksum;
    167  __u8 name5_10[12];
    168  __le16 start;
    169  __u8 name11_12[4];
    170 };
    171 
    172 struct fat_slot_info {
    173  loff_t i_pos;
    174  loff_t slot_off;
    175  int nr_slots;
    176  struct msdos_dir_entry *de;
    177  struct buffer_head *bh;
    178 };
    179 
    180 #endif
    181