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