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 
  38 #define SCAN_ANY     0  /* either hidden or not */
  39 #define SCAN_HID     1  /* only hidden */
  40 #define SCAN_NOTHID  2  /* only not hidden */
  41 #define SCAN_NOTANY  3  /* test name, then use SCAN_HID or SCAN_NOTHID */
  42 
  43 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
  44 #define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG || \
  45   *(const unsigned char *) (n) == FD_FILL_BYTE)
  46 
  47 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
  48         /* valid file mode bits */
  49 
  50 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
  51 #define MSDOS_I(i) (&((i)->u.msdos_i))
  52 
  53 #define MSDOS_NAME 11 /* maximum name length */
  54 #define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
  55 #define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
  56 
  57 #define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */
  58 
  59 /*
  60  * Conversion from and to little-endian byte order. (no-op on i386/i486)
  61  *
  62  * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
  63  * BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
  64  */
  65 
  66 #define CF_LE_W(v) (v)
  67 #define CF_LE_L(v) (v)
  68 #define CT_LE_W(v) (v)
  69 #define CT_LE_L(v) (v)
  70 
  71 
  72 struct msdos_boot_sector {
  73         __s8    ignored[3];     /* Boot strap short or near jump */
  74         __s8    system_id[8];   /* Name - can be used to special case
  75                                    partition manager volumes */
  76         __u8    sector_size[2]; /* bytes per logical sector */
  77         __u8    cluster_size;   /* sectors/cluster */
  78         __u16   reserved;       /* reserved sectors */
  79         __u8    fats;           /* number of FATs */
  80         __u8    dir_entries[2]; /* root directory entries */
  81         __u8    sectors[2];     /* number of sectors */
  82         __u8    media;          /* media code (unused) */
  83         __u16   fat_length;     /* sectors/FAT */
  84         __u16   secs_track;     /* sectors per track */
  85         __u16   heads;          /* number of heads */
  86         __u32   hidden;         /* hidden sectors (unused) */
  87         __u32   total_sect;     /* number of sectors (if sectors == 0) */
  88 };
  89 
  90 struct msdos_dir_entry {
  91         __s8    name[8],ext[3]; /* name and extension */
  92         __u8    attr;           /* attribute bits */
  93         __u8    unused[10];
  94         __u16   time,date,start;/* time, date and first cluster */
  95         __u32   size;           /* file size (in bytes) */
  96 };
  97 
  98 struct fat_cache {
  99         kdev_t device; /* device number. 0 means unused. */
 100         int ino; /* inode number. */
 101         int file_cluster; /* cluster number in the file. */
 102         int disk_cluster; /* cluster number on disk. */
 103         struct fat_cache *next; /* next cache entry */
 104 };
 105 
 106 /* Determine whether this FS has kB-aligned data. */
 107 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
 108     ((mib)->data_start & 1)))
 109 
 110 /* Convert attribute bits and a mask to the UNIX mode. */
 111 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
 112 
 113 /* Convert the UNIX mode to MS-DOS attribute bits. */
 114 #define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
 115 
 116 #ifdef __KERNEL__
 117 
 118 /* misc.c */
 119 
 120 extern void fs_panic(struct super_block *s,const char *msg);
 121 extern int is_binary(char conversion,char *extension);
 122 extern void lock_creation(void);
 123 extern void unlock_creation(void);
 124 extern void lock_fat(struct super_block *sb);
 125 extern void unlock_fat(struct super_block *sb);
 126 extern int msdos_add_cluster(struct inode *inode);
 127 extern int date_dos2unix(__u16 time, __u16 date);
 128 extern void date_unix2dos(int unix_date,__u16 *time, __u16 *date);
 129 extern int msdos_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
 130     struct msdos_dir_entry **de);
 131 extern int msdos_scan(struct inode *dir,const char *name,struct buffer_head **res_bh,
 132     struct msdos_dir_entry **res_de,int *ino,char scantype);
 133 extern int msdos_parent_ino(struct inode *dir,int locked);
 134 extern int msdos_subdirs(struct inode *dir);
 135 
 136 /* fat.c */
 137 
 138 extern int fat_access(struct super_block *sb,int nr,int new_value);
 139 extern int msdos_smap(struct inode *inode,int sector);
 140 extern int fat_free(struct inode *inode,int skip);
 141 extern void cache_init(void);
 142 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
 143 void cache_add(struct inode *inode,int f_clu,int d_clu);
 144 void cache_inval_inode(struct inode *inode);
 145 void cache_inval_dev(kdev_t device);
 146 int get_cluster(struct inode *inode,int cluster);
 147 
 148 /* namei.c */
 149 
 150 extern int msdos_lookup(struct inode *dir,const char *name,int len,
 151                         struct inode **result);
 152 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
 153         struct inode **result);
 154 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
 155 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
 156 extern int msdos_unlink(struct inode *dir,const char *name,int len);
 157 extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
 158 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
 159         struct inode *new_dir,const char *new_name,int new_len);
 160 
 161 /* inode.c */
 162 
 163 extern void msdos_put_inode(struct inode *inode);
 164 extern void msdos_put_super(struct super_block *sb);
 165 extern struct super_block *msdos_read_super(struct super_block *s,
 166                                             void *data,int);
 167 extern void msdos_statfs(struct super_block *sb,struct statfs *buf, int);
 168 extern int msdos_bmap(struct inode *inode,int block);
 169 extern void msdos_read_inode(struct inode *inode);
 170 extern void msdos_write_inode(struct inode *inode);
 171 extern int msdos_notify_change(struct inode *,struct iattr *);
 172 
 173 /* dir.c */
 174 
 175 extern struct inode_operations msdos_dir_inode_operations;
 176 extern int msdos_readdir (struct inode *inode, struct file *filp,
 177         void *dirent, filldir_t);
 178 /* file.c */
 179 
 180 extern struct inode_operations msdos_file_inode_operations;
 181 extern struct inode_operations msdos_file_inode_operations_1024;
 182 extern int msdos_file_read(struct inode *, struct file *, char *, int);
 183 extern int msdos_file_write(struct inode *, struct file *, const char *, int);
 184 extern struct inode_operations msdos_file_inode_operations_no_bmap;
 185 
 186 extern void msdos_truncate(struct inode *inode);
 187 
 188 /* mmap.c */
 189 extern int msdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
 190 
 191 #endif /* __KERNEL__ */
 192 
 193 #endif

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