Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef _EXFAT_FS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _EXFAT_FS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/ratelimit.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/nls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define EXFAT_SUPER_MAGIC       0x2011BAB0UL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define EXFAT_ROOT_INO		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #define EXFAT_CLUSTERS_UNTRACKED (~0u)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * exfat error flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) enum exfat_error_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	EXFAT_ERRORS_CONT,	/* ignore error and continue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	EXFAT_ERRORS_PANIC,	/* panic on error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	EXFAT_ERRORS_RO,	/* remount r/o on error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * exfat nls lossy flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	NLS_NAME_NO_LOSSY,	/* no lossy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	NLS_NAME_LOSSY,		/* just detected incorrect filename(s) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	NLS_NAME_OVERLEN,	/* the length is over than its limit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define EXFAT_HASH_BITS		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define EXFAT_HASH_SIZE		(1UL << EXFAT_HASH_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * Type Definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define ES_2_ENTRIES		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define ES_ALL_ENTRIES		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define DIR_DELETED		0xFFFF0321
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /* type values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define TYPE_UNUSED		0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define TYPE_DELETED		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define TYPE_INVALID		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define TYPE_CRITICAL_PRI	0x0100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #define TYPE_BITMAP		0x0101
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define TYPE_UPCASE		0x0102
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define TYPE_VOLUME		0x0103
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define TYPE_DIR		0x0104
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) #define TYPE_FILE		0x011F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define TYPE_CRITICAL_SEC	0x0200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) #define TYPE_STREAM		0x0201
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define TYPE_EXTEND		0x0202
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) #define TYPE_ACL		0x0203
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define TYPE_BENIGN_PRI		0x0400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define TYPE_GUID		0x0401
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define TYPE_PADDING		0x0402
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define TYPE_ACLTAB		0x0403
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) #define TYPE_BENIGN_SEC		0x0800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) #define TYPE_ALL		0x0FFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define MAX_CHARSET_SIZE	6 /* max size of multi-byte character */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define MAX_NAME_LENGTH		255 /* max len of file name excluding NULL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define MAX_VFSNAME_BUF_SIZE	((MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) /* Enough size to hold 256 dentry (even 512 Byte sector) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define DIR_CACHE_SIZE		(256*sizeof(struct exfat_dentry)/512+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define EXFAT_HINT_NONE		-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #define EXFAT_MIN_SUBDIR	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * helpers for cluster size to byte conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define EXFAT_CLU_TO_B(b, sbi)		((b) << (sbi)->cluster_size_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define EXFAT_B_TO_CLU(b, sbi)		((b) >> (sbi)->cluster_size_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define EXFAT_B_TO_CLU_ROUND_UP(b, sbi)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	(((b - 1) >> (sbi)->cluster_size_bits) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define EXFAT_CLU_OFFSET(off, sbi)	((off) & ((sbi)->cluster_size - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  * helpers for block size to byte conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) #define EXFAT_BLK_TO_B(b, sb)		((b) << (sb)->s_blocksize_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) #define EXFAT_B_TO_BLK(b, sb)		((b) >> (sb)->s_blocksize_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) #define EXFAT_B_TO_BLK_ROUND_UP(b, sb)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	(((b - 1) >> (sb)->s_blocksize_bits) + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #define EXFAT_BLK_OFFSET(off, sb)	((off) & ((sb)->s_blocksize - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  * helpers for block size to dentry size conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #define EXFAT_B_TO_DEN_IDX(b, sbi)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	((b) << ((sbi)->cluster_size_bits - DENTRY_SIZE_BITS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define EXFAT_B_TO_DEN(b)		((b) >> DENTRY_SIZE_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define EXFAT_DEN_TO_B(b)		((b) << DENTRY_SIZE_BITS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * helpers for fat entry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define FAT_ENT_SIZE (4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define FAT_ENT_SIZE_BITS (2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define FAT_ENT_OFFSET_SECTOR(sb, loc) (EXFAT_SB(sb)->FAT1_start_sector + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	(((u64)loc << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	((loc << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * helpers for bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define CLUSTER_TO_BITMAP_ENT(clu) ((clu) - EXFAT_RESERVED_CLUSTERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define BITMAP_ENT_TO_CLUSTER(ent) ((ent) + EXFAT_RESERVED_CLUSTERS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define BITS_PER_SECTOR(sb) ((sb)->s_blocksize * BITS_PER_BYTE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define BITS_PER_SECTOR_MASK(sb) (BITS_PER_SECTOR(sb) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define BITMAP_OFFSET_SECTOR_INDEX(sb, ent) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	((ent / BITS_PER_BYTE) >> (sb)->s_blocksize_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define BITMAP_OFFSET_BIT_IN_SECTOR(sb, ent) (ent & BITS_PER_SECTOR_MASK(sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define BITMAP_OFFSET_BYTE_IN_SECTOR(sb, ent) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	((ent / BITS_PER_BYTE) & ((sb)->s_blocksize - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #define BITS_PER_BYTE_MASK	0x7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #define IGNORED_BITS_REMAINED(clu, clu_base) ((1 << ((clu) - (clu_base))) - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct exfat_dentry_namebuf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	char *lfn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int lfnbuf_len; /* usually MAX_UNINAME_BUF_SIZE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* unicode name structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct exfat_uni_name {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	/* +3 for null and for converting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	unsigned short name[MAX_NAME_LENGTH + 3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	u16 name_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	unsigned char name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* directory structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct exfat_chain {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	unsigned int dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	unsigned int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	unsigned char flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /* first empty entry hint information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct exfat_hint_femp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	/* entry index of a directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	int eidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	/* count of continuous empty entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/* the cluster that first empty slot exists in */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct exfat_chain cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* hint structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct exfat_hint {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	unsigned int clu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		unsigned int off; /* cluster offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		int eidx; /* entry index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct exfat_entry_set_cache {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	bool modified;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	unsigned int start_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	int num_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct buffer_head *bh[DIR_CACHE_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	unsigned int num_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct exfat_dir_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	struct exfat_chain dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	int entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	unsigned int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	unsigned int start_clu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	unsigned char flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	unsigned short attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	loff_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	unsigned int num_subdirs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct timespec64 atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	struct timespec64 mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	struct timespec64 crtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct exfat_dentry_namebuf namebuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  * exfat mount in-memory data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct exfat_mount_options {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	kuid_t fs_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	kgid_t fs_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	unsigned short fs_fmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	unsigned short fs_dmask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	/* permission for setting the [am]time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	unsigned short allow_utime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	/* charset for filename input/display */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	char *iocharset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	/* on error: continue, panic, remount-ro */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	enum exfat_error_mode errors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	unsigned utf8:1, /* Use of UTF-8 character set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		 discard:1; /* Issue discard requests on deletions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	int time_offset; /* Offset of timestamps from UTC (in minutes) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * EXFAT file system superblock in-memory data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct exfat_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	unsigned long long num_sectors; /* num of sectors in volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	unsigned int num_clusters; /* num of clusters in volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	unsigned int cluster_size; /* cluster size in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	unsigned int cluster_size_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	unsigned int sect_per_clus; /* cluster size in sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	unsigned int sect_per_clus_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	unsigned long long FAT1_start_sector; /* FAT1 start sector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	unsigned long long FAT2_start_sector; /* FAT2 start sector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	unsigned long long data_start_sector; /* data area start sector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	unsigned int num_FAT_sectors; /* num of FAT sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	unsigned int root_dir; /* root dir cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	unsigned int dentries_per_clu; /* num of dentries per cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	unsigned int vol_flags; /* volume flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	unsigned int vol_flags_persistent; /* volume flags to retain */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	struct buffer_head *boot_bh; /* buffer_head of BOOT sector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	unsigned int map_clu; /* allocation bitmap start cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	unsigned int map_sectors; /* num of allocation bitmap sectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	struct buffer_head **vol_amap; /* allocation bitmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	unsigned short *vol_utbl; /* upcase table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	unsigned int clu_srch_ptr; /* cluster search pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	unsigned int used_clusters; /* number of used clusters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct mutex s_lock; /* superblock lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct exfat_mount_options options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	struct nls_table *nls_io; /* Charset used for input and display */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	struct ratelimit_state ratelimit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	spinlock_t inode_hash_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	struct hlist_head inode_hashtable[EXFAT_HASH_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #define EXFAT_CACHE_VALID	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)  * EXFAT file system inode in-memory data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct exfat_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	struct exfat_chain dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	int entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	unsigned int type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	unsigned short attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	unsigned int start_clu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	unsigned char flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	 * the copy of low 32bit of i_version to check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	 * the validation of hint_stat.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	unsigned int version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	/* hint for cluster last accessed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct exfat_hint hint_bmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	/* hint for entry index we try to lookup next time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	struct exfat_hint hint_stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	/* hint for first empty entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct exfat_hint_femp hint_femp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	spinlock_t cache_lru_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	struct list_head cache_lru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	int nr_caches;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	/* for avoiding the race between alloc and free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	unsigned int cache_valid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 * NOTE: i_size_ondisk is 64bits, so must hold ->inode_lock to access.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * physically allocated size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	loff_t i_size_ondisk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	/* block-aligned i_size (used in cont_write_begin) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	loff_t i_size_aligned;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	/* on-disk position of directory entry or 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	loff_t i_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	/* hash by i_location */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	struct hlist_node i_hash_fat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	/* protect bmap against truncate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	struct rw_semaphore truncate_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	/* File creation time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct timespec64 i_crtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static inline struct exfat_sb_info *EXFAT_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static inline struct exfat_inode_info *EXFAT_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	return container_of(inode, struct exfat_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * If ->i_mode can't hold 0222 (i.e. ATTR_RO), we use ->i_attrs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  * save ATTR_RO instead of ->i_mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  * If it's directory and !sbi->options.rodir, ATTR_RO isn't read-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * bit, it's just used as flag for app.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) static inline int exfat_mode_can_hold_ro(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	if (S_ISDIR(inode->i_mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	if ((~sbi->options.fs_fmask) & 0222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* Convert attribute bits and a mask to the UNIX mode. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static inline mode_t exfat_make_mode(struct exfat_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		unsigned short attr, mode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	if ((attr & ATTR_READONLY) && !(attr & ATTR_SUBDIR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		mode &= ~0222;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	if (attr & ATTR_SUBDIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		return (mode & ~sbi->options.fs_dmask) | S_IFDIR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	return (mode & ~sbi->options.fs_fmask) | S_IFREG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) /* Return the FAT attribute byte for this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) static inline unsigned short exfat_make_attr(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	unsigned short attr = EXFAT_I(inode)->attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	if (S_ISDIR(inode->i_mode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		attr |= ATTR_SUBDIR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	if (exfat_mode_can_hold_ro(inode) && !(inode->i_mode & 0222))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		attr |= ATTR_READONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	return attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) static inline void exfat_save_attr(struct inode *inode, unsigned short attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	if (exfat_mode_can_hold_ro(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		EXFAT_I(inode)->attr = attr & (ATTR_RWMASK | ATTR_READONLY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		EXFAT_I(inode)->attr = attr & ATTR_RWMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) static inline bool exfat_is_last_sector_in_cluster(struct exfat_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		sector_t sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	return ((sec - sbi->data_start_sector + 1) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		((1 << sbi->sect_per_clus_bits) - 1)) == 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) static inline sector_t exfat_cluster_to_sector(struct exfat_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		unsigned int clus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	return ((sector_t)(clus - EXFAT_RESERVED_CLUSTERS) << sbi->sect_per_clus_bits) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		sbi->data_start_sector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) static inline int exfat_sector_to_cluster(struct exfat_sb_info *sbi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		sector_t sec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	return ((sec - sbi->data_start_sector) >> sbi->sect_per_clus_bits) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		EXFAT_RESERVED_CLUSTERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) /* super.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) int exfat_set_volume_dirty(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) int exfat_clear_volume_dirty(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* fatent.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #define exfat_get_next_cluster(sb, pclu) exfat_ent_get(sb, *(pclu), pclu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		struct exfat_chain *p_chain, bool sync_bmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) int exfat_free_cluster(struct inode *inode, struct exfat_chain *p_chain);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) int exfat_ent_get(struct super_block *sb, unsigned int loc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		unsigned int *content);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) int exfat_ent_set(struct super_block *sb, unsigned int loc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		unsigned int content);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) int exfat_count_ext_entries(struct super_block *sb, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		int entry, struct exfat_dentry *p_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) int exfat_chain_cont_cluster(struct super_block *sb, unsigned int chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) int exfat_zeroed_cluster(struct inode *dir, unsigned int clu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) int exfat_find_last_cluster(struct super_block *sb, struct exfat_chain *p_chain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		unsigned int *ret_clu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) int exfat_count_num_clusters(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		struct exfat_chain *p_chain, unsigned int *ret_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) /* balloc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) int exfat_load_bitmap(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) void exfat_free_bitmap(struct exfat_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) int exfat_set_bitmap(struct inode *inode, unsigned int clu, bool sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) void exfat_clear_bitmap(struct inode *inode, unsigned int clu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) unsigned int exfat_find_free_bitmap(struct super_block *sb, unsigned int clu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /* file.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) extern const struct file_operations exfat_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) int __exfat_truncate(struct inode *inode, loff_t new_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) void exfat_truncate(struct inode *inode, loff_t size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) int exfat_setattr(struct dentry *dentry, struct iattr *attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) int exfat_getattr(const struct path *path, struct kstat *stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 		unsigned int request_mask, unsigned int query_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) int exfat_file_fsync(struct file *file, loff_t start, loff_t end, int datasync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) /* namei.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) extern const struct dentry_operations exfat_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) extern const struct dentry_operations exfat_utf8_dentry_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) /* cache.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) int exfat_cache_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) void exfat_cache_shutdown(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) void exfat_cache_inval_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int exfat_get_cluster(struct inode *inode, unsigned int cluster,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		unsigned int *fclus, unsigned int *dclus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		unsigned int *last_dclus, int allow_eof);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /* dir.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) extern const struct inode_operations exfat_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) extern const struct file_operations exfat_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) unsigned int exfat_get_entry_type(struct exfat_dentry *p_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) int exfat_init_dir_entry(struct inode *inode, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		int entry, unsigned int type, unsigned int start_clu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 		unsigned long long size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) int exfat_init_ext_entry(struct inode *inode, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		int entry, int num_entries, struct exfat_uni_name *p_uniname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) int exfat_remove_entries(struct inode *inode, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 		int entry, int order, int num_entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) int exfat_update_dir_chksum(struct inode *inode, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		int entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) void exfat_update_dir_chksum_with_entry_set(struct exfat_entry_set_cache *es);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) int exfat_calc_num_entries(struct exfat_uni_name *p_uniname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) int exfat_find_dir_entry(struct super_block *sb, struct exfat_inode_info *ei,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		struct exfat_chain *p_dir, struct exfat_uni_name *p_uniname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		int num_entries, unsigned int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) int exfat_alloc_new_dir(struct inode *inode, struct exfat_chain *clu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) int exfat_find_location(struct super_block *sb, struct exfat_chain *p_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 		int entry, sector_t *sector, int *offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) struct exfat_dentry *exfat_get_dentry(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		struct exfat_chain *p_dir, int entry, struct buffer_head **bh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		sector_t *sector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) struct exfat_dentry *exfat_get_dentry_cached(struct exfat_entry_set_cache *es,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		int num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) struct exfat_entry_set_cache *exfat_get_dentry_set(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 		struct exfat_chain *p_dir, int entry, unsigned int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) int exfat_free_dentry_set(struct exfat_entry_set_cache *es, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) int exfat_count_dir_entries(struct super_block *sb, struct exfat_chain *p_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) /* inode.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) extern const struct inode_operations exfat_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) void exfat_sync_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) struct inode *exfat_build_inode(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		struct exfat_dir_entry *info, loff_t i_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) void exfat_hash_inode(struct inode *inode, loff_t i_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) void exfat_unhash_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct inode *exfat_iget(struct super_block *sb, loff_t i_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) int exfat_write_inode(struct inode *inode, struct writeback_control *wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) void exfat_evict_inode(struct inode *inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) int exfat_block_truncate_page(struct inode *inode, loff_t from);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) /* exfat/nls.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) unsigned short exfat_toupper(struct super_block *sb, unsigned short a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) int exfat_uniname_ncmp(struct super_block *sb, unsigned short *a,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 		unsigned short *b, unsigned int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) int exfat_utf16_to_nls(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		struct exfat_uni_name *uniname, unsigned char *p_cstring,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) int exfat_nls_to_utf16(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 		const unsigned char *p_cstring, const int len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		struct exfat_uni_name *uniname, int *p_lossy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) int exfat_create_upcase_table(struct super_block *sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) void exfat_free_upcase_table(struct exfat_sb_info *sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) /* exfat/misc.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 		__printf(3, 4) __cold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) #define exfat_fs_error(sb, fmt, args...)          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		__exfat_fs_error(sb, 1, fmt, ## args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) #define exfat_fs_error_ratelimit(sb, fmt, args...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		__exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		fmt, ## args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		__printf(3, 4) __cold;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) #define exfat_err(sb, fmt, ...)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) #define exfat_warn(sb, fmt, ...)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) #define exfat_info(sb, fmt, ...)					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		u8 tz, __le16 time, __le16 date, u8 time_cs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) void exfat_truncate_atime(struct timespec64 *ts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) void exfat_set_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		u8 *tz, __le16 *time, __le16 *date, u8 *time_cs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) u16 exfat_calc_chksum16(void *data, int len, u16 chksum, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) void exfat_update_bh(struct buffer_head *bh, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) int exfat_update_bhs(struct buffer_head **bhs, int nr_bhs, int sync);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) void exfat_chain_set(struct exfat_chain *ec, unsigned int dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		unsigned int size, unsigned char flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) void exfat_chain_dup(struct exfat_chain *dup, struct exfat_chain *ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) #endif /* !_EXFAT_FS_H */