This source file includes following definitions.
- msdos_sread
1 #ifndef _LINUX_MSDOS_FS_H
2 #define _LINUX_MSDOS_FS_H
3
4
5
6
7 #include <linux/fs.h>
8 #include <linux/stat.h>
9 #include <linux/fd.h>
10
11 #define MSDOS_ROOT_INO 1
12 #define SECTOR_SIZE 512
13 #define SECTOR_BITS 9
14 #define MSDOS_DPB (MSDOS_DPS*2)
15 #define MSDOS_DPB_BITS 5
16 #define MSDOS_DPS (SECTOR_SIZE/sizeof(struct msdos_dir_entry))
17 #define MSDOS_DPS_BITS 4
18 #define MSDOS_DIR_BITS 5
19
20 #define MSDOS_SUPER_MAGIC 0x4d44
21
22 #define FAT_CACHE 8
23
24 #define ATTR_RO 1
25 #define ATTR_HIDDEN 2
26 #define ATTR_SYS 4
27 #define ATTR_VOLUME 8
28 #define ATTR_DIR 16
29 #define ATTR_ARCH 32
30
31 #define ATTR_NONE 0
32 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
33
34
35 #define DELETED_FLAG 0xe5
36 #define IS_FREE(n) (!*(n) || *(unsigned char *) (n) == DELETED_FLAG || \
37 *(unsigned char *) (n) == FD_FILL_BYTE)
38
39 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
40
41
42 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
43 #define MSDOS_I(i) (&((i)->u.msdos_i))
44
45 #define MSDOS_NAME 11
46 #define MSDOS_DOT ". "
47 #define MSDOS_DOTDOT ".. "
48
49 #define MSDOS_FAT12 4078
50
51
52
53
54
55
56
57
58 #define CF_LE_W(v) (v)
59 #define CF_LE_L(v) (v)
60 #define CT_LE_W(v) (v)
61 #define CT_LE_L(v) (v)
62
63
64 struct msdos_boot_sector {
65 char ignored[3];
66 char system_id[8];
67
68 unsigned char sector_size[2];
69 unsigned char cluster_size;
70 unsigned short reserved;
71 unsigned char fats;
72 unsigned char dir_entries[2];
73 unsigned char sectors[2];
74 unsigned char media;
75 unsigned short fat_length;
76 unsigned short secs_track;
77 unsigned short heads;
78 unsigned long hidden;
79 unsigned long total_sect;
80 };
81
82 struct msdos_dir_entry {
83 char name[8],ext[3];
84 unsigned char attr;
85 char unused[10];
86 unsigned short time,date,start;
87 unsigned long size;
88 };
89
90 struct fat_cache {
91 int device;
92 int ino;
93 int file_cluster;
94 int disk_cluster;
95 struct fat_cache *next;
96 };
97
98
99
100 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
101 ((mib)->data_start & 1)))
102
103
104
105 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
106
107
108
109 #define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
110
111 #ifdef __KERNEL__
112
113 static inline struct buffer_head *msdos_sread(int dev,int sector,void **start)
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
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,loff_t *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
144
145 extern int fat_access(struct super_block *sb,int nr,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
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_unlink_umsdos(struct inode *dir,const char *name,int len);
165 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
166 struct inode *new_dir,const char *new_name,int new_len);
167
168
169
170 extern void msdos_put_inode(struct inode *inode);
171 extern void msdos_put_super(struct super_block *sb);
172 extern struct super_block *msdos_read_super(struct super_block *s,
173 void *data,int);
174 extern void msdos_statfs(struct super_block *sb,struct statfs *buf);
175 extern int msdos_bmap(struct inode *inode,int block);
176 extern void msdos_read_inode(struct inode *inode);
177 extern void msdos_write_inode(struct inode *inode);
178 extern int msdos_notify_change(int flags,struct inode *inode);
179
180
181
182 extern struct inode_operations msdos_dir_inode_operations;
183 extern int msdos_readdir (struct inode *inode, struct file *filp,
184 struct dirent *dirent, int count);
185
186
187 extern struct inode_operations msdos_file_inode_operations;
188 extern int msdos_file_read(struct inode *, struct file *, char *, int);
189 extern int msdos_file_write(struct inode *, struct file *, char *, int);
190 extern struct inode_operations msdos_file_inode_operations_no_bmap;
191
192 extern void msdos_truncate(struct inode *inode);
193
194
195 extern int msdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
196
197 #endif
198
199 #endif