root/include/linux/msdos_fs.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. msdos_sread

   1 #ifndef _LINUX_MSDOS_FS_H
   2 #define _LINUX_MSDOS_FS_H
   3 
   4 /*
   5  * The MS-DOS filesystem constants/structures
   6  */
   7 
   8 #include <linux/fs.h>
   9 #include <linux/stat.h>
  10 #include <linux/fd.h>
  11 
  12 #define MSDOS_ROOT_INO  1 /* == MINIX_ROOT_INO */
  13 #define SECTOR_SIZE     512 /* sector size (bytes) */
  14 #define SECTOR_BITS     9 /* log2(SECTOR_SIZE) */
  15 #define MSDOS_DPB       (MSDOS_DPS*2) /* dir entries per block */
  16 #define MSDOS_DPB_BITS  5 /* log2(MSDOS_DPB) */
  17 #define MSDOS_DPS       (SECTOR_SIZE/sizeof(struct msdos_dir_entry))
  18 #define MSDOS_DPS_BITS  4 /* log2(MSDOS_DPS) */
  19 #define MSDOS_DIR_BITS  5 /* log2(sizeof(struct msdos_dir_entry)) */
  20 
  21 #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
  22 
  23 #define FAT_CACHE    8 /* FAT cache size */
  24 
  25 #define ATTR_RO      1  /* read-only */
  26 #define ATTR_HIDDEN  2  /* hidden */
  27 #define ATTR_SYS     4  /* system */
  28 #define ATTR_VOLUME  8  /* volume label */
  29 #define ATTR_DIR     16 /* directory */
  30 #define ATTR_ARCH    32 /* archived */
  31 
  32 #define ATTR_NONE    0 /* no attribute bits */
  33 #define ATTR_UNUSED  (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
  34         /* attribute bits that are copied "as is" */
  35 
  36 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
  37 #define IS_FREE(n) (!*(n) || *(unsigned char *) (n) == DELETED_FLAG || \
  38   *(unsigned char *) (n) == FD_FILL_BYTE)
  39 
  40 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
  41         /* valid file mode bits */
  42 
  43 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
  44 #define MSDOS_I(i) (&((i)->u.msdos_i))
  45 
  46 #define MSDOS_NAME 11 /* maximum name length */
  47 #define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
  48 #define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
  49 
  50 #define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */
  51 
  52 /*
  53  * Conversion from and to little-endian byte order. (no-op on i386/i486)
  54  *
  55  * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian, BE = big-
  56  * endian, c: W = word (16 bits), L = longword (32 bits)
  57  */
  58 
  59 #define CF_LE_W(v) (v)
  60 #define CF_LE_L(v) (v)
  61 #define CT_LE_W(v) (v)
  62 #define CT_LE_L(v) (v)
  63 
  64 
  65 struct msdos_boot_sector {
  66         char ignored[3];            /* Boot strap short or near jump */
  67         char system_id[8];          /* Name - can be used to special case
  68                                        partition manager volumes */
  69         unsigned char sector_size[2];/* bytes per logical sector */
  70         unsigned char cluster_size; /* sectors/cluster */
  71         unsigned short reserved;    /* reserved sectors */
  72         unsigned char fats;         /* number of FATs */
  73         unsigned char dir_entries[2];/* root directory entries */
  74         unsigned char sectors[2];   /* number of sectors */
  75         unsigned char media;        /* media code (unused) */
  76         unsigned short fat_length;  /* sectors/FAT */
  77         unsigned short secs_track;  /* sectors per track */
  78         unsigned short heads;       /* number of heads */
  79         unsigned long hidden;       /* hidden sectors (unused) */
  80         unsigned long total_sect;   /* number of sectors (if sectors == 0) */
  81 };
  82 
  83 struct msdos_dir_entry {
  84         char name[8],ext[3]; /* name and extension */
  85         unsigned char attr;  /* attribute bits */
  86         char unused[10];
  87         unsigned short time,date,start; /* time, date and first cluster */
  88         unsigned long size;  /* file size (in bytes) */
  89 };
  90 
  91 struct fat_cache {
  92         int device; /* device number. 0 means unused. */
  93         int ino; /* inode number. */
  94         int file_cluster; /* cluster number in the file. */
  95         int disk_cluster; /* cluster number on disk. */
  96         struct fat_cache *next; /* next cache entry */
  97 };
  98 
  99 /* Determine whether this FS has kB-aligned data. */
 100 
 101 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
 102     ((mib)->data_start & 1)))
 103 
 104 /* Convert attribute bits and a mask to the UNIX mode. */
 105 
 106 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? 0555 : 0777))
 107 
 108 /* Convert the UNIX mode to MS-DOS attribute bits. */
 109 
 110 #define MSDOS_MKATTR(m) ((m & 0200) ? ATTR_NONE : ATTR_RO)
 111 
 112 
 113 static inline struct buffer_head *msdos_sread(int dev,int sector,void **start)
     /* [previous][next][first][last][top][bottom][index][help] */
 114 {
 115         struct buffer_head *bh;
 116 
 117         if (!(bh = bread(dev,sector >> 1, 1024)))
 118                 return NULL;
 119         *start = bh->b_data+((sector & 1) << SECTOR_BITS);
 120         return bh;
 121 }
 122 
 123 
 124 /* misc.c */
 125 
 126 extern void fs_panic(struct super_block *s,char *msg);
 127 extern int is_binary(char conversion,char *extension);
 128 extern void lock_creation(void);
 129 extern void unlock_creation(void);
 130 extern void lock_fat(struct super_block *sb);
 131 extern void unlock_fat(struct super_block *sb);
 132 extern int msdos_add_cluster(struct inode *inode);
 133 extern int date_dos2unix(unsigned short time,unsigned short date);
 134 extern void date_unix2dos(int unix_date,unsigned short *time,
 135     unsigned short *date);
 136 extern int msdos_get_entry(struct inode *dir,int *pos,struct buffer_head **bh,
 137     struct msdos_dir_entry **de);
 138 extern int msdos_scan(struct inode *dir,char *name,struct buffer_head **res_bh,
 139     struct msdos_dir_entry **res_de,int *ino);
 140 extern int msdos_parent_ino(struct inode *dir,int locked);
 141 extern int msdos_subdirs(struct inode *dir);
 142 
 143 /* fat.c */
 144 
 145 extern int fat_access(struct super_block *sb,int this,int new_value);
 146 extern int msdos_smap(struct inode *inode,int sector);
 147 extern int fat_free(struct inode *inode,int skip);
 148 extern void cache_init(void);
 149 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
 150 void cache_add(struct inode *inode,int f_clu,int d_clu);
 151 void cache_inval_inode(struct inode *inode);
 152 void cache_inval_dev(int device);
 153 int get_cluster(struct inode *inode,int cluster);
 154 
 155 /* namei.c */
 156 
 157 extern int msdos_lookup(struct inode *dir,const char *name,int len,
 158         struct inode **result);
 159 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
 160         struct inode **result);
 161 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
 162 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
 163 extern int msdos_unlink(struct inode *dir,const char *name,int len);
 164 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
 165         struct inode *new_dir,const char *new_name,int new_len);
 166 
 167 /* inode.c */
 168 
 169 extern void msdos_put_inode(struct inode *inode);
 170 extern void msdos_put_super(struct super_block *sb);
 171 extern struct super_block *msdos_read_super(struct super_block *s,
 172                                             void *data,int);
 173 extern void msdos_statfs(struct super_block *sb,struct statfs *buf);
 174 extern int msdos_bmap(struct inode *inode,int block);
 175 extern void msdos_read_inode(struct inode *inode);
 176 extern void msdos_write_inode(struct inode *inode);
 177 extern int msdos_notify_change(int flags,struct inode *inode);
 178 
 179 /* dir.c */
 180 
 181 extern struct file_operations msdos_dir_operations;
 182 extern struct inode_operations msdos_dir_inode_operations;
 183 
 184 /* file.c */
 185 
 186 extern struct file_operations msdos_file_operations;
 187 extern struct inode_operations msdos_file_inode_operations;
 188 extern struct inode_operations msdos_file_inode_operations_no_bmap;
 189 
 190 extern void msdos_truncate(struct inode *inode);
 191 
 192 #endif

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