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