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 
  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 MSDOS_SB(s) (&((s)->u.msdos_sb))
  37 #define MSDOS_I(i) (&((i)->u.msdos_i))
  38 
  39 #define MSDOS_NAME 11 /* maximum name length */
  40 #define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
  41 #define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
  42 
  43 #define MSDOS_FAT12 4086 /* maximum number of clusters in a 12 bit FAT */
  44 
  45 struct msdos_boot_sector {
  46         char ignored[13];
  47         unsigned char cluster_size; /* sectors/cluster */
  48         unsigned short reserved;    /* reserved sectors */
  49         unsigned char fats;         /* number of FATs */
  50         unsigned char dir_entries[2];/* root directory entries */
  51         unsigned char sectors[2];   /* number of sectors */
  52         unsigned char media;        /* media code (unused) */
  53         unsigned short fat_length;  /* sectors/FAT */
  54         unsigned short secs_track;  /* sectors per track (unused) */
  55         unsigned short heads;       /* number of heads (unused) */
  56         unsigned long hidden;       /* hidden sectors (unused) */
  57         unsigned long total_sect;   /* number of sectors (if sectors == 0) */
  58 };
  59 
  60 struct msdos_dir_entry {
  61         char name[8],ext[3]; /* name and extension */
  62         unsigned char attr;  /* attribute bits */
  63         char unused[10];
  64         unsigned short time,date,start; /* time, date and first cluster */
  65         unsigned long size;  /* file size (in bytes) */
  66 };
  67 
  68 struct fat_cache {
  69         int device; /* device number. 0 means unused. */
  70         int ino; /* inode number. */
  71         int file_cluster; /* cluster number in the file. */
  72         int disk_cluster; /* cluster number on disk. */
  73         struct fat_cache *next; /* next cache entry */
  74 };
  75 
  76 /* Determine whether this FS has kB-aligned data. */
  77 
  78 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
  79     ((mib)->data_start & 1)))
  80 
  81 /* Convert attribute bits and a mask to the UNIX mode. */
  82 
  83 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? 0444 : 0777))
  84 
  85 /* Convert the UNIX mode to MS-DOS attribute bits. */
  86 
  87 #define MSDOS_MKATTR(m) (!(m & 0200) ? ATTR_RO : ATTR_NONE)
  88 
  89 
  90 static inline struct buffer_head *msdos_sread(int dev,int sector,void **start)
     /* [previous][next][first][last][top][bottom][index][help] */
  91 {
  92         struct buffer_head *bh;
  93 
  94         if (!(bh = bread(dev,sector >> 1, 1024)))
  95                 return NULL;
  96         *start = bh->b_data+((sector & 1) << SECTOR_BITS);
  97         return bh;
  98 }
  99 
 100 
 101 /* misc.c */
 102 
 103 extern int is_binary(char conversion,char *extension);
 104 extern void lock_creation(void);
 105 extern void unlock_creation(void);
 106 extern void lock_fat(struct super_block *sb);
 107 extern void unlock_fat(struct super_block *sb);
 108 extern int msdos_add_cluster(struct inode *inode);
 109 extern int date_dos2unix(unsigned short time,unsigned short date);
 110 extern void date_unix2dos(int unix_date,unsigned short *time,
 111     unsigned short *date);
 112 extern int msdos_get_entry(struct inode *dir,int *pos,struct buffer_head **bh,
 113     struct msdos_dir_entry **de);
 114 extern int msdos_scan(struct inode *dir,char *name,struct buffer_head **res_bh,
 115     struct msdos_dir_entry **res_de,int *ino);
 116 extern int msdos_parent_ino(struct inode *dir,int locked);
 117 extern int msdos_subdirs(struct inode *dir);
 118 
 119 /* fat.c */
 120 
 121 extern int fat_access(struct super_block *sb,int this,int new_value);
 122 extern int msdos_smap(struct inode *inode,int sector);
 123 extern int fat_free(struct inode *inode,int skip);
 124 extern void cache_init(void);
 125 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
 126 void cache_add(struct inode *inode,int f_clu,int d_clu);
 127 void cache_inval_inode(struct inode *inode);
 128 void cache_inval_dev(int device);
 129 int get_cluster(struct inode *inode,int cluster);
 130 
 131 /* namei.c */
 132 
 133 extern int msdos_lookup(struct inode *dir,const char *name,int len,
 134         struct inode **result);
 135 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
 136         struct inode **result);
 137 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
 138 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
 139 extern int msdos_unlink(struct inode *dir,const char *name,int len);
 140 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
 141         struct inode *new_dir,const char *new_name,int new_len);
 142 
 143 /* inode.c */
 144 
 145 extern void msdos_put_inode(struct inode *inode);
 146 extern void msdos_put_super(struct super_block *sb);
 147 extern struct super_block *msdos_read_super(struct super_block *s,void *data);
 148 extern void msdos_statfs(struct super_block *sb,struct statfs *buf);
 149 extern int msdos_bmap(struct inode *inode,int block);
 150 extern void msdos_read_inode(struct inode *inode);
 151 extern void msdos_write_inode(struct inode *inode);
 152 
 153 /* dir.c */
 154 
 155 extern struct file_operations msdos_dir_operations;
 156 extern struct inode_operations msdos_dir_inode_operations;
 157 
 158 /* file.c */
 159 
 160 extern struct file_operations msdos_file_operations;
 161 extern struct inode_operations msdos_file_inode_operations;
 162 extern struct inode_operations msdos_file_inode_operations_no_bmap;
 163 
 164 extern void msdos_truncate(struct inode *inode);
 165 
 166 #endif

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