Lines Matching +full:cluster +full:- +full:mode
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
67 #define MAX_CHARSET_SIZE 6 /* max size of multi-byte character */
74 #define EXFAT_HINT_NONE -1
78 * helpers for cluster size to byte conversion.
80 #define EXFAT_CLU_TO_B(b, sbi) ((b) << (sbi)->cluster_size_bits)
81 #define EXFAT_B_TO_CLU(b, sbi) ((b) >> (sbi)->cluster_size_bits)
83 (((b - 1) >> (sbi)->cluster_size_bits) + 1)
84 #define EXFAT_CLU_OFFSET(off, sbi) ((off) & ((sbi)->cluster_size - 1))
89 #define EXFAT_BLK_TO_B(b, sb) ((b) << (sb)->s_blocksize_bits)
90 #define EXFAT_B_TO_BLK(b, sb) ((b) >> (sb)->s_blocksize_bits)
92 (((b - 1) >> (sb)->s_blocksize_bits) + 1)
93 #define EXFAT_BLK_OFFSET(off, sb) ((off) & ((sb)->s_blocksize - 1))
99 ((b) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS))
108 #define FAT_ENT_OFFSET_SECTOR(sb, loc) (EXFAT_SB(sb)->FAT1_start_sector + \
109 (((u64)loc << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
111 ((loc << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
116 #define CLUSTER_TO_BITMAP_ENT(clu) ((clu) - EXFAT_RESERVED_CLUSTERS)
118 #define BITS_PER_SECTOR(sb) ((sb)->s_blocksize * BITS_PER_BYTE)
119 #define BITS_PER_SECTOR_MASK(sb) (BITS_PER_SECTOR(sb) - 1)
121 ((ent / BITS_PER_BYTE) >> (sb)->s_blocksize_bits)
124 ((ent / BITS_PER_BYTE) & ((sb)->s_blocksize - 1))
126 #define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
154 /* the cluster that first empty slot exists in */
162 unsigned int off; /* cluster offset */
192 * exfat mount in-memory data
203 /* on error: continue, panic, remount-ro */
205 unsigned utf8:1, /* Use of UTF-8 character set */
213 * EXFAT file system superblock in-memory data
218 unsigned int cluster_size; /* cluster size in bytes */
220 unsigned int sect_per_clus; /* cluster size in sectors */
226 unsigned int root_dir; /* root dir cluster */
227 unsigned int dentries_per_clu; /* num of dentries per cluster */
232 unsigned int map_clu; /* allocation bitmap start cluster */
238 unsigned int clu_srch_ptr; /* cluster search pointer */
256 * EXFAT file system inode in-memory data
271 /* hint for cluster last accessed */
285 * NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access.
289 /* block-aligned i_size (used in cont_write_begin) */
291 /* on-disk position of directory entry or 0 */
304 return sb->s_fs_info; in EXFAT_SB()
313 * If ->i_mode can't hold 0222 (i.e. ATTR_RO), we use ->i_attrs to
314 * save ATTR_RO instead of ->i_mode.
316 * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
321 struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb); in exfat_mode_can_hold_ro()
323 if (S_ISDIR(inode->i_mode)) in exfat_mode_can_hold_ro()
326 if ((~sbi->options.fs_fmask) & 0222) in exfat_mode_can_hold_ro()
331 /* Convert attribute bits and a mask to the UNIX mode. */
333 unsigned short attr, mode_t mode) in exfat_make_mode() argument
336 mode &= ~0222; in exfat_make_mode()
339 return (mode & ~sbi->options.fs_dmask) | S_IFDIR; in exfat_make_mode()
341 return (mode & ~sbi->options.fs_fmask) | S_IFREG; in exfat_make_mode()
347 unsigned short attr = EXFAT_I(inode)->attr; in exfat_make_attr()
349 if (S_ISDIR(inode->i_mode)) in exfat_make_attr()
351 if (exfat_mode_can_hold_ro(inode) && !(inode->i_mode & 0222)) in exfat_make_attr()
359 EXFAT_I(inode)->attr = attr & (ATTR_RWMASK | ATTR_READONLY); in exfat_save_attr()
361 EXFAT_I(inode)->attr = attr & ATTR_RWMASK; in exfat_save_attr()
367 return ((sec - sbi->data_start_sector + 1) & in exfat_is_last_sector_in_cluster()
368 ((1 << sbi->sect_per_clus_bits) - 1)) == 0; in exfat_is_last_sector_in_cluster()
374 return ((sector_t)(clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) + in exfat_cluster_to_sector()
375 sbi->data_start_sector; in exfat_cluster_to_sector()
381 return ((sec - sbi->data_start_sector) >> sbi->sect_per_clus_bits) + in exfat_sector_to_cluster()
388 return clus >= EXFAT_FIRST_CLUSTER && clus < sbi->num_clusters; in is_valid_cluster()
446 int exfat_get_cluster(struct inode *inode, unsigned int cluster,
510 __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
515 pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
517 pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
519 pr_info("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
521 pr_debug("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)