bus: mhi: core: Fix some error return code
[linux/fpc-iii.git] / fs / exfat / exfat_raw.h
blob2a841010e6490ccafd5d12844a48a93fc6ee4bbf
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd.
4 */
6 #ifndef _EXFAT_RAW_H
7 #define _EXFAT_RAW_H
9 #include <linux/types.h>
11 #define PBR_SIGNATURE 0xAA55
13 #define EXFAT_MAX_FILE_LEN 255
15 #define VOL_CLEAN 0x0000
16 #define VOL_DIRTY 0x0002
18 #define EXFAT_EOF_CLUSTER 0xFFFFFFFFu
19 #define EXFAT_BAD_CLUSTER 0xFFFFFFF7u
20 #define EXFAT_FREE_CLUSTER 0
21 /* Cluster 0, 1 are reserved, the first cluster is 2 in the cluster heap. */
22 #define EXFAT_RESERVED_CLUSTERS 2
23 #define EXFAT_FIRST_CLUSTER 2
24 #define EXFAT_DATA_CLUSTER_COUNT(sbi) \
25 ((sbi)->num_clusters - EXFAT_RESERVED_CLUSTERS)
27 /* AllocationPossible and NoFatChain field in GeneralSecondaryFlags Field */
28 #define ALLOC_FAT_CHAIN 0x01
29 #define ALLOC_NO_FAT_CHAIN 0x03
31 #define DENTRY_SIZE 32 /* directory entry size */
32 #define DENTRY_SIZE_BITS 5
33 /* exFAT allows 8388608(256MB) directory entries */
34 #define MAX_EXFAT_DENTRIES 8388608
36 /* dentry types */
37 #define EXFAT_UNUSED 0x00 /* end of directory */
38 #define EXFAT_DELETE (~0x80)
39 #define IS_EXFAT_DELETED(x) ((x) < 0x80) /* deleted file (0x01~0x7F) */
40 #define EXFAT_INVAL 0x80 /* invalid value */
41 #define EXFAT_BITMAP 0x81 /* allocation bitmap */
42 #define EXFAT_UPCASE 0x82 /* upcase table */
43 #define EXFAT_VOLUME 0x83 /* volume label */
44 #define EXFAT_FILE 0x85 /* file or dir */
45 #define EXFAT_GUID 0xA0
46 #define EXFAT_PADDING 0xA1
47 #define EXFAT_ACLTAB 0xA2
48 #define EXFAT_STREAM 0xC0 /* stream entry */
49 #define EXFAT_NAME 0xC1 /* file name entry */
50 #define EXFAT_ACL 0xC2 /* stream entry */
52 #define IS_EXFAT_CRITICAL_PRI(x) (x < 0xA0)
53 #define IS_EXFAT_BENIGN_PRI(x) (x < 0xC0)
54 #define IS_EXFAT_CRITICAL_SEC(x) (x < 0xE0)
56 /* checksum types */
57 #define CS_DIR_ENTRY 0
58 #define CS_PBR_SECTOR 1
59 #define CS_DEFAULT 2
61 /* file attributes */
62 #define ATTR_READONLY 0x0001
63 #define ATTR_HIDDEN 0x0002
64 #define ATTR_SYSTEM 0x0004
65 #define ATTR_VOLUME 0x0008
66 #define ATTR_SUBDIR 0x0010
67 #define ATTR_ARCHIVE 0x0020
69 #define ATTR_RWMASK (ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME | \
70 ATTR_SUBDIR | ATTR_ARCHIVE)
72 #define PBR64_JUMP_BOOT_LEN 3
73 #define PBR64_OEM_NAME_LEN 8
74 #define PBR64_RESERVED_LEN 53
76 #define EXFAT_FILE_NAME_LEN 15
78 /* EXFAT BIOS parameter block (64 bytes) */
79 struct bpb64 {
80 __u8 jmp_boot[PBR64_JUMP_BOOT_LEN];
81 __u8 oem_name[PBR64_OEM_NAME_LEN];
82 __u8 res_zero[PBR64_RESERVED_LEN];
83 } __packed;
85 /* EXFAT EXTEND BIOS parameter block (56 bytes) */
86 struct bsx64 {
87 __le64 vol_offset;
88 __le64 vol_length;
89 __le32 fat_offset;
90 __le32 fat_length;
91 __le32 clu_offset;
92 __le32 clu_count;
93 __le32 root_cluster;
94 __le32 vol_serial;
95 __u8 fs_version[2];
96 __le16 vol_flags;
97 __u8 sect_size_bits;
98 __u8 sect_per_clus_bits;
99 __u8 num_fats;
100 __u8 phy_drv_no;
101 __u8 perc_in_use;
102 __u8 reserved2[7];
103 } __packed;
105 /* EXFAT PBR[BPB+BSX] (120 bytes) */
106 struct pbr64 {
107 struct bpb64 bpb;
108 struct bsx64 bsx;
109 } __packed;
111 /* Common PBR[Partition Boot Record] (512 bytes) */
112 struct pbr {
113 union {
114 __u8 raw[64];
115 struct bpb64 f64;
116 } bpb;
117 union {
118 __u8 raw[56];
119 struct bsx64 f64;
120 } bsx;
121 __u8 boot_code[390];
122 __le16 signature;
123 } __packed;
125 struct exfat_dentry {
126 __u8 type;
127 union {
128 struct {
129 __u8 num_ext;
130 __le16 checksum;
131 __le16 attr;
132 __le16 reserved1;
133 __le16 create_time;
134 __le16 create_date;
135 __le16 modify_time;
136 __le16 modify_date;
137 __le16 access_time;
138 __le16 access_date;
139 __u8 create_time_ms;
140 __u8 modify_time_ms;
141 __u8 create_tz;
142 __u8 modify_tz;
143 __u8 access_tz;
144 __u8 reserved2[7];
145 } __packed file; /* file directory entry */
146 struct {
147 __u8 flags;
148 __u8 reserved1;
149 __u8 name_len;
150 __le16 name_hash;
151 __le16 reserved2;
152 __le64 valid_size;
153 __le32 reserved3;
154 __le32 start_clu;
155 __le64 size;
156 } __packed stream; /* stream extension directory entry */
157 struct {
158 __u8 flags;
159 __le16 unicode_0_14[EXFAT_FILE_NAME_LEN];
160 } __packed name; /* file name directory entry */
161 struct {
162 __u8 flags;
163 __u8 reserved[18];
164 __le32 start_clu;
165 __le64 size;
166 } __packed bitmap; /* allocation bitmap directory entry */
167 struct {
168 __u8 reserved1[3];
169 __le32 checksum;
170 __u8 reserved2[12];
171 __le32 start_clu;
172 __le64 size;
173 } __packed upcase; /* up-case table directory entry */
174 } __packed dentry;
175 } __packed;
177 #define EXFAT_TZ_VALID (1 << 7)
179 /* Jan 1 GMT 00:00:00 1980 */
180 #define EXFAT_MIN_TIMESTAMP_SECS 315532800LL
181 /* Dec 31 GMT 23:59:59 2107 */
182 #define EXFAT_MAX_TIMESTAMP_SECS 4354819199LL
184 #endif /* !_EXFAT_RAW_H */