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