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

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