5 #include <linux/string.h>
8 #include <linux/hash.h>
11 #include <linux/msdos_fs.h>
16 #define VFAT_SFN_DISPLAY_LOWER 0x0001
17 #define VFAT_SFN_DISPLAY_WIN95 0x0002
18 #define VFAT_SFN_DISPLAY_WINNT 0x0004
19 #define VFAT_SFN_CREATE_WIN95 0x0100
20 #define VFAT_SFN_CREATE_WINNT 0x0200
22 #define FAT_ERRORS_CONT 1
23 #define FAT_ERRORS_PANIC 2
24 #define FAT_ERRORS_RO 3
54 #define FAT_HASH_BITS 8
55 #define FAT_HASH_SIZE (1UL << FAT_HASH_BITS)
99 #define FAT_CACHE_VALID 0
129 struct buffer_head *
bh;
149 static inline int fat_mode_can_hold_ro(
struct inode *
inode)
173 if (attrs & ATTR_DIR)
180 static inline u8 fat_make_attrs(
struct inode *inode)
182 u8 attrs = MSDOS_I(inode)->i_attrs;
185 if (fat_mode_can_hold_ro(inode) && !(inode->
i_mode &
S_IWUGO))
190 static inline void fat_save_attrs(
struct inode *inode,
u8 attrs)
192 if (fat_mode_can_hold_ro(inode))
195 MSDOS_I(inode)->i_attrs = attrs & (ATTR_UNUSED |
ATTR_RO);
198 static inline unsigned char fat_checksum(
const __u8 *
name)
200 unsigned char s = name[0];
215 static inline void fat16_towchar(
wchar_t *
dst,
const __u8 *
src,
size_t len)
219 *dst++ = src[0] | (src[1] << 8);
223 memcpy(dst, src, len * 2);
227 static inline int fat_get_start(
const struct msdos_sb_info *sbi,
236 static inline void fat_set_start(
struct msdos_dir_entry *de,
int cluster)
242 static inline void fatwchar_to16(
__u8 *dst,
const wchar_t *src,
size_t len)
246 dst[0] = *src & 0x00FF;
247 dst[1] = (*src & 0xFF00) >> 8;
252 memcpy(dst, src, len * 2);
259 int *fclus,
int *dclus);
261 unsigned long *mapped_blocks,
int create);
269 extern int fat_scan(
struct inode *dir,
const unsigned char *
name,
287 struct buffer_head *
bhs[2];
291 static inline void fatent_init(
struct fat_entry *fatent)
300 static inline void fatent_set_entry(
struct fat_entry *fatent,
int entry)
306 static inline void fatent_brelse(
struct fat_entry *fatent)
310 for (i = 0; i < fatent->
nr_bhs; i++)
311 brelse(fatent->
bhs[i]);
340 extern void fat_attach(
struct inode *inode, loff_t i_pos);
351 static inline unsigned long fat_dir_hash(
int logstart)
359 #define fat_fs_error(sb, fmt, args...) \
360 __fat_fs_error(sb, 1, fmt , ## args)
361 #define fat_fs_error_ratelimit(sb, fmt, args...) \
362 __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args)
365 #define fat_msg_ratelimit(sb, level, fmt, args...) \
367 if (__ratelimit(&MSDOS_SB(sb)->ratelimit)) \
368 fat_msg(sb, level, fmt, ## args); \
371 extern int fat_chain_add(
struct inode *inode,
int new_dclus,
int nr_cluster);
376 extern int fat_sync_bhs(
struct buffer_head **bhs,
int nr_bhs);
384 int fh_len,
int fh_type);
386 int fh_len,
int fh_type);
390 typedef unsigned long long llu;