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