xref: /linux/fs/fat/fat.h (revision dacd0e7b392dfaf888461741dbcaccf8b6a15bac)
19e975daeSOGAWA Hirofumi #ifndef _FAT_H
29e975daeSOGAWA Hirofumi #define _FAT_H
39e975daeSOGAWA Hirofumi 
49e975daeSOGAWA Hirofumi #include <linux/buffer_head.h>
59e975daeSOGAWA Hirofumi #include <linux/string.h>
69e975daeSOGAWA Hirofumi #include <linux/nls.h>
79e975daeSOGAWA Hirofumi #include <linux/fs.h>
89e975daeSOGAWA Hirofumi #include <linux/mutex.h>
9aaa04b48SOGAWA Hirofumi #include <linux/ratelimit.h>
109e975daeSOGAWA Hirofumi #include <linux/msdos_fs.h>
119e975daeSOGAWA Hirofumi 
129e975daeSOGAWA Hirofumi /*
139e975daeSOGAWA Hirofumi  * vfat shortname flags
149e975daeSOGAWA Hirofumi  */
159e975daeSOGAWA Hirofumi #define VFAT_SFN_DISPLAY_LOWER	0x0001 /* convert to lowercase for display */
169e975daeSOGAWA Hirofumi #define VFAT_SFN_DISPLAY_WIN95	0x0002 /* emulate win95 rule for display */
179e975daeSOGAWA Hirofumi #define VFAT_SFN_DISPLAY_WINNT	0x0004 /* emulate winnt rule for display */
189e975daeSOGAWA Hirofumi #define VFAT_SFN_CREATE_WIN95	0x0100 /* emulate win95 rule for create */
199e975daeSOGAWA Hirofumi #define VFAT_SFN_CREATE_WINNT	0x0200 /* emulate winnt rule for create */
209e975daeSOGAWA Hirofumi 
2185c78591SDenis Karpov #define FAT_ERRORS_CONT		1      /* ignore error and continue */
2285c78591SDenis Karpov #define FAT_ERRORS_PANIC	2      /* panic on error */
2385c78591SDenis Karpov #define FAT_ERRORS_RO		3      /* remount r/o on error */
2485c78591SDenis Karpov 
259e975daeSOGAWA Hirofumi struct fat_mount_options {
269e975daeSOGAWA Hirofumi 	uid_t fs_uid;
279e975daeSOGAWA Hirofumi 	gid_t fs_gid;
289e975daeSOGAWA Hirofumi 	unsigned short fs_fmask;
299e975daeSOGAWA Hirofumi 	unsigned short fs_dmask;
309e975daeSOGAWA Hirofumi 	unsigned short codepage;  /* Codepage for shortname conversions */
319e975daeSOGAWA Hirofumi 	char *iocharset;          /* Charset used for filename input/display */
329e975daeSOGAWA Hirofumi 	unsigned short shortname; /* flags for shortname display/create rule */
339e975daeSOGAWA Hirofumi 	unsigned char name_check; /* r = relaxed, n = normal, s = strict */
3485c78591SDenis Karpov 	unsigned char errors;	  /* On error: continue, panic, remount-ro */
359e975daeSOGAWA Hirofumi 	unsigned short allow_utime;/* permission for setting the [am]time */
369e975daeSOGAWA Hirofumi 	unsigned quiet:1,         /* set = fake successful chmods and chowns */
379e975daeSOGAWA Hirofumi 		 showexec:1,      /* set = only set x bit for com/exe/bat */
389e975daeSOGAWA Hirofumi 		 sys_immutable:1, /* set = system files are immutable */
399e975daeSOGAWA Hirofumi 		 dotsOK:1,        /* set = hidden and system files are named '.filename' */
409e975daeSOGAWA Hirofumi 		 isvfat:1,        /* 0=no vfat long filename support, 1=vfat support */
419e975daeSOGAWA Hirofumi 		 utf8:1,	  /* Use of UTF-8 character set (Default) */
429e975daeSOGAWA Hirofumi 		 unicode_xlate:1, /* create escape sequences for unhandled Unicode */
439e975daeSOGAWA Hirofumi 		 numtail:1,       /* Does first alias have a numeric '~1' type tail? */
449e975daeSOGAWA Hirofumi 		 flush:1,	  /* write things quickly */
459e975daeSOGAWA Hirofumi 		 nocase:1,	  /* Does this need case conversion? 0=need case conversion*/
469e975daeSOGAWA Hirofumi 		 usefree:1,	  /* Use free_clusters for FAT32 */
47dfc209c0SOGAWA Hirofumi 		 tz_utc:1,	  /* Filesystem timestamps are in UTC */
48681142f9SChristoph Hellwig 		 rodir:1,	  /* allow ATTR_RO for directory */
49681142f9SChristoph Hellwig 		 discard:1;	  /* Issue discard requests on deletions */
509e975daeSOGAWA Hirofumi };
519e975daeSOGAWA Hirofumi 
529e975daeSOGAWA Hirofumi #define FAT_HASH_BITS	8
539e975daeSOGAWA Hirofumi #define FAT_HASH_SIZE	(1UL << FAT_HASH_BITS)
549e975daeSOGAWA Hirofumi 
559e975daeSOGAWA Hirofumi /*
569e975daeSOGAWA Hirofumi  * MS-DOS file system in-core superblock data
579e975daeSOGAWA Hirofumi  */
589e975daeSOGAWA Hirofumi struct msdos_sb_info {
599e975daeSOGAWA Hirofumi 	unsigned short sec_per_clus; /* sectors/cluster */
609e975daeSOGAWA Hirofumi 	unsigned short cluster_bits; /* log2(cluster_size) */
619e975daeSOGAWA Hirofumi 	unsigned int cluster_size;   /* cluster size */
629e975daeSOGAWA Hirofumi 	unsigned char fats,fat_bits; /* number of FATs, FAT bits (12 or 16) */
639e975daeSOGAWA Hirofumi 	unsigned short fat_start;
649e975daeSOGAWA Hirofumi 	unsigned long fat_length;    /* FAT start & length (sec.) */
659e975daeSOGAWA Hirofumi 	unsigned long dir_start;
669e975daeSOGAWA Hirofumi 	unsigned short dir_entries;  /* root dir start & entries */
679e975daeSOGAWA Hirofumi 	unsigned long data_start;    /* first data sector */
689e975daeSOGAWA Hirofumi 	unsigned long max_cluster;   /* maximum cluster number */
699e975daeSOGAWA Hirofumi 	unsigned long root_cluster;  /* first cluster of the root directory */
709e975daeSOGAWA Hirofumi 	unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
719e975daeSOGAWA Hirofumi 	struct mutex fat_lock;
729e975daeSOGAWA Hirofumi 	unsigned int prev_free;      /* previously allocated cluster number */
739e975daeSOGAWA Hirofumi 	unsigned int free_clusters;  /* -1 if undefined */
749e975daeSOGAWA Hirofumi 	unsigned int free_clus_valid; /* is free_clusters valid? */
759e975daeSOGAWA Hirofumi 	struct fat_mount_options options;
769e975daeSOGAWA Hirofumi 	struct nls_table *nls_disk;  /* Codepage used on disk */
779e975daeSOGAWA Hirofumi 	struct nls_table *nls_io;    /* Charset used for input and display */
789e975daeSOGAWA Hirofumi 	const void *dir_ops;		     /* Opaque; default directory operations */
799e975daeSOGAWA Hirofumi 	int dir_per_block;	     /* dir entries per block */
809e975daeSOGAWA Hirofumi 	int dir_per_block_bits;	     /* log2(dir_per_block) */
819e975daeSOGAWA Hirofumi 
829e975daeSOGAWA Hirofumi 	int fatent_shift;
839e975daeSOGAWA Hirofumi 	struct fatent_operations *fatent_ops;
84b522412aSAl Viro 	struct inode *fat_inode;
859e975daeSOGAWA Hirofumi 
86aaa04b48SOGAWA Hirofumi 	struct ratelimit_state ratelimit;
87aaa04b48SOGAWA Hirofumi 
889e975daeSOGAWA Hirofumi 	spinlock_t inode_hash_lock;
899e975daeSOGAWA Hirofumi 	struct hlist_head inode_hashtable[FAT_HASH_SIZE];
909e975daeSOGAWA Hirofumi };
919e975daeSOGAWA Hirofumi 
929e975daeSOGAWA Hirofumi #define FAT_CACHE_VALID	0	/* special case for valid cache */
939e975daeSOGAWA Hirofumi 
949e975daeSOGAWA Hirofumi /*
959e975daeSOGAWA Hirofumi  * MS-DOS file system inode data in memory
969e975daeSOGAWA Hirofumi  */
979e975daeSOGAWA Hirofumi struct msdos_inode_info {
989e975daeSOGAWA Hirofumi 	spinlock_t cache_lru_lock;
999e975daeSOGAWA Hirofumi 	struct list_head cache_lru;
1009e975daeSOGAWA Hirofumi 	int nr_caches;
1019e975daeSOGAWA Hirofumi 	/* for avoiding the race between fat_free() and fat_get_cluster() */
1029e975daeSOGAWA Hirofumi 	unsigned int cache_valid_id;
1039e975daeSOGAWA Hirofumi 
1042bdf67ebSOGAWA Hirofumi 	/* NOTE: mmu_private is 64bits, so must hold ->i_mutex to access */
1052bdf67ebSOGAWA Hirofumi 	loff_t mmu_private;	/* physically allocated size */
1062bdf67ebSOGAWA Hirofumi 
1079e975daeSOGAWA Hirofumi 	int i_start;		/* first cluster or 0 */
1089e975daeSOGAWA Hirofumi 	int i_logstart;		/* logical first cluster */
1099e975daeSOGAWA Hirofumi 	int i_attrs;		/* unused attribute bits */
1109e975daeSOGAWA Hirofumi 	loff_t i_pos;		/* on-disk position of directory entry or 0 */
1119e975daeSOGAWA Hirofumi 	struct hlist_node i_fat_hash;	/* hash by i_location */
11258268691SChristoph Hellwig 	struct rw_semaphore truncate_lock; /* protect bmap against truncate */
1139e975daeSOGAWA Hirofumi 	struct inode vfs_inode;
1149e975daeSOGAWA Hirofumi };
1159e975daeSOGAWA Hirofumi 
1169e975daeSOGAWA Hirofumi struct fat_slot_info {
1179e975daeSOGAWA Hirofumi 	loff_t i_pos;		/* on-disk position of directory entry */
1189e975daeSOGAWA Hirofumi 	loff_t slot_off;	/* offset for slot or de start */
1199e975daeSOGAWA Hirofumi 	int nr_slots;		/* number of slots + 1(de) in filename */
1209e975daeSOGAWA Hirofumi 	struct msdos_dir_entry *de;
1219e975daeSOGAWA Hirofumi 	struct buffer_head *bh;
1229e975daeSOGAWA Hirofumi };
1239e975daeSOGAWA Hirofumi 
1249e975daeSOGAWA Hirofumi static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
1259e975daeSOGAWA Hirofumi {
1269e975daeSOGAWA Hirofumi 	return sb->s_fs_info;
1279e975daeSOGAWA Hirofumi }
1289e975daeSOGAWA Hirofumi 
1299e975daeSOGAWA Hirofumi static inline struct msdos_inode_info *MSDOS_I(struct inode *inode)
1309e975daeSOGAWA Hirofumi {
1319e975daeSOGAWA Hirofumi 	return container_of(inode, struct msdos_inode_info, vfs_inode);
1329e975daeSOGAWA Hirofumi }
1339e975daeSOGAWA Hirofumi 
1349183482fSOGAWA Hirofumi /*
1359183482fSOGAWA Hirofumi  * If ->i_mode can't hold S_IWUGO (i.e. ATTR_RO), we use ->i_attrs to
1369183482fSOGAWA Hirofumi  * save ATTR_RO instead of ->i_mode.
137dfc209c0SOGAWA Hirofumi  *
138dfc209c0SOGAWA Hirofumi  * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
139dfc209c0SOGAWA Hirofumi  * bit, it's just used as flag for app.
1409183482fSOGAWA Hirofumi  */
1419183482fSOGAWA Hirofumi static inline int fat_mode_can_hold_ro(struct inode *inode)
1429183482fSOGAWA Hirofumi {
1439183482fSOGAWA Hirofumi 	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
144*dacd0e7bSAl Viro 	umode_t mask;
1459183482fSOGAWA Hirofumi 
146dfc209c0SOGAWA Hirofumi 	if (S_ISDIR(inode->i_mode)) {
147dfc209c0SOGAWA Hirofumi 		if (!sbi->options.rodir)
148dfc209c0SOGAWA Hirofumi 			return 0;
1499183482fSOGAWA Hirofumi 		mask = ~sbi->options.fs_dmask;
150dfc209c0SOGAWA Hirofumi 	} else
1519183482fSOGAWA Hirofumi 		mask = ~sbi->options.fs_fmask;
1529183482fSOGAWA Hirofumi 
1539183482fSOGAWA Hirofumi 	if (!(mask & S_IWUGO))
1549183482fSOGAWA Hirofumi 		return 0;
1559183482fSOGAWA Hirofumi 	return 1;
1569183482fSOGAWA Hirofumi }
1579183482fSOGAWA Hirofumi 
1589c0aa1b8SOGAWA Hirofumi /* Convert attribute bits and a mask to the UNIX mode. */
159*dacd0e7bSAl Viro static inline umode_t fat_make_mode(struct msdos_sb_info *sbi,
160*dacd0e7bSAl Viro 				   u8 attrs, umode_t mode)
1619c0aa1b8SOGAWA Hirofumi {
162dfc209c0SOGAWA Hirofumi 	if (attrs & ATTR_RO && !((attrs & ATTR_DIR) && !sbi->options.rodir))
1639c0aa1b8SOGAWA Hirofumi 		mode &= ~S_IWUGO;
1649c0aa1b8SOGAWA Hirofumi 
1659c0aa1b8SOGAWA Hirofumi 	if (attrs & ATTR_DIR)
1669c0aa1b8SOGAWA Hirofumi 		return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
1679c0aa1b8SOGAWA Hirofumi 	else
1689c0aa1b8SOGAWA Hirofumi 		return (mode & ~sbi->options.fs_fmask) | S_IFREG;
1699c0aa1b8SOGAWA Hirofumi }
1709c0aa1b8SOGAWA Hirofumi 
1719e975daeSOGAWA Hirofumi /* Return the FAT attribute byte for this inode */
1729c0aa1b8SOGAWA Hirofumi static inline u8 fat_make_attrs(struct inode *inode)
1739e975daeSOGAWA Hirofumi {
1749183482fSOGAWA Hirofumi 	u8 attrs = MSDOS_I(inode)->i_attrs;
1759183482fSOGAWA Hirofumi 	if (S_ISDIR(inode->i_mode))
1769183482fSOGAWA Hirofumi 		attrs |= ATTR_DIR;
1779183482fSOGAWA Hirofumi 	if (fat_mode_can_hold_ro(inode) && !(inode->i_mode & S_IWUGO))
1789183482fSOGAWA Hirofumi 		attrs |= ATTR_RO;
1799183482fSOGAWA Hirofumi 	return attrs;
1809e975daeSOGAWA Hirofumi }
1819e975daeSOGAWA Hirofumi 
1829c0aa1b8SOGAWA Hirofumi static inline void fat_save_attrs(struct inode *inode, u8 attrs)
1839c0aa1b8SOGAWA Hirofumi {
1849183482fSOGAWA Hirofumi 	if (fat_mode_can_hold_ro(inode))
1859c0aa1b8SOGAWA Hirofumi 		MSDOS_I(inode)->i_attrs = attrs & ATTR_UNUSED;
1869183482fSOGAWA Hirofumi 	else
1879183482fSOGAWA Hirofumi 		MSDOS_I(inode)->i_attrs = attrs & (ATTR_UNUSED | ATTR_RO);
1889c0aa1b8SOGAWA Hirofumi }
1899c0aa1b8SOGAWA Hirofumi 
1909e975daeSOGAWA Hirofumi static inline unsigned char fat_checksum(const __u8 *name)
1919e975daeSOGAWA Hirofumi {
1929e975daeSOGAWA Hirofumi 	unsigned char s = name[0];
1939e975daeSOGAWA Hirofumi 	s = (s<<7) + (s>>1) + name[1];	s = (s<<7) + (s>>1) + name[2];
1949e975daeSOGAWA Hirofumi 	s = (s<<7) + (s>>1) + name[3];	s = (s<<7) + (s>>1) + name[4];
1959e975daeSOGAWA Hirofumi 	s = (s<<7) + (s>>1) + name[5];	s = (s<<7) + (s>>1) + name[6];
1969e975daeSOGAWA Hirofumi 	s = (s<<7) + (s>>1) + name[7];	s = (s<<7) + (s>>1) + name[8];
1979e975daeSOGAWA Hirofumi 	s = (s<<7) + (s>>1) + name[9];	s = (s<<7) + (s>>1) + name[10];
1989e975daeSOGAWA Hirofumi 	return s;
1999e975daeSOGAWA Hirofumi }
2009e975daeSOGAWA Hirofumi 
2019e975daeSOGAWA Hirofumi static inline sector_t fat_clus_to_blknr(struct msdos_sb_info *sbi, int clus)
2029e975daeSOGAWA Hirofumi {
2039e975daeSOGAWA Hirofumi 	return ((sector_t)clus - FAT_START_ENT) * sbi->sec_per_clus
2049e975daeSOGAWA Hirofumi 		+ sbi->data_start;
2059e975daeSOGAWA Hirofumi }
2069e975daeSOGAWA Hirofumi 
2079e975daeSOGAWA Hirofumi static inline void fat16_towchar(wchar_t *dst, const __u8 *src, size_t len)
2089e975daeSOGAWA Hirofumi {
2099e975daeSOGAWA Hirofumi #ifdef __BIG_ENDIAN
2109e975daeSOGAWA Hirofumi 	while (len--) {
2119e975daeSOGAWA Hirofumi 		*dst++ = src[0] | (src[1] << 8);
2129e975daeSOGAWA Hirofumi 		src += 2;
2139e975daeSOGAWA Hirofumi 	}
2149e975daeSOGAWA Hirofumi #else
2159e975daeSOGAWA Hirofumi 	memcpy(dst, src, len * 2);
2169e975daeSOGAWA Hirofumi #endif
2179e975daeSOGAWA Hirofumi }
2189e975daeSOGAWA Hirofumi 
2199e975daeSOGAWA Hirofumi static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len)
2209e975daeSOGAWA Hirofumi {
2219e975daeSOGAWA Hirofumi #ifdef __BIG_ENDIAN
2229e975daeSOGAWA Hirofumi 	while (len--) {
2239e975daeSOGAWA Hirofumi 		dst[0] = *src & 0x00FF;
2249e975daeSOGAWA Hirofumi 		dst[1] = (*src & 0xFF00) >> 8;
2259e975daeSOGAWA Hirofumi 		dst += 2;
2269e975daeSOGAWA Hirofumi 		src++;
2279e975daeSOGAWA Hirofumi 	}
2289e975daeSOGAWA Hirofumi #else
2299e975daeSOGAWA Hirofumi 	memcpy(dst, src, len * 2);
2309e975daeSOGAWA Hirofumi #endif
2319e975daeSOGAWA Hirofumi }
2329e975daeSOGAWA Hirofumi 
2339e975daeSOGAWA Hirofumi /* fat/cache.c */
2349e975daeSOGAWA Hirofumi extern void fat_cache_inval_inode(struct inode *inode);
2359e975daeSOGAWA Hirofumi extern int fat_get_cluster(struct inode *inode, int cluster,
2369e975daeSOGAWA Hirofumi 			   int *fclus, int *dclus);
2379e975daeSOGAWA Hirofumi extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
2382bdf67ebSOGAWA Hirofumi 		    unsigned long *mapped_blocks, int create);
2399e975daeSOGAWA Hirofumi 
2409e975daeSOGAWA Hirofumi /* fat/dir.c */
2419e975daeSOGAWA Hirofumi extern const struct file_operations fat_dir_operations;
2429e975daeSOGAWA Hirofumi extern int fat_search_long(struct inode *inode, const unsigned char *name,
2439e975daeSOGAWA Hirofumi 			   int name_len, struct fat_slot_info *sinfo);
2449e975daeSOGAWA Hirofumi extern int fat_dir_empty(struct inode *dir);
2459e975daeSOGAWA Hirofumi extern int fat_subdirs(struct inode *dir);
2469e975daeSOGAWA Hirofumi extern int fat_scan(struct inode *dir, const unsigned char *name,
2479e975daeSOGAWA Hirofumi 		    struct fat_slot_info *sinfo);
2489e975daeSOGAWA Hirofumi extern int fat_get_dotdot_entry(struct inode *dir, struct buffer_head **bh,
2499e975daeSOGAWA Hirofumi 				struct msdos_dir_entry **de, loff_t *i_pos);
2509e975daeSOGAWA Hirofumi extern int fat_alloc_new_dir(struct inode *dir, struct timespec *ts);
2519e975daeSOGAWA Hirofumi extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots,
2529e975daeSOGAWA Hirofumi 			   struct fat_slot_info *sinfo);
2539e975daeSOGAWA Hirofumi extern int fat_remove_entries(struct inode *dir, struct fat_slot_info *sinfo);
2549e975daeSOGAWA Hirofumi 
2559e975daeSOGAWA Hirofumi /* fat/fatent.c */
2569e975daeSOGAWA Hirofumi struct fat_entry {
2579e975daeSOGAWA Hirofumi 	int entry;
2589e975daeSOGAWA Hirofumi 	union {
2599e975daeSOGAWA Hirofumi 		u8 *ent12_p[2];
2609e975daeSOGAWA Hirofumi 		__le16 *ent16_p;
2619e975daeSOGAWA Hirofumi 		__le32 *ent32_p;
2629e975daeSOGAWA Hirofumi 	} u;
2639e975daeSOGAWA Hirofumi 	int nr_bhs;
2649e975daeSOGAWA Hirofumi 	struct buffer_head *bhs[2];
265b522412aSAl Viro 	struct inode *fat_inode;
2669e975daeSOGAWA Hirofumi };
2679e975daeSOGAWA Hirofumi 
2689e975daeSOGAWA Hirofumi static inline void fatent_init(struct fat_entry *fatent)
2699e975daeSOGAWA Hirofumi {
2709e975daeSOGAWA Hirofumi 	fatent->nr_bhs = 0;
2719e975daeSOGAWA Hirofumi 	fatent->entry = 0;
2729e975daeSOGAWA Hirofumi 	fatent->u.ent32_p = NULL;
2739e975daeSOGAWA Hirofumi 	fatent->bhs[0] = fatent->bhs[1] = NULL;
274b522412aSAl Viro 	fatent->fat_inode = NULL;
2759e975daeSOGAWA Hirofumi }
2769e975daeSOGAWA Hirofumi 
2779e975daeSOGAWA Hirofumi static inline void fatent_set_entry(struct fat_entry *fatent, int entry)
2789e975daeSOGAWA Hirofumi {
2799e975daeSOGAWA Hirofumi 	fatent->entry = entry;
2809e975daeSOGAWA Hirofumi 	fatent->u.ent32_p = NULL;
2819e975daeSOGAWA Hirofumi }
2829e975daeSOGAWA Hirofumi 
2839e975daeSOGAWA Hirofumi static inline void fatent_brelse(struct fat_entry *fatent)
2849e975daeSOGAWA Hirofumi {
2859e975daeSOGAWA Hirofumi 	int i;
2869e975daeSOGAWA Hirofumi 	fatent->u.ent32_p = NULL;
2879e975daeSOGAWA Hirofumi 	for (i = 0; i < fatent->nr_bhs; i++)
2889e975daeSOGAWA Hirofumi 		brelse(fatent->bhs[i]);
2899e975daeSOGAWA Hirofumi 	fatent->nr_bhs = 0;
2909e975daeSOGAWA Hirofumi 	fatent->bhs[0] = fatent->bhs[1] = NULL;
291b522412aSAl Viro 	fatent->fat_inode = NULL;
2929e975daeSOGAWA Hirofumi }
2939e975daeSOGAWA Hirofumi 
2949e975daeSOGAWA Hirofumi extern void fat_ent_access_init(struct super_block *sb);
2959e975daeSOGAWA Hirofumi extern int fat_ent_read(struct inode *inode, struct fat_entry *fatent,
2969e975daeSOGAWA Hirofumi 			int entry);
2979e975daeSOGAWA Hirofumi extern int fat_ent_write(struct inode *inode, struct fat_entry *fatent,
2989e975daeSOGAWA Hirofumi 			 int new, int wait);
2999e975daeSOGAWA Hirofumi extern int fat_alloc_clusters(struct inode *inode, int *cluster,
3009e975daeSOGAWA Hirofumi 			      int nr_cluster);
3019e975daeSOGAWA Hirofumi extern int fat_free_clusters(struct inode *inode, int cluster);
3029e975daeSOGAWA Hirofumi extern int fat_count_free_clusters(struct super_block *sb);
3039e975daeSOGAWA Hirofumi 
3049e975daeSOGAWA Hirofumi /* fat/file.c */
3057845bc3eSArnd Bergmann extern long fat_generic_ioctl(struct file *filp, unsigned int cmd,
3067845bc3eSArnd Bergmann 			      unsigned long arg);
3079e975daeSOGAWA Hirofumi extern const struct file_operations fat_file_operations;
3089e975daeSOGAWA Hirofumi extern const struct inode_operations fat_file_inode_operations;
3099e975daeSOGAWA Hirofumi extern int fat_setattr(struct dentry * dentry, struct iattr * attr);
310459f6ed3Snpiggin@suse.de extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
3119e975daeSOGAWA Hirofumi extern int fat_getattr(struct vfsmount *mnt, struct dentry *dentry,
3129e975daeSOGAWA Hirofumi 		       struct kstat *stat);
31302c24a82SJosef Bacik extern int fat_file_fsync(struct file *file, loff_t start, loff_t end,
31402c24a82SJosef Bacik 			  int datasync);
3159e975daeSOGAWA Hirofumi 
3169e975daeSOGAWA Hirofumi /* fat/inode.c */
3179e975daeSOGAWA Hirofumi extern void fat_attach(struct inode *inode, loff_t i_pos);
3189e975daeSOGAWA Hirofumi extern void fat_detach(struct inode *inode);
3199e975daeSOGAWA Hirofumi extern struct inode *fat_iget(struct super_block *sb, loff_t i_pos);
3209e975daeSOGAWA Hirofumi extern struct inode *fat_build_inode(struct super_block *sb,
3219e975daeSOGAWA Hirofumi 			struct msdos_dir_entry *de, loff_t i_pos);
3229e975daeSOGAWA Hirofumi extern int fat_sync_inode(struct inode *inode);
3239e975daeSOGAWA Hirofumi extern int fat_fill_super(struct super_block *sb, void *data, int silent,
3243d23985dSAl Viro 			  int isvfat, void (*setup)(struct super_block *));
3259e975daeSOGAWA Hirofumi 
3269e975daeSOGAWA Hirofumi extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
3279e975daeSOGAWA Hirofumi 		            struct inode *i2);
3289e975daeSOGAWA Hirofumi /* fat/misc.c */
329b9075fa9SJoe Perches extern __printf(3, 4) __cold
330b9075fa9SJoe Perches void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...);
3312c8a5ffbSAlexey Fisher #define fat_fs_error(sb, fmt, args...)		\
3322c8a5ffbSAlexey Fisher 	__fat_fs_error(sb, 1, fmt , ## args)
3332c8a5ffbSAlexey Fisher #define fat_fs_error_ratelimit(sb, fmt, args...) \
3342c8a5ffbSAlexey Fisher 	__fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args)
335b9075fa9SJoe Perches __printf(3, 4) __cold
336b9075fa9SJoe Perches void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...);
337ed248b29SOGAWA Hirofumi extern int fat_clusters_flush(struct super_block *sb);
3389e975daeSOGAWA Hirofumi extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
3397decd1cbSOGAWA Hirofumi extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
3407decd1cbSOGAWA Hirofumi 			      __le16 __time, __le16 __date, u8 time_cs);
3417decd1cbSOGAWA Hirofumi extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts,
3427decd1cbSOGAWA Hirofumi 			      __le16 *time, __le16 *date, u8 *time_cs);
3439e975daeSOGAWA Hirofumi extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
3449e975daeSOGAWA Hirofumi 
3459e975daeSOGAWA Hirofumi int fat_cache_init(void);
3469e975daeSOGAWA Hirofumi void fat_cache_destroy(void);
3479e975daeSOGAWA Hirofumi 
348c3302931SOGAWA Hirofumi /* helper for printk */
349c3302931SOGAWA Hirofumi typedef unsigned long long	llu;
350c3302931SOGAWA Hirofumi 
3519e975daeSOGAWA Hirofumi #endif /* !_FAT_H */
352