exfat_fs.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
  4. */
  5. #ifndef _EXFAT_FS_H
  6. #define _EXFAT_FS_H
  7. #include <linux/fs.h>
  8. #include <linux/ratelimit.h>
  9. #include <linux/nls.h>
  10. #define EXFAT_ROOT_INO 1
  11. #define EXFAT_CLUSTERS_UNTRACKED (~0u)
  12. /*
  13. * exfat error flags
  14. */
  15. enum exfat_error_mode {
  16. EXFAT_ERRORS_CONT, /* ignore error and continue */
  17. EXFAT_ERRORS_PANIC, /* panic on error */
  18. EXFAT_ERRORS_RO, /* remount r/o on error */
  19. };
  20. /*
  21. * exfat nls lossy flag
  22. */
  23. enum {
  24. NLS_NAME_NO_LOSSY = 0, /* no lossy */
  25. NLS_NAME_LOSSY = 1 << 0, /* just detected incorrect filename(s) */
  26. NLS_NAME_OVERLEN = 1 << 1, /* the length is over than its limit */
  27. };
  28. #define EXFAT_HASH_BITS 8
  29. #define EXFAT_HASH_SIZE (1UL << EXFAT_HASH_BITS)
  30. /*
  31. * Type Definitions
  32. */
  33. #define ES_2_ENTRIES 2
  34. #define ES_ALL_ENTRIES 0
  35. #define DIR_DELETED 0xFFFFFFF7
  36. /* type values */
  37. #define TYPE_UNUSED 0x0000
  38. #define TYPE_DELETED 0x0001
  39. #define TYPE_INVALID 0x0002
  40. #define TYPE_CRITICAL_PRI 0x0100
  41. #define TYPE_BITMAP 0x0101
  42. #define TYPE_UPCASE 0x0102
  43. #define TYPE_VOLUME 0x0103
  44. #define TYPE_DIR 0x0104
  45. #define TYPE_FILE 0x011F
  46. #define TYPE_CRITICAL_SEC 0x0200
  47. #define TYPE_STREAM 0x0201
  48. #define TYPE_EXTEND 0x0202
  49. #define TYPE_ACL 0x0203
  50. #define TYPE_BENIGN_PRI 0x0400
  51. #define TYPE_GUID 0x0401
  52. #define TYPE_PADDING 0x0402
  53. #define TYPE_ACLTAB 0x0403
  54. #define TYPE_BENIGN_SEC 0x0800
  55. #define TYPE_ALL 0x0FFF
  56. #define MAX_CHARSET_SIZE 6 /* max size of multi-byte character */
  57. #define MAX_NAME_LENGTH 255 /* max len of file name excluding NULL */
  58. #define MAX_VFSNAME_BUF_SIZE ((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE)
  59. /* Enough size to hold 256 dentry (even 512 Byte sector) */
  60. #define DIR_CACHE_SIZE (256*sizeof(struct exfat_dentry)/512+1)
  61. #define EXFAT_HINT_NONE -1
  62. #define EXFAT_MIN_SUBDIR 2
  63. /*
  64. * helpers for cluster size to byte conversion.
  65. */
  66. #define EXFAT_CLU_TO_B(b, sbi) ((b) << (sbi)->cluster_size_bits)
  67. #define EXFAT_B_TO_CLU(b, sbi) ((b) >> (sbi)->cluster_size_bits)
  68. #define EXFAT_B_TO_CLU_ROUND_UP(b, sbi) \
  69. (((b - 1) >> (sbi)->cluster_size_bits) + 1)
  70. #define EXFAT_CLU_OFFSET(off, sbi) ((off) & ((sbi)->cluster_size - 1))
  71. /*
  72. * helpers for block size to byte conversion.
  73. */
  74. #define EXFAT_BLK_TO_B(b, sb) ((b) << (sb)->s_blocksize_bits)
  75. #define EXFAT_B_TO_BLK(b, sb) ((b) >> (sb)->s_blocksize_bits)
  76. #define EXFAT_B_TO_BLK_ROUND_UP(b, sb) \
  77. (((b - 1) >> (sb)->s_blocksize_bits) + 1)
  78. #define EXFAT_BLK_OFFSET(off, sb) ((off) & ((sb)->s_blocksize - 1))
  79. /*
  80. * helpers for block size to dentry size conversion.
  81. */
  82. #define EXFAT_B_TO_DEN_IDX(b, sbi) \
  83. ((b) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS))
  84. #define EXFAT_B_TO_DEN(b) ((b) >> DENTRY_SIZE_BITS)
  85. #define EXFAT_DEN_TO_B(b) ((b) << DENTRY_SIZE_BITS)
  86. /*
  87. * helpers for fat entry.
  88. */
  89. #define FAT_ENT_SIZE (4)
  90. #define FAT_ENT_SIZE_BITS (2)
  91. #define FAT_ENT_OFFSET_SECTOR(sb, loc) (EXFAT_SB(sb)->FAT1_start_sector + \
  92. (((u64)loc << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
  93. #define FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc) \
  94. ((loc << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
  95. /*
  96. * helpers for bitmap.
  97. */
  98. #define CLUSTER_TO_BITMAP_ENT(clu) ((clu) - EXFAT_RESERVED_CLUSTERS)
  99. #define BITMAP_ENT_TO_CLUSTER(ent) ((ent) + EXFAT_RESERVED_CLUSTERS)
  100. #define BITS_PER_SECTOR(sb) ((sb)->s_blocksize * BITS_PER_BYTE)
  101. #define BITS_PER_SECTOR_MASK(sb) (BITS_PER_SECTOR(sb) - 1)
  102. #define BITMAP_OFFSET_SECTOR_INDEX(sb, ent) \
  103. ((ent / BITS_PER_BYTE) >> (sb)->s_blocksize_bits)
  104. #define BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent) (ent & BITS_PER_SECTOR_MASK(sb))
  105. #define BITMAP_OFFSET_BYTE_IN_SECTOR(sb, ent) \
  106. ((ent / BITS_PER_BYTE) & ((sb)->s_blocksize - 1))
  107. #define BITS_PER_BYTE_MASK 0x7
  108. #define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
  109. struct exfat_dentry_namebuf {
  110. char *lfn;
  111. int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */
  112. };
  113. /* unicode name structure */
  114. struct exfat_uni_name {
  115. /* +3 for null and for converting */
  116. unsigned short name[MAX_NAME_LENGTH + 3];
  117. u16 name_hash;
  118. unsigned char name_len;
  119. };
  120. /* directory structure */
  121. struct exfat_chain {
  122. unsigned int dir;
  123. unsigned int size;
  124. unsigned char flags;
  125. };
  126. /* first empty entry hint information */
  127. struct exfat_hint_femp {
  128. /* entry index of a directory */
  129. int eidx;
  130. /* count of continuous empty entry */
  131. int count;
  132. /* the cluster that first empty slot exists in */
  133. struct exfat_chain cur;
  134. };
  135. /* hint structure */
  136. struct exfat_hint {
  137. unsigned int clu;
  138. union {
  139. unsigned int off; /* cluster offset */
  140. int eidx; /* entry index */
  141. };
  142. };
  143. struct exfat_entry_set_cache {
  144. struct super_block *sb;
  145. bool modified;
  146. unsigned int start_off;
  147. int num_bh;
  148. struct buffer_head *bh[DIR_CACHE_SIZE];
  149. unsigned int num_entries;
  150. };
  151. struct exfat_dir_entry {
  152. struct exfat_chain dir;
  153. int entry;
  154. unsigned int type;
  155. unsigned int start_clu;
  156. unsigned char flags;
  157. unsigned short attr;
  158. loff_t size;
  159. unsigned int num_subdirs;
  160. struct timespec64 atime;
  161. struct timespec64 mtime;
  162. struct timespec64 crtime;
  163. struct exfat_dentry_namebuf namebuf;
  164. };
  165. /*
  166. * exfat mount in-memory data
  167. */
  168. struct exfat_mount_options {
  169. kuid_t fs_uid;
  170. kgid_t fs_gid;
  171. unsigned short fs_fmask;
  172. unsigned short fs_dmask;
  173. /* permission for setting the [am]time */
  174. unsigned short allow_utime;
  175. /* charset for filename input/display */
  176. char *iocharset;
  177. /* on error: continue, panic, remount-ro */
  178. enum exfat_error_mode errors;
  179. unsigned utf8:1, /* Use of UTF-8 character set */
  180. sys_tz:1, /* Use local timezone */
  181. discard:1, /* Issue discard requests on deletions */
  182. keep_last_dots:1; /* Keep trailing periods in paths */
  183. int time_offset; /* Offset of timestamps from UTC (in minutes) */
  184. };
  185. /*
  186. * EXFAT file system superblock in-memory data
  187. */
  188. struct exfat_sb_info {
  189. unsigned long long num_sectors; /* num of sectors in volume */
  190. unsigned int num_clusters; /* num of clusters in volume */
  191. unsigned int cluster_size; /* cluster size in bytes */
  192. unsigned int cluster_size_bits;
  193. unsigned int sect_per_clus; /* cluster size in sectors */
  194. unsigned int sect_per_clus_bits;
  195. unsigned long long FAT1_start_sector; /* FAT1 start sector */
  196. unsigned long long FAT2_start_sector; /* FAT2 start sector */
  197. unsigned long long data_start_sector; /* data area start sector */
  198. unsigned int num_FAT_sectors; /* num of FAT sectors */
  199. unsigned int root_dir; /* root dir cluster */
  200. unsigned int dentries_per_clu; /* num of dentries per cluster */
  201. unsigned int vol_flags; /* volume flags */
  202. unsigned int vol_flags_persistent; /* volume flags to retain */
  203. struct buffer_head *boot_bh; /* buffer_head of BOOT sector */
  204. unsigned int map_clu; /* allocation bitmap start cluster */
  205. unsigned int map_sectors; /* num of allocation bitmap sectors */
  206. struct buffer_head **vol_amap; /* allocation bitmap */
  207. unsigned short *vol_utbl; /* upcase table */
  208. unsigned int clu_srch_ptr; /* cluster search pointer */
  209. unsigned int used_clusters; /* number of used clusters */
  210. struct mutex s_lock; /* superblock lock */
  211. struct mutex bitmap_lock; /* bitmap lock */
  212. struct exfat_mount_options options;
  213. struct nls_table *nls_io; /* Charset used for input and display */
  214. struct ratelimit_state ratelimit;
  215. spinlock_t inode_hash_lock;
  216. struct hlist_head inode_hashtable[EXFAT_HASH_SIZE];
  217. struct rcu_head rcu;
  218. };
  219. #define EXFAT_CACHE_VALID 0
  220. /*
  221. * EXFAT file system inode in-memory data
  222. */
  223. struct exfat_inode_info {
  224. struct exfat_chain dir;
  225. int entry;
  226. unsigned int type;
  227. unsigned short attr;
  228. unsigned int start_clu;
  229. unsigned char flags;
  230. /*
  231. * the copy of low 32bit of i_version to check
  232. * the validation of hint_stat.
  233. */
  234. unsigned int version;
  235. /* hint for cluster last accessed */
  236. struct exfat_hint hint_bmap;
  237. /* hint for entry index we try to lookup next time */
  238. struct exfat_hint hint_stat;
  239. /* hint for first empty entry */
  240. struct exfat_hint_femp hint_femp;
  241. spinlock_t cache_lru_lock;
  242. struct list_head cache_lru;
  243. int nr_caches;
  244. /* for avoiding the race between alloc and free */
  245. unsigned int cache_valid_id;
  246. /*
  247. * NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access.
  248. * physically allocated size.
  249. */
  250. loff_t i_size_ondisk;
  251. /* block-aligned i_size (used in cont_write_begin) */
  252. loff_t i_size_aligned;
  253. /* on-disk position of directory entry or 0 */
  254. loff_t i_pos;
  255. /* hash by i_location */
  256. struct hlist_node i_hash_fat;
  257. /* protect bmap against truncate */
  258. struct rw_semaphore truncate_lock;
  259. struct inode vfs_inode;
  260. /* File creation time */
  261. struct timespec64 i_crtime;
  262. };
  263. static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
  264. {
  265. return sb->s_fs_info;
  266. }
  267. static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
  268. {
  269. return container_of(inode, struct exfat_inode_info, vfs_inode);
  270. }
  271. /*
  272. * If ->i_mode can't hold 0222 (i.e. ATTR_RO), we use ->i_attrs to
  273. * save ATTR_RO instead of ->i_mode.
  274. *
  275. * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
  276. * bit, it's just used as flag for app.
  277. */
  278. static inline int exfat_mode_can_hold_ro(struct inode *inode)
  279. {
  280. struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
  281. if (S_ISDIR(inode->i_mode))
  282. return 0;
  283. if ((~sbi->options.fs_fmask) & 0222)
  284. return 1;
  285. return 0;
  286. }
  287. /* Convert attribute bits and a mask to the UNIX mode. */
  288. static inline mode_t exfat_make_mode(struct exfat_sb_info *sbi,
  289. unsigned short attr, mode_t mode)
  290. {
  291. if ((attr & ATTR_READONLY) && !(attr & ATTR_SUBDIR))
  292. mode &= ~0222;
  293. if (attr & ATTR_SUBDIR)
  294. return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
  295. return (mode & ~sbi->options.fs_fmask) | S_IFREG;
  296. }
  297. /* Return the FAT attribute byte for this inode */
  298. static inline unsigned short exfat_make_attr(struct inode *inode)
  299. {
  300. unsigned short attr = EXFAT_I(inode)->attr;
  301. if (S_ISDIR(inode->i_mode))
  302. attr |= ATTR_SUBDIR;
  303. if (exfat_mode_can_hold_ro(inode) && !(inode->i_mode & 0222))
  304. attr |= ATTR_READONLY;
  305. return attr;
  306. }
  307. static inline void exfat_save_attr(struct inode *inode, unsigned short attr)
  308. {
  309. if (exfat_mode_can_hold_ro(inode))
  310. EXFAT_I(inode)->attr = attr & (ATTR_RWMASK | ATTR_READONLY);
  311. else
  312. EXFAT_I(inode)->attr = attr & ATTR_RWMASK;
  313. }
  314. static inline bool exfat_is_last_sector_in_cluster(struct exfat_sb_info *sbi,
  315. sector_t sec)
  316. {
  317. return ((sec - sbi->data_start_sector + 1) &
  318. ((1 << sbi->sect_per_clus_bits) - 1)) == 0;
  319. }
  320. static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi,
  321. unsigned int clus)
  322. {
  323. return ((sector_t)(clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) +
  324. sbi->data_start_sector;
  325. }
  326. static inline int exfat_sector_to_cluster(struct exfat_sb_info *sbi,
  327. sector_t sec)
  328. {
  329. return ((sec - sbi->data_start_sector) >> sbi->sect_per_clus_bits) +
  330. EXFAT_RESERVED_CLUSTERS;
  331. }
  332. static inline bool is_valid_cluster(struct exfat_sb_info *sbi,
  333. unsigned int clus)
  334. {
  335. return clus >= EXFAT_FIRST_CLUSTER && clus < sbi->num_clusters;
  336. }
  337. /* super.c */
  338. int exfat_set_volume_dirty(struct super_block *sb);
  339. int exfat_clear_volume_dirty(struct super_block *sb);
  340. /* fatent.c */
  341. #define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu)
  342. int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
  343. struct exfat_chain *p_chain, bool sync_bmap);
  344. int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain);
  345. int exfat_ent_get(struct super_block *sb, unsigned int loc,
  346. unsigned int *content);
  347. int exfat_ent_set(struct super_block *sb, unsigned int loc,
  348. unsigned int content);
  349. int exfat_count_ext_entries(struct super_block *sb, struct exfat_chain *p_dir,
  350. int entry, struct exfat_dentry *p_entry);
  351. int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain,
  352. unsigned int len);
  353. int exfat_zeroed_cluster(struct inode *dir, unsigned int clu);
  354. int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
  355. unsigned int *ret_clu);
  356. int exfat_count_num_clusters(struct super_block *sb,
  357. struct exfat_chain *p_chain, unsigned int *ret_count);
  358. /* balloc.c */
  359. int exfat_load_bitmap(struct super_block *sb);
  360. void exfat_free_bitmap(struct exfat_sb_info *sbi);
  361. int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync);
  362. void exfat_clear_bitmap(struct inode *inode, unsigned int clu, bool sync);
  363. unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
  364. int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);
  365. int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);
  366. /* file.c */
  367. extern const struct file_operations exfat_file_operations;
  368. int __exfat_truncate(struct inode *inode, loff_t new_size);
  369. void exfat_truncate(struct inode *inode, loff_t size);
  370. int exfat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
  371. struct iattr *attr);
  372. int exfat_getattr(struct user_namespace *mnt_userns, const struct path *path,
  373. struct kstat *stat, unsigned int request_mask,
  374. unsigned int query_flags);
  375. int exfat_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
  376. long exfat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
  377. long exfat_compat_ioctl(struct file *filp, unsigned int cmd,
  378. unsigned long arg);
  379. /* namei.c */
  380. extern const struct dentry_operations exfat_dentry_ops;
  381. extern const struct dentry_operations exfat_utf8_dentry_ops;
  382. /* cache.c */
  383. int exfat_cache_init(void);
  384. void exfat_cache_shutdown(void);
  385. void exfat_cache_inval_inode(struct inode *inode);
  386. int exfat_get_cluster(struct inode *inode, unsigned int cluster,
  387. unsigned int *fclus, unsigned int *dclus,
  388. unsigned int *last_dclus, int allow_eof);
  389. /* dir.c */
  390. extern const struct inode_operations exfat_dir_inode_operations;
  391. extern const struct file_operations exfat_dir_operations;
  392. unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
  393. int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
  394. int entry, unsigned int type, unsigned int start_clu,
  395. unsigned long long size);
  396. int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
  397. int entry, int num_entries, struct exfat_uni_name *p_uniname);
  398. int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,
  399. int entry, int order, int num_entries);
  400. int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,
  401. int entry);
  402. void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es);
  403. int exfat_calc_num_entries(struct exfat_uni_name *p_uniname);
  404. int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
  405. struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname,
  406. int num_entries, unsigned int type, struct exfat_hint *hint_opt);
  407. int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu);
  408. struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
  409. struct exfat_chain *p_dir, int entry, struct buffer_head **bh);
  410. struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es,
  411. int num);
  412. struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
  413. struct exfat_chain *p_dir, int entry, unsigned int type);
  414. int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
  415. int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);
  416. /* inode.c */
  417. extern const struct inode_operations exfat_file_inode_operations;
  418. void exfat_sync_inode(struct inode *inode);
  419. struct inode *exfat_build_inode(struct super_block *sb,
  420. struct exfat_dir_entry *info, loff_t i_pos);
  421. void exfat_hash_inode(struct inode *inode, loff_t i_pos);
  422. void exfat_unhash_inode(struct inode *inode);
  423. struct inode *exfat_iget(struct super_block *sb, loff_t i_pos);
  424. int __exfat_write_inode(struct inode *inode, int sync);
  425. int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
  426. void exfat_evict_inode(struct inode *inode);
  427. int exfat_block_truncate_page(struct inode *inode, loff_t from);
  428. /* exfat/nls.c */
  429. unsigned short exfat_toupper(struct super_block *sb, unsigned short a);
  430. int exfat_uniname_ncmp(struct super_block *sb, unsigned short *a,
  431. unsigned short *b, unsigned int len);
  432. int exfat_utf16_to_nls(struct super_block *sb,
  433. struct exfat_uni_name *uniname, unsigned char *p_cstring,
  434. int len);
  435. int exfat_nls_to_utf16(struct super_block *sb,
  436. const unsigned char *p_cstring, const int len,
  437. struct exfat_uni_name *uniname, int *p_lossy);
  438. int exfat_create_upcase_table(struct super_block *sb);
  439. void exfat_free_upcase_table(struct exfat_sb_info *sbi);
  440. /* exfat/misc.c */
  441. void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
  442. __printf(3, 4) __cold;
  443. #define exfat_fs_error(sb, fmt, args...) \
  444. __exfat_fs_error(sb, 1, fmt, ## args)
  445. #define exfat_fs_error_ratelimit(sb, fmt, args...) \
  446. __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
  447. fmt, ## args)
  448. /* expand to pr_*() with prefix */
  449. #define exfat_err(sb, fmt, ...) \
  450. pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
  451. #define exfat_warn(sb, fmt, ...) \
  452. pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
  453. #define exfat_info(sb, fmt, ...) \
  454. pr_info("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
  455. #define exfat_debug(sb, fmt, ...) \
  456. pr_debug("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
  457. void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
  458. u8 tz, __le16 time, __le16 date, u8 time_cs);
  459. void exfat_truncate_atime(struct timespec64 *ts);
  460. void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
  461. u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
  462. u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
  463. u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
  464. void exfat_update_bh(struct buffer_head *bh, int sync);
  465. int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync);
  466. void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
  467. unsigned int size, unsigned char flags);
  468. void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);
  469. #endif /* !_EXFAT_FS_H */