OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [msdos_fs.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
#ifndef _LINUX_MSDOS_FS_H
2
#define _LINUX_MSDOS_FS_H
3
 
4
/*
5
 * The MS-DOS filesystem constants/structures
6
 */
7
#include <linux/fs.h>
8
#include <linux/stat.h>
9
#include <linux/fd.h>
10
#include <asm/byteorder.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) /* dir entries per block */
16
#define MSDOS_DPB_BITS  4 /* 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 MSDOS_MAX_EXTRA 3 /* tolerate up to that number of clusters which are
26
                             inaccessible because the FAT is too short */
27
 
28
#define ATTR_RO      1  /* read-only */
29
#define ATTR_HIDDEN  2  /* hidden */
30
#define ATTR_SYS     4  /* system */
31
#define ATTR_VOLUME  8  /* volume label */
32
#define ATTR_DIR     16 /* directory */
33
#define ATTR_ARCH    32 /* archived */
34
 
35
#define ATTR_NONE    0 /* no attribute bits */
36
#define ATTR_UNUSED  (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
37
        /* attribute bits that are copied "as is" */
38
#define ATTR_EXT     (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
39
        /* bits that are used by the Windows 95/Windows NT extended FAT */
40
 
41
#define ATTR_DIR_READ_BOTH 512 /* read both short and long names from the
42
                                * vfat filesystem.  This is used by Samba
43
                                * to export the vfat filesystem with correct
44
                                * shortnames. */
45
#define ATTR_DIR_READ_SHORT 1024
46
 
47
#define CASE_LOWER_BASE 8       /* base is lower case */
48
#define CASE_LOWER_EXT  16      /* extension is lower case */
49
 
50
#define SCAN_ANY     0  /* either hidden or not */
51
#define SCAN_HID     1  /* only hidden */
52
#define SCAN_NOTHID  2  /* only not hidden */
53
#define SCAN_NOTANY  3  /* test name, then use SCAN_HID or SCAN_NOTHID */
54
 
55
#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
56
#define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG || \
57
  *(const unsigned char *) (n) == FD_FILL_BYTE)
58
 
59
#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
60
        /* valid file mode bits */
61
 
62
#define MSDOS_SB(s) (&((s)->u.msdos_sb))
63
#define MSDOS_I(i) (&((i)->u.msdos_i))
64
 
65
#define MSDOS_NAME 11 /* maximum name length */
66
#define MSDOS_LONGNAME 256 /* maximum name length */
67
#define MSDOS_SLOTS 21  /* max # of slots needed for short and long names */
68
#define MSDOS_DOT    ".          " /* ".", padded to MSDOS_NAME chars */
69
#define MSDOS_DOTDOT "..         " /* "..", padded to MSDOS_NAME chars */
70
 
71
#define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */
72
 
73
#define EOF_FAT12 0xFF8         /* standard EOF */
74
#define EOF_FAT16 0xFFF8
75
#define EOF_FAT32 0xFFFFFF8
76
 
77
/*
78
 * Inode flags
79
 */
80
#define FAT_BINARY_FL           0x00000001 /* File contains binary data */
81
 
82
/*
83
 * ioctl commands
84
 */
85
#define VFAT_IOCTL_READDIR_BOTH         _IOR('r', 1, struct dirent [2])
86
#define VFAT_IOCTL_READDIR_SHORT        _IOR('r', 2, struct dirent [2])
87
 
88
/*
89
 * Conversion from and to little-endian byte order. (no-op on i386/i486)
90
 *
91
 * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
92
 * BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
93
 */
94
 
95
#define CF_LE_W(v) (v)
96
#define CF_LE_L(v) (v)
97
#define CT_LE_W(v) (v)
98
#define CT_LE_L(v) (v)
99
 
100
 
101
struct fat_boot_sector {
102
        __s8    ignored[3];     /* Boot strap short or near jump */
103
        __s8    system_id[8];   /* Name - can be used to special case
104
                                   partition manager volumes */
105
        __u8    sector_size[2]; /* bytes per logical sector */
106
        __u8    cluster_size;   /* sectors/cluster */
107
        __u16   reserved;       /* reserved sectors */
108
        __u8    fats;           /* number of FATs */
109
        __u8    dir_entries[2]; /* root directory entries */
110
        __u8    sectors[2];     /* number of sectors */
111
        __u8    media;          /* media code (unused) */
112
        __u16   fat_length;     /* sectors/FAT */
113
        __u16   secs_track;     /* sectors per track */
114
        __u16   heads;          /* number of heads */
115
        __u32   hidden;         /* hidden sectors (unused) */
116
        __u32   total_sect;     /* number of sectors (if sectors == 0) */
117
 
118
        /* The following fields are only used by FAT32 */
119
        __u32   fat32_length;   /* sectors/FAT */
120
        __u16   flags;          /* bit 8: fat mirroring, low 4: active fat */
121
        __u8    version[2];     /* major, minor filesystem version */
122
        __u32   root_cluster;   /* first cluster in root directory */
123
        __u16   info_sector;    /* filesystem info sector */
124
        __u16   backup_boot;    /* backup boot sector */
125
        __u16   reserved2[6];   /* Unused */
126
};
127
 
128
struct fat_boot_fsinfo {
129
        __u32   reserved1;      /* Nothing as far as I can tell */
130
        __u32   signature;      /* 0x61417272L */
131
        __u32   free_clusters;  /* Free cluster count.  -1 if unknown */
132
        __u32   next_cluster;   /* Most recently allocated cluster.
133
                                 * Unused under Linux. */
134
        __u32   reserved2[4];
135
};
136
 
137
struct msdos_dir_entry {
138
        __s8    name[8],ext[3]; /* name and extension */
139
        __u8    attr;           /* attribute bits */
140
        __u8    lcase;          /* Case for base and extension */
141
        __u8    ctime_ms;       /* Creation time, milliseconds */
142
        __u16   ctime;          /* Creation time */
143
        __u16   cdate;          /* Creation date */
144
        __u16   adate;          /* Last access date */
145
        __u16   starthi;        /* High 16 bits of cluster in FAT32 */
146
        __u16   time,date,start;/* time, date and first cluster */
147
        __u32   size;           /* file size (in bytes) */
148
};
149
 
150
/* Up to 13 characters of the name */
151
struct msdos_dir_slot {
152
        __u8    id;             /* sequence number for slot */
153
        __u8    name0_4[10];    /* first 5 characters in name */
154
        __u8    attr;           /* attribute byte */
155
        __u8    reserved;       /* always 0 */
156
        __u8    alias_checksum; /* checksum for 8.3 alias */
157
        __u8    name5_10[12];   /* 6 more characters in name */
158
        __u16   start;          /* starting cluster number, 0 in long slots */
159
        __u8    name11_12[4];   /* last 2 characters in name */
160
};
161
 
162
struct slot_info {
163
        int is_long;                   /* was the found entry long */
164
        int long_slots;                /* number of long slots in filename */
165
        int total_slots;               /* total slots (long and short) */
166
        loff_t longname_offset;        /* dir offset for longname start */
167
        loff_t shortname_offset;       /* dir offset for shortname start */
168
        int ino;                       /* ino for the file */
169
};
170
 
171
/* Determine whether this FS has kB-aligned data. */
172
#define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
173
    ((mib)->data_start & 1)))
174
 
175
/* Convert attribute bits and a mask to the UNIX mode. */
176
#define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
177
 
178
/* Convert the UNIX mode to MS-DOS attribute bits. */
179
#define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
180
 
181
 
182
#ifdef __KERNEL__
183
 
184
typedef int (*fat_filldir_t)(filldir_t filldir, void *, const char *,
185
                             int, int, off_t, off_t, int, ino_t);
186
 
187
struct fat_cache {
188
        kdev_t device; /* device number. 0 means unused. */
189
        int ino; /* inode number. */
190
        int file_cluster; /* cluster number in the file. */
191
        int disk_cluster; /* cluster number on disk. */
192
        struct fat_cache *next; /* next cache entry */
193
};
194
 
195
/* misc.c */
196
extern int is_binary(char conversion,char *extension);
197
extern void lock_fat(struct super_block *sb);
198
extern void unlock_fat(struct super_block *sb);
199
extern int fat_add_cluster(struct inode *inode);
200
extern int date_dos2unix(__u16 time, __u16 date);
201
extern void fat_fs_panic(struct super_block *s,const char *msg);
202
extern void fat_lock_creation(void);
203
extern void fat_unlock_creation(void);
204
extern void fat_date_unix2dos(int unix_date,__u16 *time, __u16 *date);
205
extern int fat_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
206
                         struct msdos_dir_entry **de);
207
extern int fat_scan(struct inode *dir,const char *name,struct buffer_head **res_bh,
208
                    struct msdos_dir_entry **res_de,int *ino,char scantype);
209
extern int fat_parent_ino(struct inode *dir,int locked);
210
extern int fat_subdirs(struct inode *dir);
211
void fat_clusters_flush(struct super_block *sb);
212
 
213
/* fat.c */
214
extern int fat_access(struct super_block *sb,int nr,int new_value);
215
extern int fat_smap(struct inode *inode,int sector);
216
extern int fat_free(struct inode *inode,int skip);
217
void fat_cache_inval_inode(struct inode *inode);
218
void fat_cache_inval_dev(kdev_t device);
219
extern void cache_init(void);
220
void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
221
void cache_add(struct inode *inode,int f_clu,int d_clu);
222
int get_cluster(struct inode *inode,int cluster);
223
 
224
/* inode.c */
225
extern int fat_bmap(struct inode *inode,int block);
226
extern int fat_notify_change(struct inode *,struct iattr *);
227
extern void fat_put_inode(struct inode *inode);
228
extern void fat_put_super(struct super_block *sb);
229
extern void fat_read_inode(struct inode *inode, struct inode_operations *dir_ops);
230
extern struct super_block *fat_read_super(struct super_block *s, void *data, int silent);
231
extern void msdos_put_super(struct super_block *sb);
232
extern void fat_statfs(struct super_block *sb,struct statfs *buf, int);
233
extern void fat_write_inode(struct inode *inode);
234
 
235
/* dir.c */
236
extern struct file_operations fat_dir_operations;
237
extern int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
238
                        fat_filldir_t fat_filldir, filldir_t filldir,
239
                        int shortnames, int longnames, int both);
240
extern int fat_readdir(struct inode *inode, struct file *filp,
241
                       void *dirent, filldir_t);
242
extern int fat_dir_ioctl(struct inode * inode, struct file * filp,
243
                         unsigned int cmd, unsigned long arg);
244
 
245
/* file.c */
246
extern struct inode_operations fat_file_inode_operations;
247
extern struct inode_operations fat_file_inode_operations_1024;
248
extern int fat_file_read(struct inode *, struct file *, char *, int);
249
extern int fat_file_write(struct inode *, struct file *, const char *, int);
250
extern void fat_truncate(struct inode *inode);
251
 
252
/* mmap.c */
253
extern int fat_mmap(struct inode *, struct file *, struct vm_area_struct *);
254
 
255
 
256
/* vfat.c */
257
extern int init_vfat_fs(void);
258
 
259
 
260
/* msdosfs_syms.c */
261
extern int init_msdos_fs(void);
262
extern struct file_system_type msdos_fs_type;
263
 
264
/* msdos.c */
265
extern struct super_block *msdos_read_super(struct super_block *sb,void *data, int silent);
266
 
267
/* msdos.c - these are for Umsdos */
268
extern void msdos_read_inode(struct inode *inode);
269
extern int msdos_lookup(struct inode *dir,const char *name,int len,
270
                        struct inode **result);
271
extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
272
                        struct inode **result);
273
extern int msdos_rmdir(struct inode *dir,const char *name,int len);
274
extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
275
extern int msdos_unlink(struct inode *dir,const char *name,int len);
276
extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
277
extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
278
                        struct inode *new_dir,const char *new_name,int new_len,
279
                        int must_be_dir);
280
 
281
/* nls.c */
282
extern int init_fat_nls(void);
283
extern struct fat_nls_table *fat_load_nls(int codepage);
284
 
285
/* tables.c */
286
extern unsigned char fat_uni2esc[];
287
extern unsigned char fat_esc2uni[];
288
 
289
/* fatfs_syms.c */
290
extern int init_fat_fs(void);
291
extern void cleanup_fat_fs(void);
292
 
293
/* nls.c */
294
extern int fat_register_nls(struct fat_nls_table * fmt);
295
extern int fat_unregister_nls(struct fat_nls_table * fmt);
296
extern struct fat_nls_table *fat_find_nls(int codepage);
297
extern struct fat_nls_table *fat_load_nls(int codepage);
298
extern void fat_unload_nls(int codepage);
299
extern int init_fat_nls(void);
300
 
301
 
302
/* vfat/namei.c - these are for dmsdos */
303
extern int vfat_create(struct inode *dir,const char *name,int len,int mode,
304
                       struct inode **result);
305
extern int vfat_unlink(struct inode *dir,const char *name,int len);
306
extern int vfat_unlink_uvfat(struct inode *dir,const char *name,int len);
307
extern int vfat_mkdir(struct inode *dir,const char *name,int len,int mode);
308
extern int vfat_rmdir(struct inode *dir,const char *name,int len);
309
extern int vfat_rename(struct inode *old_dir,const char *old_name,int old_len,
310
                       struct inode *new_dir,const char *new_name,int new_len,
311
                       int must_be_dir);
312
extern void vfat_put_super(struct super_block *sb);
313
extern struct super_block *vfat_read_super(struct super_block *sb,void *data,
314
                                           int silent);
315
extern void vfat_read_inode(struct inode *inode);
316
extern int vfat_lookup(struct inode *dir,const char *name,int len,
317
                       struct inode **result);
318
 
319
/* vfat/vfatfs_syms.c */
320
extern struct file_system_type vfat_fs_type;
321
 
322
 
323
#endif /* __KERNEL__ */
324
 
325
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.