Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / include / linux / msdos_fs.h
index 9a3d272..81cd36b 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _LINUX_MSDOS_FS_H
 #define _LINUX_MSDOS_FS_H
 
+#include <linux/magic.h>
+
 /*
  * The MS-DOS filesystem constants/structures
  */
@@ -18,8 +20,6 @@
 #define CT_LE_L(v)     cpu_to_le32(v)
 
 
-#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
-
 #define MSDOS_ROOT_INO 1       /* == MINIX_ROOT_INO */
 #define MSDOS_DIR_BITS 5       /* log2(sizeof(struct msdos_dir_entry)) */
 
@@ -57,8 +57,6 @@
 #define MSDOS_DOT      ".          "   /* ".", padded to MSDOS_NAME chars */
 #define MSDOS_DOTDOT   "..         "   /* "..", padded to MSDOS_NAME chars */
 
-/* media of boot sector */
-#define FAT_VALID_MEDIA(x)     ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
 #define FAT_FIRST_ENT(s, x)    ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
        MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
 
@@ -146,7 +144,7 @@ struct fat_boot_fsinfo {
 };
 
 struct msdos_dir_entry {
-       __u8    name[8],ext[3]; /* name and extension */
+       __u8    name[MSDOS_NAME];/* name and extension */
        __u8    attr;           /* attribute bits */
        __u8    lcase;          /* Case for base and extension */
        __u8    ctime_cs;       /* Creation time, centiseconds (0-199) */
@@ -184,6 +182,7 @@ struct fat_slot_info {
 #include <linux/string.h>
 #include <linux/nls.h>
 #include <linux/fs.h>
+#include <linux/mutex.h>
 
 struct fat_mount_options {
        uid_t fs_uid;
@@ -194,16 +193,19 @@ struct fat_mount_options {
        char *iocharset;          /* Charset used for filename input/display */
        unsigned short shortname; /* flags for shortname display/create rule */
        unsigned char name_check; /* r = relaxed, n = normal, s = strict */
+       unsigned short allow_utime;/* permission for setting the [am]time */
        unsigned quiet:1,         /* set = fake successful chmods and chowns */
                 showexec:1,      /* set = only set x bit for com/exe/bat */
                 sys_immutable:1, /* set = system files are immutable */
                 dotsOK:1,        /* set = hidden and system files are named '.filename' */
                 isvfat:1,        /* 0=no vfat long filename support, 1=vfat support */
-                utf8:1,          /* Use of UTF8 character set (Default) */
+                utf8:1,          /* Use of UTF-8 character set (Default) */
                 unicode_xlate:1, /* create escape sequences for unhandled Unicode */
                 numtail:1,       /* Does first alias have a numeric '~1' type tail? */
                 atari:1,         /* Use Atari GEMDOS variation of MS-DOS fs */
-                nocase:1;        /* Does this need case conversion? 0=need case conversion*/
+                flush:1,         /* write things quickly */
+                nocase:1,        /* Does this need case conversion? 0=need case conversion*/
+                usefree:1;       /* Use free_clusters for FAT32 */
 };
 
 #define FAT_HASH_BITS  8
@@ -226,13 +228,14 @@ struct msdos_sb_info {
        unsigned long max_cluster;   /* maximum cluster number */
        unsigned long root_cluster;  /* first cluster of the root directory */
        unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
-       struct semaphore fat_lock;
+       struct mutex fat_lock;
        unsigned int prev_free;      /* previously allocated cluster number */
        unsigned int free_clusters;  /* -1 if undefined */
+       unsigned int free_clus_valid; /* is free_clusters valid? */
        struct fat_mount_options options;
        struct nls_table *nls_disk;  /* Codepage used on disk */
        struct nls_table *nls_io;    /* Charset used for input and display */
-       void *dir_ops;               /* Opaque; default directory operations */
+       const void *dir_ops;                 /* Opaque; default directory operations */
        int dir_per_block;           /* dir entries per block */
        int dir_per_block_bits;      /* log2(dir_per_block) */
 
@@ -282,6 +285,17 @@ static inline u8 fat_attr(struct inode *inode)
                MSDOS_I(inode)->i_attrs;
 }
 
+static inline unsigned char fat_checksum(const __u8 *name)
+{
+       unsigned char s = name[0];
+       s = (s<<7) + (s>>1) + name[1];  s = (s<<7) + (s>>1) + name[2];
+       s = (s<<7) + (s>>1) + name[3];  s = (s<<7) + (s>>1) + name[4];
+       s = (s<<7) + (s>>1) + name[5];  s = (s<<7) + (s>>1) + name[6];
+       s = (s<<7) + (s>>1) + name[7];  s = (s<<7) + (s>>1) + name[8];
+       s = (s<<7) + (s>>1) + name[9];  s = (s<<7) + (s>>1) + name[10];
+       return s;
+}
+
 static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
 {
        return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus
@@ -314,14 +328,21 @@ static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len)
 #endif
 }
 
+/* media of boot sector */
+static inline int fat_valid_media(u8 media)
+{
+       return 0xf8 <= media || media == 0xf0;
+}
+
 /* fat/cache.c */
 extern void fat_cache_inval_inode(struct inode *inode);
 extern int fat_get_cluster(struct inode *inode, int cluster,
                           int *fclus, int *dclus);
-extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys);
+extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
+                   unsigned long *mapped_blocks);
 
 /* fat/dir.c */
-extern struct file_operations fat_dir_operations;
+extern const struct file_operations fat_dir_operations;
 extern int fat_search_long(struct inode *inode, const unsigned char *name,
                           int name_len, struct fat_slot_info *sinfo);
 extern int fat_dir_empty(struct inode *dir);
@@ -384,10 +405,12 @@ extern int fat_count_free_clusters(struct super_block *sb);
 /* fat/file.c */
 extern int fat_generic_ioctl(struct inode *inode, struct file *filp,
                             unsigned int cmd, unsigned long arg);
-extern struct file_operations fat_file_operations;
-extern struct inode_operations fat_file_inode_operations;
-extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
+extern const struct file_operations fat_file_operations;
+extern const struct inode_operations fat_file_inode_operations;
+extern int fat_setattr(struct dentry * dentry, struct iattr * attr);
 extern void fat_truncate(struct inode *inode);
+extern int fat_getattr(struct vfsmount *mnt, struct dentry *dentry,
+                      struct kstat *stat);
 
 /* fat/inode.c */
 extern void fat_attach(struct inode *inode, loff_t i_pos);
@@ -397,8 +420,10 @@ extern struct inode *fat_build_inode(struct super_block *sb,
                        struct msdos_dir_entry *de, loff_t i_pos);
 extern int fat_sync_inode(struct inode *inode);
 extern int fat_fill_super(struct super_block *sb, void *data, int silent,
-                       struct inode_operations *fs_dir_inode_ops, int isvfat);
+                       const struct inode_operations *fs_dir_inode_ops, int isvfat);
 
+extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
+                           struct inode *i2);
 /* fat/misc.c */
 extern void fat_fs_panic(struct super_block *s, const char *fmt, ...);
 extern void fat_clusters_flush(struct super_block *sb);
@@ -407,6 +432,9 @@ extern int date_dos2unix(unsigned short time, unsigned short date);
 extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date);
 extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
 
+int fat_cache_init(void);
+void fat_cache_destroy(void);
+
 #endif /* __KERNEL__ */
 
 #endif