1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 2 /* 3 * Copyright (C) 2012-2013 Samsung Electronics 3 * Copyright (C) 2012-2013 Samsung Electronics Co., Ltd. 4 */ 4 */ 5 5 6 #ifndef _EXFAT_RAW_H 6 #ifndef _EXFAT_RAW_H 7 #define _EXFAT_RAW_H 7 #define _EXFAT_RAW_H 8 8 9 #include <linux/types.h> 9 #include <linux/types.h> 10 10 11 #define BOOT_SIGNATURE 0xAA55 11 #define BOOT_SIGNATURE 0xAA55 12 #define EXBOOT_SIGNATURE 0xAA550000 12 #define EXBOOT_SIGNATURE 0xAA550000 13 #define STR_EXFAT "EXFAT " 13 #define STR_EXFAT "EXFAT " /* size should be 8 */ 14 14 15 #define EXFAT_MAX_FILE_LEN 255 15 #define EXFAT_MAX_FILE_LEN 255 16 16 17 #define VOLUME_DIRTY 0x0002 17 #define VOLUME_DIRTY 0x0002 18 #define MEDIA_FAILURE 0x0004 18 #define MEDIA_FAILURE 0x0004 19 19 20 #define EXFAT_EOF_CLUSTER 0xFFFFFFFFu 20 #define EXFAT_EOF_CLUSTER 0xFFFFFFFFu 21 #define EXFAT_BAD_CLUSTER 0xFFFFFFF7u 21 #define EXFAT_BAD_CLUSTER 0xFFFFFFF7u 22 #define EXFAT_FREE_CLUSTER 0 22 #define EXFAT_FREE_CLUSTER 0 23 /* Cluster 0, 1 are reserved, the first cluste 23 /* Cluster 0, 1 are reserved, the first cluster is 2 in the cluster heap. */ 24 #define EXFAT_RESERVED_CLUSTERS 2 24 #define EXFAT_RESERVED_CLUSTERS 2 25 #define EXFAT_FIRST_CLUSTER 2 25 #define EXFAT_FIRST_CLUSTER 2 26 #define EXFAT_DATA_CLUSTER_COUNT(sbi) \ 26 #define EXFAT_DATA_CLUSTER_COUNT(sbi) \ 27 ((sbi)->num_clusters - EXFAT_RESERVED_ 27 ((sbi)->num_clusters - EXFAT_RESERVED_CLUSTERS) 28 28 29 /* AllocationPossible and NoFatChain field in 29 /* AllocationPossible and NoFatChain field in GeneralSecondaryFlags Field */ 30 #define ALLOC_POSSIBLE 0x01 << 31 #define ALLOC_FAT_CHAIN 0x01 30 #define ALLOC_FAT_CHAIN 0x01 32 #define ALLOC_NO_FAT_CHAIN 0x03 31 #define ALLOC_NO_FAT_CHAIN 0x03 33 32 34 #define DENTRY_SIZE 32 /* director 33 #define DENTRY_SIZE 32 /* directory entry size */ 35 #define DENTRY_SIZE_BITS 5 34 #define DENTRY_SIZE_BITS 5 36 /* exFAT allows 8388608(256MB) directory entri 35 /* exFAT allows 8388608(256MB) directory entries */ 37 #define MAX_EXFAT_DENTRIES 8388608 36 #define MAX_EXFAT_DENTRIES 8388608 38 37 39 /* dentry types */ 38 /* dentry types */ 40 #define EXFAT_UNUSED 0x00 /* end 39 #define EXFAT_UNUSED 0x00 /* end of directory */ 41 #define EXFAT_DELETE (~0x80) 40 #define EXFAT_DELETE (~0x80) 42 #define IS_EXFAT_DELETED(x) ((x) < 0x80) / 41 #define IS_EXFAT_DELETED(x) ((x) < 0x80) /* deleted file (0x01~0x7F) */ 43 #define EXFAT_INVAL 0x80 /* inv 42 #define EXFAT_INVAL 0x80 /* invalid value */ 44 #define EXFAT_BITMAP 0x81 /* all 43 #define EXFAT_BITMAP 0x81 /* allocation bitmap */ 45 #define EXFAT_UPCASE 0x82 /* upc 44 #define EXFAT_UPCASE 0x82 /* upcase table */ 46 #define EXFAT_VOLUME 0x83 /* vol 45 #define EXFAT_VOLUME 0x83 /* volume label */ 47 #define EXFAT_FILE 0x85 /* fil 46 #define EXFAT_FILE 0x85 /* file or dir */ 48 #define EXFAT_GUID 0xA0 47 #define EXFAT_GUID 0xA0 49 #define EXFAT_PADDING 0xA1 48 #define EXFAT_PADDING 0xA1 50 #define EXFAT_ACLTAB 0xA2 49 #define EXFAT_ACLTAB 0xA2 51 #define EXFAT_STREAM 0xC0 /* str 50 #define EXFAT_STREAM 0xC0 /* stream entry */ 52 #define EXFAT_NAME 0xC1 /* fil 51 #define EXFAT_NAME 0xC1 /* file name entry */ 53 #define EXFAT_ACL 0xC2 /* str 52 #define EXFAT_ACL 0xC2 /* stream entry */ 54 #define EXFAT_VENDOR_EXT 0xE0 /* ven << 55 #define EXFAT_VENDOR_ALLOC 0xE1 /* ven << 56 53 57 #define IS_EXFAT_CRITICAL_PRI(x) (x < 0 54 #define IS_EXFAT_CRITICAL_PRI(x) (x < 0xA0) 58 #define IS_EXFAT_BENIGN_PRI(x) (x < 0 55 #define IS_EXFAT_BENIGN_PRI(x) (x < 0xC0) 59 #define IS_EXFAT_CRITICAL_SEC(x) (x < 0 56 #define IS_EXFAT_CRITICAL_SEC(x) (x < 0xE0) 60 57 61 /* checksum types */ 58 /* checksum types */ 62 #define CS_DIR_ENTRY 0 59 #define CS_DIR_ENTRY 0 63 #define CS_BOOT_SECTOR 1 60 #define CS_BOOT_SECTOR 1 64 #define CS_DEFAULT 2 61 #define CS_DEFAULT 2 65 62 66 /* file attributes */ 63 /* file attributes */ 67 #define EXFAT_ATTR_READONLY 0x0001 !! 64 #define ATTR_READONLY 0x0001 68 #define EXFAT_ATTR_HIDDEN 0x0002 !! 65 #define ATTR_HIDDEN 0x0002 69 #define EXFAT_ATTR_SYSTEM 0x0004 !! 66 #define ATTR_SYSTEM 0x0004 70 #define EXFAT_ATTR_VOLUME 0x0008 !! 67 #define ATTR_VOLUME 0x0008 71 #define EXFAT_ATTR_SUBDIR 0x0010 !! 68 #define ATTR_SUBDIR 0x0010 72 #define EXFAT_ATTR_ARCHIVE 0x0020 !! 69 #define ATTR_ARCHIVE 0x0020 73 !! 70 74 #define EXFAT_ATTR_RWMASK (EXFAT_ATTR_HI !! 71 #define ATTR_RWMASK (ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME | \ 75 EXFAT_ATTR_VO !! 72 ATTR_SUBDIR | ATTR_ARCHIVE) 76 EXFAT_ATTR_AR << 77 73 78 #define BOOTSEC_JUMP_BOOT_LEN 3 74 #define BOOTSEC_JUMP_BOOT_LEN 3 79 #define BOOTSEC_FS_NAME_LEN 8 75 #define BOOTSEC_FS_NAME_LEN 8 80 #define BOOTSEC_OLDBPB_LEN 53 76 #define BOOTSEC_OLDBPB_LEN 53 81 77 82 #define EXFAT_FILE_NAME_LEN 15 78 #define EXFAT_FILE_NAME_LEN 15 83 79 84 #define EXFAT_MIN_SECT_SIZE_BITS 80 #define EXFAT_MIN_SECT_SIZE_BITS 9 85 #define EXFAT_MAX_SECT_SIZE_BITS 81 #define EXFAT_MAX_SECT_SIZE_BITS 12 86 #define EXFAT_MAX_SECT_PER_CLUS_BITS(x) 82 #define EXFAT_MAX_SECT_PER_CLUS_BITS(x) (25 - (x)->sect_size_bits) 87 83 88 /* EXFAT: Main and Backup Boot Sector (512 byt 84 /* EXFAT: Main and Backup Boot Sector (512 bytes) */ 89 struct boot_sector { 85 struct boot_sector { 90 __u8 jmp_boot[BOOTSEC_JUMP_BOOT_LEN 86 __u8 jmp_boot[BOOTSEC_JUMP_BOOT_LEN]; 91 __u8 fs_name[BOOTSEC_FS_NAME_LEN]; 87 __u8 fs_name[BOOTSEC_FS_NAME_LEN]; 92 __u8 must_be_zero[BOOTSEC_OLDBPB_LE 88 __u8 must_be_zero[BOOTSEC_OLDBPB_LEN]; 93 __le64 partition_offset; 89 __le64 partition_offset; 94 __le64 vol_length; 90 __le64 vol_length; 95 __le32 fat_offset; 91 __le32 fat_offset; 96 __le32 fat_length; 92 __le32 fat_length; 97 __le32 clu_offset; 93 __le32 clu_offset; 98 __le32 clu_count; 94 __le32 clu_count; 99 __le32 root_cluster; 95 __le32 root_cluster; 100 __le32 vol_serial; 96 __le32 vol_serial; 101 __u8 fs_revision[2]; 97 __u8 fs_revision[2]; 102 __le16 vol_flags; 98 __le16 vol_flags; 103 __u8 sect_size_bits; 99 __u8 sect_size_bits; 104 __u8 sect_per_clus_bits; 100 __u8 sect_per_clus_bits; 105 __u8 num_fats; 101 __u8 num_fats; 106 __u8 drv_sel; 102 __u8 drv_sel; 107 __u8 percent_in_use; 103 __u8 percent_in_use; 108 __u8 reserved[7]; 104 __u8 reserved[7]; 109 __u8 boot_code[390]; 105 __u8 boot_code[390]; 110 __le16 signature; 106 __le16 signature; 111 } __packed; 107 } __packed; 112 108 113 struct exfat_dentry { 109 struct exfat_dentry { 114 __u8 type; 110 __u8 type; 115 union { 111 union { 116 struct { 112 struct { 117 __u8 num_ext; 113 __u8 num_ext; 118 __le16 checksum; 114 __le16 checksum; 119 __le16 attr; 115 __le16 attr; 120 __le16 reserved1; 116 __le16 reserved1; 121 __le16 create_time; 117 __le16 create_time; 122 __le16 create_date; 118 __le16 create_date; 123 __le16 modify_time; 119 __le16 modify_time; 124 __le16 modify_date; 120 __le16 modify_date; 125 __le16 access_time; 121 __le16 access_time; 126 __le16 access_date; 122 __le16 access_date; 127 __u8 create_time_cs; 123 __u8 create_time_cs; 128 __u8 modify_time_cs; 124 __u8 modify_time_cs; 129 __u8 create_tz; 125 __u8 create_tz; 130 __u8 modify_tz; 126 __u8 modify_tz; 131 __u8 access_tz; 127 __u8 access_tz; 132 __u8 reserved2[7]; 128 __u8 reserved2[7]; 133 } __packed file; /* file direc 129 } __packed file; /* file directory entry */ 134 struct { 130 struct { 135 __u8 flags; 131 __u8 flags; 136 __u8 reserved1; 132 __u8 reserved1; 137 __u8 name_len; 133 __u8 name_len; 138 __le16 name_hash; 134 __le16 name_hash; 139 __le16 reserved2; 135 __le16 reserved2; 140 __le64 valid_size; 136 __le64 valid_size; 141 __le32 reserved3; 137 __le32 reserved3; 142 __le32 start_clu; 138 __le32 start_clu; 143 __le64 size; 139 __le64 size; 144 } __packed stream; /* stream e 140 } __packed stream; /* stream extension directory entry */ 145 struct { 141 struct { 146 __u8 flags; 142 __u8 flags; 147 __le16 unicode_0_14[EX 143 __le16 unicode_0_14[EXFAT_FILE_NAME_LEN]; 148 } __packed name; /* file name 144 } __packed name; /* file name directory entry */ 149 struct { 145 struct { 150 __u8 flags; 146 __u8 flags; 151 __u8 reserved[18]; 147 __u8 reserved[18]; 152 __le32 start_clu; 148 __le32 start_clu; 153 __le64 size; 149 __le64 size; 154 } __packed bitmap; /* allocati 150 } __packed bitmap; /* allocation bitmap directory entry */ 155 struct { 151 struct { 156 __u8 reserved1[3]; 152 __u8 reserved1[3]; 157 __le32 checksum; 153 __le32 checksum; 158 __u8 reserved2[12]; 154 __u8 reserved2[12]; 159 __le32 start_clu; 155 __le32 start_clu; 160 __le64 size; 156 __le64 size; 161 } __packed upcase; /* up-case 157 } __packed upcase; /* up-case table directory entry */ 162 struct { << 163 __u8 flags; << 164 __u8 vendor_guid[16]; << 165 __u8 vendor_defined[14 << 166 } __packed vendor_ext; /* vend << 167 struct { << 168 __u8 flags; << 169 __u8 vendor_guid[16]; << 170 __u8 vendor_defined[2] << 171 __le32 start_clu; << 172 __le64 size; << 173 } __packed vendor_alloc; /* ve << 174 struct { << 175 __u8 flags; << 176 __u8 custom_defined[18 << 177 __le32 start_clu; << 178 __le64 size; << 179 } __packed generic_secondary; << 180 } __packed dentry; 158 } __packed dentry; 181 } __packed; 159 } __packed; 182 160 183 #define EXFAT_TZ_VALID (1 << 7) 161 #define EXFAT_TZ_VALID (1 << 7) 184 162 185 /* Jan 1 GMT 00:00:00 1980 */ 163 /* Jan 1 GMT 00:00:00 1980 */ 186 #define EXFAT_MIN_TIMESTAMP_SECS 315532800L 164 #define EXFAT_MIN_TIMESTAMP_SECS 315532800LL 187 /* Dec 31 GMT 23:59:59 2107 */ 165 /* Dec 31 GMT 23:59:59 2107 */ 188 #define EXFAT_MAX_TIMESTAMP_SECS 4354819199 166 #define EXFAT_MAX_TIMESTAMP_SECS 4354819199LL 189 167 190 #endif /* !_EXFAT_RAW_H */ 168 #endif /* !_EXFAT_RAW_H */ 191 169
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.