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