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