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)
15 #define MSDOS_DPB_BITS 4
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 MSDOS_MAX_EXTRA 3
25
26
27 #define ATTR_RO 1
28 #define ATTR_HIDDEN 2
29 #define ATTR_SYS 4
30 #define ATTR_VOLUME 8
31 #define ATTR_DIR 16
32 #define ATTR_ARCH 32
33
34 #define ATTR_NONE 0
35 #define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
36
37
38 #define DELETED_FLAG 0xe5
39 #define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG || \
40 *(const unsigned char *) (n) == FD_FILL_BYTE)
41
42 #define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
43
44
45 #define MSDOS_SB(s) (&((s)->u.msdos_sb))
46 #define MSDOS_I(i) (&((i)->u.msdos_i))
47
48 #define MSDOS_NAME 11
49 #define MSDOS_DOT ". "
50 #define MSDOS_DOTDOT ".. "
51
52 #define MSDOS_FAT12 4078
53
54
55
56
57
58
59
60
61 #define CF_LE_W(v) (v)
62 #define CF_LE_L(v) (v)
63 #define CT_LE_W(v) (v)
64 #define CT_LE_L(v) (v)
65
66
67 struct msdos_boot_sector {
68 __s8 ignored[3];
69 __s8 system_id[8];
70
71 __u8 sector_size[2];
72 __u8 cluster_size;
73 __u16 reserved;
74 __u8 fats;
75 __u8 dir_entries[2];
76 __u8 sectors[2];
77 __u8 media;
78 __u16 fat_length;
79 __u16 secs_track;
80 __u16 heads;
81 __u32 hidden;
82 __u32 total_sect;
83 };
84
85 struct msdos_dir_entry {
86 __s8 name[8],ext[3];
87 __u8 attr;
88 __u8 unused[10];
89 __u16 time,date,start;
90 __u32 size;
91 };
92
93 struct fat_cache {
94 kdev_t device;
95 int ino;
96 int file_cluster;
97 int disk_cluster;
98 struct fat_cache *next;
99 };
100
101
102
103 #define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
104 ((mib)->data_start & 1)))
105
106
107
108 #define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
109
110
111
112 #define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
113
114 #ifdef __KERNEL__
115
116
117
118 extern void fs_panic(struct super_block *s,const char *msg);
119 extern int is_binary(char conversion,char *extension);
120 extern void lock_creation(void);
121 extern void unlock_creation(void);
122 extern void lock_fat(struct super_block *sb);
123 extern void unlock_fat(struct super_block *sb);
124 extern int msdos_add_cluster(struct inode *inode);
125 extern int date_dos2unix(__u16 time, __u16 date);
126 extern void date_unix2dos(int unix_date,__u16 *time, __u16 *date);
127 extern int msdos_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
128 struct msdos_dir_entry **de);
129 extern int msdos_scan(struct inode *dir,const char *name,struct buffer_head **res_bh,
130 struct msdos_dir_entry **res_de,int *ino);
131 extern int msdos_parent_ino(struct inode *dir,int locked);
132 extern int msdos_subdirs(struct inode *dir);
133
134
135
136 extern int fat_access(struct super_block *sb,int nr,int new_value);
137 extern int msdos_smap(struct inode *inode,int sector);
138 extern int fat_free(struct inode *inode,int skip);
139 extern void cache_init(void);
140 void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
141 void cache_add(struct inode *inode,int f_clu,int d_clu);
142 void cache_inval_inode(struct inode *inode);
143 void cache_inval_dev(kdev_t device);
144 int get_cluster(struct inode *inode,int cluster);
145
146
147
148 extern int msdos_lookup(struct inode *dir,const char *name,int len,
149 struct inode **result);
150 extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
151 struct inode **result);
152 extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
153 extern int msdos_rmdir(struct inode *dir,const char *name,int len);
154 extern int msdos_unlink(struct inode *dir,const char *name,int len);
155 extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
156 extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
157 struct inode *new_dir,const char *new_name,int new_len);
158
159
160
161 extern void msdos_put_inode(struct inode *inode);
162 extern void msdos_put_super(struct super_block *sb);
163 extern struct super_block *msdos_read_super(struct super_block *s,
164 void *data,int);
165 extern void msdos_statfs(struct super_block *sb,struct statfs *buf, int);
166 extern int msdos_bmap(struct inode *inode,int block);
167 extern void msdos_read_inode(struct inode *inode);
168 extern void msdos_write_inode(struct inode *inode);
169 extern int msdos_notify_change(struct inode *,struct iattr *);
170
171
172
173 extern struct inode_operations msdos_dir_inode_operations;
174 extern int msdos_readdir (struct inode *inode, struct file *filp,
175 void *dirent, filldir_t);
176
177
178 extern struct inode_operations msdos_file_inode_operations;
179 extern struct inode_operations msdos_file_inode_operations_1024;
180 extern int msdos_file_read(struct inode *, struct file *, char *, int);
181 extern int msdos_file_write(struct inode *, struct file *, const char *, int);
182 extern struct inode_operations msdos_file_inode_operations_no_bmap;
183
184 extern void msdos_truncate(struct inode *inode);
185
186
187 extern int msdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
188
189 #endif
190
191 #endif