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 _MSDOS_FS_H
   2 #define _MSDOS_FS_H
   3 
   4 /*
   5  * The MS-DOS filesystem constants/structures
   6  */
   7 
   8 #include <linux/fs.h>
   9 
  10 #define MSDOS_ROOT_INO  1 /* == MINIX_ROOT_INO */
  11 #define SECTOR_SIZE     512 /* sector size (bytes) */
  12 #define SECTOR_BITS     9 /* log2(SECTOR_SIZE) */
  13 #define MSDOS_DPB       (MSDOS_DPS*2) /* dir entries per block */
  14 #define MSDOS_DPB_BITS  5 /* log2(MSDOS_DPB) */
  15 #define MSDOS_DPS       (SECTOR_SIZE/sizeof(struct msdos_dir_entry))
  16 #define MSDOS_DPS_BITS  4 /* log2(MSDOS_DPS) */
  17 #define MSDOS_DIR_BITS  5 /* log2(sizeof(struct msdos_dir_entry)) */
  18 
  19 #define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
  20 
  21 #define FAT_CACHE    8 /* FAT cache size */
  22 
  23 #define ATTR_RO      1  /* read-only */
  24 #define ATTR_HIDDEN  2  /* hidden */
  25 #define ATTR_SYS     4  /* system */
  26 #define ATTR_VOLUME  8  /* volume label */
  27 #define ATTR_DIR     16 /* directory */
  28 #define ATTR_ARCH    32 /* archived */
  29 
  30 #define ATTR_NONE    0 /* no attribute bits */
  31 #define ATTR_UNUSED  (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
  32         /* attribute bits that are copied "as is" */
  33 
  34 #define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
  35 
  36 #define D_START    0 /* i_data[0]: first cluster or 0 */
  37 #define D_ATTRS    1 /* i_data[1]: unused attribute bits */
  38 #define D_BUSY     2 /* i_data[2]: file is either deleted but still open, or
  39                                    inconsistent (mkdir) */
  40 #define D_DEPEND   3 /* i_data[3]: pointer to inode that depends on the current
  41                                    inode */
  42 #define D_OLD      4 /* i_data[4]: pointer to the old inode this inode depends
  43                                    on */
  44 #define D_BINARY   5 /* i_data[5]: file contains non-text data */
  45 
  46 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
  47 
  48 #define MSDOS_NAME 11 /* maximum name length */
  49 #define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
  50 #define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
  51 
  52 #define MSDOS_FAT12 4086 /* maximum number of clusters in a 12 bit FAT */
  53 
  54 struct msdos_boot_sector {
  55         char ignored[13];
  56         unsigned char cluster_size; /* sectors/cluster */
  57         unsigned short reserved;    /* reserved sectors */
  58         unsigned char fats;         /* number of FATs */
  59         unsigned char dir_entries[2];/* root directory entries */
  60         unsigned char sectors[2];   /* number of sectors */
  61         unsigned char media;        /* media code (unused) */
  62         unsigned short fat_length;  /* sectors/FAT */
  63         unsigned short secs_track;  /* sectors per track (unused) */
  64         unsigned short heads;       /* number of heads (unused) */
  65         unsigned long hidden;       /* hidden sectors (unused) */
  66         unsigned long total_sect;   /* number of sectors (if sectors == 0) */
  67 };
  68 
  69 struct msdos_dir_entry {
  70         char name[8],ext[3]; /* name and extension */
  71         unsigned char attr;  /* attribute bits */
  72         char unused[10];
  73         unsigned short time,date,start; /* time, date and first cluster */
  74         unsigned long size;  /* file size (in bytes) */
  75 };
  76 
  77 struct fat_cache {
  78         int device; /* device number. 0 means unused. */
  79         int ino; /* inode number. */
  80         int file_cluster; /* cluster number in the file. */
  81         int disk_cluster; /* cluster number on disk. */
  82         struct fat_cache *next; /* next cache entry */
  83 };
  84 
  85 /* Determine whether this FS has kB-aligned data. */
  86 
  87 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
  88     ((mib)->data_start & 1)))
  89 
  90 /* Convert attribute bits and a mask to the UNIX mode. */
  91 
  92 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? 0444 : 0777))
  93 
  94 /* Convert the UNIX mode to MS-DOS attribute bits. */
  95 
  96 #define MSDOS_MKATTR(m) (!(m & 0200) ? ATTR_RO : ATTR_NONE)
  97 
  98 
  99 static inline struct buffer_head *msdos_sread(int dev,int sector,void **start)
     /* [previous][next][first][last][top][bottom][index][help] */
 100 {
 101         struct buffer_head *bh;
 102 
 103         if (!(bh = bread(dev,sector >> 1, 1024)))
 104                 return NULL;
 105         *start = bh->b_data+((sector & 1) << SECTOR_BITS);
 106         return bh;
 107 }
 108 
 109 
 110 /* misc.c */
 111 
 112 extern int is_binary(char conversion,char *extension);
 113 extern void lock_creation(void);
 114 extern void unlock_creation(void);
 115 extern int msdos_add_cluster(struct inode *inode);
 116 extern int date_dos2unix(unsigned short time,unsigned short date);
 117 extern void date_unix2dos(int unix_date,unsigned short *time,
 118     unsigned short *date);
 119 extern int msdos_get_entry(struct inode *dir,int *pos,struct buffer_head **bh,
 120     struct msdos_dir_entry **de);
 121 extern int msdos_scan(struct inode *dir,char *name,struct buffer_head **res_bh,
 122     struct msdos_dir_entry **res_de,int *ino);
 123 extern int msdos_parent_ino(struct inode *dir,int locked);
 124 
 125 /* fat.c */
 126 
 127 extern int fat_access(struct super_block *sb,int this,int new_value);
 128 extern int msdos_smap(struct inode *inode,int sector);
 129 extern int fat_free(struct inode *inode,int skip);
 130 extern void cache_init(void);
 131 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
 132 void cache_add(struct inode *inode,int f_clu,int d_clu);
 133 void cache_inval_inode(struct inode *inode);
 134 void cache_inval_dev(int device);
 135 int get_cluster(struct inode *inode,int cluster);
 136 
 137 /* namei.c */
 138 
 139 extern int msdos_lookup(struct inode *dir,const char *name,int len,
 140         struct inode **result);
 141 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
 142         struct inode **result);
 143 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
 144 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
 145 extern int msdos_unlink(struct inode *dir,const char *name,int len);
 146 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
 147         struct inode *new_dir,const char *new_name,int new_len);
 148 
 149 /* inode.c */
 150 
 151 extern void msdos_put_inode(struct inode *inode);
 152 extern void msdos_put_super(struct super_block *sb);
 153 extern struct super_block *msdos_read_super(struct super_block *s,void *data);
 154 extern void msdos_statfs(struct super_block *sb,struct statfs *buf);
 155 extern int msdos_bmap(struct inode *inode,int block);
 156 extern void msdos_read_inode(struct inode *inode);
 157 extern void msdos_write_inode(struct inode *inode);
 158 
 159 /* dir.c */
 160 
 161 extern struct file_operations msdos_dir_operations;
 162 extern struct inode_operations msdos_dir_inode_operations;
 163 
 164 /* file.c */
 165 
 166 extern struct file_operations msdos_file_operations;
 167 extern struct inode_operations msdos_file_inode_operations;
 168 extern struct inode_operations msdos_file_inode_operations_no_bmap;
 169 
 170 extern void msdos_truncate(struct inode *inode);
 171 
 172 #endif

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