root/include/linux/msdos_fs.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _LINUX_MSDOS_FS_H
   2 #define _LINUX_MSDOS_FS_H
   3 
   4 /*
   5  * The MS-DOS filesystem constants/structures
   6  */
   7 #include <linux/fs.h>
   8 #include <linux/stat.h>
   9 #include <linux/fd.h>
  10 
  11 #define MSDOS_ROOT_INO  1 /* == MINIX_ROOT_INO */
  12 #define SECTOR_SIZE     512 /* sector size (bytes) */
  13 #define SECTOR_BITS     9 /* log2(SECTOR_SIZE) */
  14 #define MSDOS_DPB       (MSDOS_DPS) /* dir entries per block */
  15 #define MSDOS_DPB_BITS  4 /* log2(MSDOS_DPB) */
  16 #define MSDOS_DPS       (SECTOR_SIZE/sizeof(struct msdos_dir_entry))
  17 #define MSDOS_DPS_BITS  4 /* log2(MSDOS_DPS) */
  18 #define MSDOS_DIR_BITS  5 /* log2(sizeof(struct msdos_dir_entry)) */
  19 
  20 #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
  21 
  22 #define FAT_CACHE    8 /* FAT cache size */
  23 
  24 #define MSDOS_MAX_EXTRA 3 /* tolerate up to that number of clusters which are
  25                              inaccessible because the FAT is too short */
  26 
  27 #define ATTR_RO      1  /* read-only */
  28 #define ATTR_HIDDEN  2  /* hidden */
  29 #define ATTR_SYS     4  /* system */
  30 #define ATTR_VOLUME  8  /* volume label */
  31 #define ATTR_DIR     16 /* directory */
  32 #define ATTR_ARCH    32 /* archived */
  33 
  34 #define ATTR_NONE    0 /* no attribute bits */
  35 #define ATTR_UNUSED  (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
  36         /* attribute bits that are copied "as is" */
  37 #define ATTR_EXT     (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
  38         /* bits that are used by the Windows 95/Windows NT extended FAT */
  39 
  40 #define CASE_LOWER_BASE 8       /* base is lower case */
  41 #define CASE_LOWER_EXT  16      /* extension is lower case */
  42 
  43 #define SCAN_ANY     0  /* either hidden or not */
  44 #define SCAN_HID     1  /* only hidden */
  45 #define SCAN_NOTHID  2  /* only not hidden */
  46 #define SCAN_NOTANY  3  /* test name, then use SCAN_HID or SCAN_NOTHID */
  47 
  48 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
  49 #define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG || \
  50   *(const unsigned char *) (n) == FD_FILL_BYTE)
  51 
  52 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
  53         /* valid file mode bits */
  54 
  55 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
  56 #define MSDOS_I(i) (&((i)->u.msdos_i))
  57 
  58 #define MSDOS_NAME 11 /* maximum name length */
  59 #define MSDOS_LONGNAME 256 /* maximum name length */
  60 #define MSDOS_SLOTS 21  /* max # of slots needed for short and long names */
  61 #define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
  62 #define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
  63 
  64 #define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */
  65 
  66 /*
  67  * Conversion from and to little-endian byte order. (no-op on i386/i486)
  68  *
  69  * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
  70  * BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
  71  */
  72 
  73 #define CF_LE_W(v) (v)
  74 #define CF_LE_L(v) (v)
  75 #define CT_LE_W(v) (v)
  76 #define CT_LE_L(v) (v)
  77 
  78 
  79 struct msdos_boot_sector {
  80         __s8    ignored[3];     /* Boot strap short or near jump */
  81         __s8    system_id[8];   /* Name - can be used to special case
  82                                    partition manager volumes */
  83         __u8    sector_size[2]; /* bytes per logical sector */
  84         __u8    cluster_size;   /* sectors/cluster */
  85         __u16   reserved;       /* reserved sectors */
  86         __u8    fats;           /* number of FATs */
  87         __u8    dir_entries[2]; /* root directory entries */
  88         __u8    sectors[2];     /* number of sectors */
  89         __u8    media;          /* media code (unused) */
  90         __u16   fat_length;     /* sectors/FAT */
  91         __u16   secs_track;     /* sectors per track */
  92         __u16   heads;          /* number of heads */
  93         __u32   hidden;         /* hidden sectors (unused) */
  94         __u32   total_sect;     /* number of sectors (if sectors == 0) */
  95 };
  96 
  97 struct msdos_dir_entry {
  98         __s8    name[8],ext[3]; /* name and extension */
  99         __u8    attr;           /* attribute bits */
 100         __u8    lcase;          /* Case for base and extension */
 101         __u8    ctime_ms;       /* Creation time, milliseconds */
 102         __u16   ctime;          /* Creation time */
 103         __u16   cdate;          /* Creation date */
 104         __u16   adate;          /* Last access date */
 105         __u8    unused[2];
 106         __u16   time,date,start;/* time, date and first cluster */
 107         __u32   size;           /* file size (in bytes) */
 108 };
 109 
 110 /* Up to 13 characters of the name */
 111 struct msdos_dir_slot {
 112         __u8    id;             /* sequence number for slot */
 113         __u8    name0_4[10];    /* first 5 characters in name */
 114         __u8    attr;           /* attribute byte */
 115         __u8    reserved;       /* always 0 */
 116         __u8    alias_checksum; /* checksum for 8.3 alias */
 117         __u8    name5_10[12];   /* 6 more characters in name */
 118         __u8    start[2];       /* starting cluster number */
 119         __u8    name11_12[4];   /* last 2 characters in name */
 120 };
 121 
 122 struct slot_info {
 123         int is_long;                   /* was the found entry long */
 124         int long_slots;                /* number of long slots in filename */
 125         int total_slots;               /* total slots (long and short) */
 126         loff_t longname_offset;        /* dir offset for longname start */
 127         loff_t shortname_offset;       /* dir offset for shortname start */
 128         int ino;                       /* ino for the file */
 129 };
 130 
 131 struct fat_cache {
 132         kdev_t device; /* device number. 0 means unused. */
 133         int ino; /* inode number. */
 134         int file_cluster; /* cluster number in the file. */
 135         int disk_cluster; /* cluster number on disk. */
 136         struct fat_cache *next; /* next cache entry */
 137 };
 138 
 139 /* Determine whether this FS has kB-aligned data. */
 140 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
 141     ((mib)->data_start & 1)))
 142 
 143 /* Convert attribute bits and a mask to the UNIX mode. */
 144 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
 145 
 146 /* Convert the UNIX mode to MS-DOS attribute bits. */
 147 #define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
 148 
 149 
 150 #ifdef __KERNEL__
 151 
 152 /* misc.c */
 153 extern int is_binary(char conversion,char *extension);
 154 extern void lock_fat(struct super_block *sb);
 155 extern void unlock_fat(struct super_block *sb);
 156 extern int fat_add_cluster(struct inode *inode);
 157 extern int date_dos2unix(__u16 time, __u16 date);
 158 extern void fat_fs_panic(struct super_block *s,const char *msg);
 159 extern void fat_lock_creation(void);
 160 extern void fat_unlock_creation(void);
 161 extern void fat_date_unix2dos(int unix_date,__u16 *time, __u16 *date);
 162 extern int fat_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
 163                          struct msdos_dir_entry **de);
 164 extern int fat_scan(struct inode *dir,const char *name,struct buffer_head **res_bh,
 165                     struct msdos_dir_entry **res_de,int *ino,char scantype);
 166 extern int fat_parent_ino(struct inode *dir,int locked);
 167 extern int fat_subdirs(struct inode *dir);
 168 
 169 /* fat.c */
 170 extern int fat_access(struct super_block *sb,int nr,int new_value);
 171 extern int fat_smap(struct inode *inode,int sector);
 172 extern int fat_free(struct inode *inode,int skip);
 173 void fat_cache_inval_inode(struct inode *inode);
 174 void fat_cache_inval_dev(kdev_t device);
 175 extern void cache_init(void);
 176 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
 177 void cache_add(struct inode *inode,int f_clu,int d_clu);
 178 int get_cluster(struct inode *inode,int cluster);
 179 
 180 /* inode.c */
 181 extern int fat_bmap(struct inode *inode,int block);
 182 extern int fat_notify_change(struct inode *,struct iattr *);
 183 extern void fat_put_inode(struct inode *inode);
 184 extern void fat_put_super(struct super_block *sb);
 185 extern void fat_read_inode(struct inode *inode, struct inode_operations *dir_ops);
 186 extern struct super_block *fat_read_super(struct super_block *s, void *data, int silent);
 187 extern void fat_statfs(struct super_block *sb,struct statfs *buf, int);
 188 extern void fat_write_inode(struct inode *inode);
 189 
 190 /* dir.c */
 191 extern struct file_operations fat_dir_operations;
 192 extern int fat_readdir(struct inode *inode, struct file *filp,
 193                        void *dirent, filldir_t);
 194 extern int fat_dir_ioctl(struct inode * inode, struct file * filp,
 195                          unsigned int cmd, unsigned long arg);
 196 
 197 /* file.c */
 198 extern struct inode_operations fat_file_inode_operations;
 199 extern struct inode_operations fat_file_inode_operations_1024;
 200 extern int fat_file_read(struct inode *, struct file *, char *, int);
 201 extern int fat_file_write(struct inode *, struct file *, const char *, int);
 202 extern void fat_truncate(struct inode *inode);
 203 
 204 /* mmap.c */
 205 extern int fat_mmap(struct inode *, struct file *, struct vm_area_struct *);
 206 
 207 
 208 /* vfat.c */
 209 extern int init_vfat_fs(void);
 210 
 211 
 212 /* msdosfs_syms.c */
 213 extern int init_msdos_fs(void);
 214 extern struct file_system_type msdos_fs_type;
 215 
 216 /* msdos.c */
 217 extern struct super_block *msdos_read_super(struct super_block *sb,void *data, int silent);
 218 
 219 /* msdos.c - these are for Umsdos */
 220 extern void msdos_read_inode(struct inode *inode);
 221 extern int msdos_lookup(struct inode *dir,const char *name,int len, 
 222                         struct inode **result);
 223 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
 224                         struct inode **result);
 225 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
 226 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
 227 extern int msdos_unlink(struct inode *dir,const char *name,int len);
 228 extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
 229 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
 230                         struct inode *new_dir,const char *new_name,int new_len);
 231 
 232 /* fatfs_syms.c */
 233 extern int init_fat_fs(void);
 234 
 235 #endif /* __KERNEL__ */
 236 
 237 #endif

/* [previous][next][first][last][top][bottom][index][help] */