summaryrefslogtreecommitdiffstats
path: root/include/linux/msdos_fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/msdos_fs.h')
-rw-r--r--include/linux/msdos_fs.h216
1 files changed, 153 insertions, 63 deletions
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index fa2dd9fa9..7aef08e01 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -21,6 +21,9 @@
#define FAT_CACHE 8 /* FAT cache size */
+#define MSDOS_MAX_EXTRA 3 /* tolerate up to that number of clusters which are
+ inaccessible because the FAT is too short */
+
#define ATTR_RO 1 /* read-only */
#define ATTR_HIDDEN 2 /* hidden */
#define ATTR_SYS 4 /* system */
@@ -31,10 +34,26 @@
#define ATTR_NONE 0 /* no attribute bits */
#define ATTR_UNUSED (ATTR_VOLUME | ATTR_ARCH | ATTR_SYS | ATTR_HIDDEN)
/* attribute bits that are copied "as is" */
+#define ATTR_EXT (ATTR_RO | ATTR_HIDDEN | ATTR_SYS | ATTR_VOLUME)
+ /* bits that are used by the Windows 95/Windows NT extended FAT */
+
+#define ATTR_DIR_READ_BOTH 512 /* read both short and long names from the
+ * vfat filesystem. This is used by Samba
+ * to export the vfat filesystem with correct
+ * shortnames. */
+#define ATTR_DIR_READ_SHORT 1024
+
+#define CASE_LOWER_BASE 8 /* base is lower case */
+#define CASE_LOWER_EXT 16 /* extension is lower case */
+
+#define SCAN_ANY 0 /* either hidden or not */
+#define SCAN_HID 1 /* only hidden */
+#define SCAN_NOTHID 2 /* only not hidden */
+#define SCAN_NOTANY 3 /* test name, then use SCAN_HID or SCAN_NOTHID */
#define DELETED_FLAG 0xe5 /* marks file as deleted when in name[0] */
-#define IS_FREE(n) (!*(n) || *(unsigned char *) (n) == DELETED_FLAG || \
- *(unsigned char *) (n) == FD_FILL_BYTE)
+#define IS_FREE(n) (!*(n) || *(const unsigned char *) (n) == DELETED_FLAG || \
+ *(const unsigned char *) (n) == FD_FILL_BYTE)
#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)
/* valid file mode bits */
@@ -43,16 +62,29 @@
#define MSDOS_I(i) (&((i)->u.msdos_i))
#define MSDOS_NAME 11 /* maximum name length */
+#define MSDOS_LONGNAME 256 /* maximum name length */
+#define MSDOS_SLOTS 21 /* max # of slots needed for short and long names */
#define MSDOS_DOT ". " /* ".", padded to MSDOS_NAME chars */
#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */
#define MSDOS_FAT12 4078 /* maximum number of clusters in a 12 bit FAT */
/*
+ * Inode flags
+ */
+#define FAT_BINARY_FL 0x00000001 /* File contains binary data */
+
+/*
+ * ioctl commands
+ */
+#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, long)
+#define VFAT_IOCTL_READDIR_SHORT _IOW('r', 2, long)
+
+/*
* Conversion from and to little-endian byte order. (no-op on i386/i486)
*
- * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian, BE = big-
- * endian, c: W = word (16 bits), L = longword (32 bits)
+ * Naming: Ca_b_c, where a: F = from, T = to, b: LE = little-endian,
+ * BE = big-endian, c: W = word (16 bits), L = longword (32 bits)
*/
#define CF_LE_W(v) (v)
@@ -82,106 +114,164 @@ struct msdos_boot_sector {
struct msdos_dir_entry {
__s8 name[8],ext[3]; /* name and extension */
__u8 attr; /* attribute bits */
- __u8 unused[10];
+ __u8 lcase; /* Case for base and extension */
+ __u8 ctime_ms; /* Creation time, milliseconds */
+ __u16 ctime; /* Creation time */
+ __u16 cdate; /* Creation date */
+ __u16 adate; /* Last access date */
+ __u8 unused[2];
__u16 time,date,start;/* time, date and first cluster */
__u32 size; /* file size (in bytes) */
};
-struct fat_cache {
- int device; /* device number. 0 means unused. */
- int ino; /* inode number. */
- int file_cluster; /* cluster number in the file. */
- int disk_cluster; /* cluster number on disk. */
- struct fat_cache *next; /* next cache entry */
+/* Up to 13 characters of the name */
+struct msdos_dir_slot {
+ __u8 id; /* sequence number for slot */
+ __u8 name0_4[10]; /* first 5 characters in name */
+ __u8 attr; /* attribute byte */
+ __u8 reserved; /* always 0 */
+ __u8 alias_checksum; /* checksum for 8.3 alias */
+ __u8 name5_10[12]; /* 6 more characters in name */
+ __u8 start[2]; /* starting cluster number */
+ __u8 name11_12[4]; /* last 2 characters in name */
};
-/* Determine whether this FS has kB-aligned data. */
+struct slot_info {
+ int is_long; /* was the found entry long */
+ int long_slots; /* number of long slots in filename */
+ int total_slots; /* total slots (long and short) */
+ loff_t longname_offset; /* dir offset for longname start */
+ loff_t shortname_offset; /* dir offset for shortname start */
+ int ino; /* ino for the file */
+};
+/* Determine whether this FS has kB-aligned data. */
#define MSDOS_CAN_BMAP(mib) (!(((mib)->cluster_size & 1) || \
((mib)->data_start & 1)))
/* Convert attribute bits and a mask to the UNIX mode. */
-
#define MSDOS_MKMODE(a,m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO))
/* Convert the UNIX mode to MS-DOS attribute bits. */
-
#define MSDOS_MKATTR(m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)
+
#ifdef __KERNEL__
-/* misc.c */
+typedef int (*fat_filldir_t)(filldir_t filldir, void *, const char *,
+ int, int, off_t, off_t, int, ino_t);
+
+struct fat_cache {
+ kdev_t device; /* device number. 0 means unused. */
+ int ino; /* inode number. */
+ int file_cluster; /* cluster number in the file. */
+ int disk_cluster; /* cluster number on disk. */
+ struct fat_cache *next; /* next cache entry */
+};
-extern void fs_panic(struct super_block *s,char *msg);
+/* misc.c */
extern int is_binary(char conversion,char *extension);
-extern void lock_creation(void);
-extern void unlock_creation(void);
extern void lock_fat(struct super_block *sb);
extern void unlock_fat(struct super_block *sb);
-extern int msdos_add_cluster(struct inode *inode);
+extern int fat_add_cluster(struct inode *inode);
extern int date_dos2unix(__u16 time, __u16 date);
-extern void date_unix2dos(int unix_date,__u16 *time, __u16 *date);
-extern int msdos_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
- struct msdos_dir_entry **de);
-extern int msdos_scan(struct inode *dir,char *name,struct buffer_head **res_bh,
- struct msdos_dir_entry **res_de,int *ino);
-extern int msdos_parent_ino(struct inode *dir,int locked);
-extern int msdos_subdirs(struct inode *dir);
+extern void fat_fs_panic(struct super_block *s,const char *msg);
+extern void fat_lock_creation(void);
+extern void fat_unlock_creation(void);
+extern void fat_date_unix2dos(int unix_date,__u16 *time, __u16 *date);
+extern int fat_get_entry(struct inode *dir,loff_t *pos,struct buffer_head **bh,
+ struct msdos_dir_entry **de);
+extern int fat_scan(struct inode *dir,const char *name,struct buffer_head **res_bh,
+ struct msdos_dir_entry **res_de,int *ino,char scantype);
+extern int fat_parent_ino(struct inode *dir,int locked);
+extern int fat_subdirs(struct inode *dir);
/* fat.c */
-
extern int fat_access(struct super_block *sb,int nr,int new_value);
-extern int msdos_smap(struct inode *inode,int sector);
+extern int fat_smap(struct inode *inode,int sector);
extern int fat_free(struct inode *inode,int skip);
+void fat_cache_inval_inode(struct inode *inode);
+void fat_cache_inval_dev(kdev_t device);
extern void cache_init(void);
void cache_lookup(struct inode *inode,int cluster,int *f_clu,int *d_clu);
void cache_add(struct inode *inode,int f_clu,int d_clu);
-void cache_inval_inode(struct inode *inode);
-void cache_inval_dev(int device);
int get_cluster(struct inode *inode,int cluster);
-/* namei.c */
-
-extern int msdos_lookup(struct inode *dir,const char *name,int len,
- struct inode **result);
-extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
- struct inode **result);
-extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
-extern int msdos_rmdir(struct inode *dir,const char *name,int len);
-extern int msdos_unlink(struct inode *dir,const char *name,int len);
-extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
-extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
- struct inode *new_dir,const char *new_name,int new_len);
-
/* inode.c */
-
-extern void msdos_put_inode(struct inode *inode);
+extern int fat_bmap(struct inode *inode,int block);
+extern int fat_notify_change(struct inode *,struct iattr *);
+extern void fat_put_inode(struct inode *inode);
+extern void fat_put_super(struct super_block *sb);
+extern void fat_read_inode(struct inode *inode, struct inode_operations *dir_ops);
+extern struct super_block *fat_read_super(struct super_block *s, void *data, int silent);
extern void msdos_put_super(struct super_block *sb);
-extern struct super_block *msdos_read_super(struct super_block *s,
- void *data,int);
-extern void msdos_statfs(struct super_block *sb,struct statfs *buf, int);
-extern int msdos_bmap(struct inode *inode,int block);
-extern void msdos_read_inode(struct inode *inode);
-extern void msdos_write_inode(struct inode *inode);
-extern int msdos_notify_change(struct inode *,struct iattr *);
+extern void fat_statfs(struct super_block *sb,struct statfs *buf, int);
+extern void fat_write_inode(struct inode *inode);
/* dir.c */
+extern struct file_operations fat_dir_operations;
+extern int fat_readdirx(struct inode *inode, struct file *filp, void *dirent,
+ fat_filldir_t fat_filldir, filldir_t filldir,
+ int shortnames, int longnames, int both);
+extern int fat_readdir(struct inode *inode, struct file *filp,
+ void *dirent, filldir_t);
+extern int fat_dir_ioctl(struct inode * inode, struct file * filp,
+ unsigned int cmd, unsigned long arg);
-extern struct inode_operations msdos_dir_inode_operations;
-extern int msdos_readdir (struct inode *inode, struct file *filp,
- void *dirent, filldir_t);
/* file.c */
+extern struct inode_operations fat_file_inode_operations;
+extern struct inode_operations fat_file_inode_operations_1024;
+extern long fat_file_read(struct inode *, struct file *, char *, unsigned long);
+extern long fat_file_write(struct inode *, struct file *, const char *, unsigned long);
+extern void fat_truncate(struct inode *inode);
-extern struct inode_operations msdos_file_inode_operations;
-extern struct inode_operations msdos_file_inode_operations_1024;
-extern int msdos_file_read(struct inode *, struct file *, char *, int);
-extern int msdos_file_write(struct inode *, struct file *, char *, int);
-extern struct inode_operations msdos_file_inode_operations_no_bmap;
+/* mmap.c */
+extern int fat_mmap(struct inode *, struct file *, struct vm_area_struct *);
-extern void msdos_truncate(struct inode *inode);
-/* mmap.c */
-extern int msdos_mmap(struct inode *, struct file *, struct vm_area_struct *);
+/* vfat.c */
+extern int init_vfat_fs(void);
+
+
+/* msdosfs_syms.c */
+extern int init_msdos_fs(void);
+extern struct file_system_type msdos_fs_type;
+
+/* msdos.c */
+extern struct super_block *msdos_read_super(struct super_block *sb,void *data, int silent);
+
+/* msdos.c - these are for Umsdos */
+extern void msdos_read_inode(struct inode *inode);
+extern int msdos_lookup(struct inode *dir,const char *name,int len,
+ struct inode **result);
+extern int msdos_create(struct inode *dir,const char *name,int len,int mode,
+ struct inode **result);
+extern int msdos_rmdir(struct inode *dir,const char *name,int len);
+extern int msdos_mkdir(struct inode *dir,const char *name,int len,int mode);
+extern int msdos_unlink(struct inode *dir,const char *name,int len);
+extern int msdos_unlink_umsdos(struct inode *dir,const char *name,int len);
+extern int msdos_rename(struct inode *old_dir,const char *old_name,int old_len,
+ struct inode *new_dir,const char *new_name,int new_len,
+ int must_be_dir);
+
+/* fatfs_syms.c */
+extern int init_fat_fs(void);
+
+/* vfat/namei.c - these are for dmsdos */
+extern int vfat_create(struct inode *dir,const char *name,int len,int mode,
+ struct inode **result);
+extern int vfat_unlink(struct inode *dir,const char *name,int len);
+extern int vfat_mkdir(struct inode *dir,const char *name,int len,int mode);
+extern int vfat_rmdir(struct inode *dir,const char *name,int len);
+extern int vfat_rename(struct inode *old_dir,const char *old_name,int old_len,
+ struct inode *new_dir,const char *new_name,int new_len,
+ int must_be_dir);
+extern void vfat_put_super(struct super_block *sb);
+extern struct super_block *vfat_read_super(struct super_block *sb,void *data,
+ int silent);
+extern void vfat_read_inode(struct inode *inode);
+extern int vfat_lookup(struct inode *dir,const char *name,int len,
+ struct inode **result);
#endif /* __KERNEL__ */