2 * Copyright 2011, Jérôme Duval, korli@users.berlios.de.
3 * Copyright 2014 Haiku, Inc. All Rights reserved.
5 * Distributed under the terms of the MIT License.
8 * Jérôme Duval, korli@users.berlios.de
9 * John Scipione, jscipione@gmail.com
17 #include <ByteOrder.h>
18 #include <fs_interface.h>
19 #include <KernelExport.h>
22 typedef uint64 fileblock_t
; // file block number
23 typedef uint64 fsblock_t
; // filesystem block number
25 typedef uint32 cluster_t
;
28 #define EXFAT_SUPER_BLOCK_OFFSET 0x0
31 struct exfat_super_block
{
37 uint32 first_fat_block
;
39 uint32 first_data_block
;
41 uint32 root_dir_cluster
;
47 uint8 blocks_per_cluster_shift
;
56 // implemented in Volume.cpp
57 uint64
FirstBlock() const { return B_LENDIAN_TO_HOST_INT64(first_block
); }
58 uint64
NumBlocks() const { return B_LENDIAN_TO_HOST_INT32(num_blocks
); }
59 uint32
FirstFatBlock() const
60 { return B_LENDIAN_TO_HOST_INT32(first_fat_block
); }
61 uint32
FatLength() const
62 { return B_LENDIAN_TO_HOST_INT32(fat_length
); }
63 uint32
FirstDataBlock() const
64 { return B_LENDIAN_TO_HOST_INT32(first_data_block
); }
65 uint32
ClusterCount() const
66 { return B_LENDIAN_TO_HOST_INT32(cluster_count
); }
67 uint32
RootDirCluster() const
68 { return B_LENDIAN_TO_HOST_INT32(root_dir_cluster
); }
69 uint32
SerialNumber() const
70 { return B_LENDIAN_TO_HOST_INT32(serial_number
); }
71 uint8
VersionMinor() const { return version_minor
; }
72 uint8
VersionMajor() const { return version_major
; }
73 uint16
Flags() const { return B_LENDIAN_TO_HOST_INT16(flags
); }
74 uint8
BlockShift() const { return block_shift
; }
75 uint8
BlocksPerClusterShift() const { return blocks_per_cluster_shift
; }
76 uint8
FatCount() const { return fat_count
; }
77 uint8
DriveSelect() const { return drive_select
; }
78 uint8
UsedPercent() const { return used_percent
; }
82 #define EXFAT_SUPER_BLOCK_MAGIC "EXFAT "
84 #define EXFAT_ENTRY_TYPE_NOT_IN_USE 0x03
85 #define EXFAT_ENTRY_TYPE_BITMAP 0x81
86 #define EXFAT_ENTRY_TYPE_UPPERCASE 0x82
87 #define EXFAT_ENTRY_TYPE_LABEL 0x83
88 #define EXFAT_ENTRY_TYPE_FILE 0x85
89 #define EXFAT_ENTRY_TYPE_GUID 0xa0
90 #define EXFAT_ENTRY_TYPE_FILEINFO 0xc0
91 #define EXFAT_ENTRY_TYPE_FILENAME 0xc1
92 #define EXFAT_CLUSTER_END 0xffffffff
93 #define EXFAT_ENTRY_ATTRIB_SUBDIR 0x10
95 #define EXFAT_ENTRY_FLAG_CONTIGUOUS 0x3
97 #define EXFAT_FILENAME_MAX_LENGTH 512
107 } _PACKED volume_label
;
114 } _PACKED volume_guid
;
119 uint32 start_cluster
;
121 } _PACKED bitmap_uppercase
;
127 uint16 creation_time
;
128 uint16 creation_date
;
129 uint16 modification_time
;
130 uint16 modification_date
;
133 uint8 creation_time_low
;
134 uint8 modification_time_low
;
136 uint16
ModificationTime() const
137 { return B_LENDIAN_TO_HOST_INT16(modification_time
); }
138 uint16
ModificationDate() const
139 { return B_LENDIAN_TO_HOST_INT16(modification_date
); }
140 uint16
AccessTime() const
141 { return B_LENDIAN_TO_HOST_INT16(access_time
); }
142 uint16
AccessDate() const
143 { return B_LENDIAN_TO_HOST_INT16(access_date
); }
144 uint16
CreationTime() const
145 { return B_LENDIAN_TO_HOST_INT16(creation_time
); }
146 uint16
CreationDate() const
147 { return B_LENDIAN_TO_HOST_INT16(creation_date
); }
148 uint16
Attribs() const
149 { return B_LENDIAN_TO_HOST_INT16(attribs
); }
150 void SetAttribs(uint16 newAttribs
)
151 { attribs
= B_HOST_TO_LENDIAN_INT16(newAttribs
); }
161 uint32 start_cluster
;
163 uint32
StartCluster() const
164 { return B_LENDIAN_TO_HOST_INT32(start_cluster
); }
165 void SetStartCluster(uint32 startCluster
)
166 { start_cluster
= B_HOST_TO_LENDIAN_INT32(startCluster
); }
167 bool IsContiguous() const
168 { return (flag
& EXFAT_ENTRY_FLAG_CONTIGUOUS
) != 0; }
169 void SetFlag(uint8 newFlag
)
172 { return B_LENDIAN_TO_HOST_INT64(size1
); }
183 bigtime_t last_notification
;
188 #define EXFAT_OPEN_MODE_USER_MASK 0x7fffffff
190 extern fs_volume_ops gExfatVolumeOps
;
191 extern fs_vnode_ops gExfatVnodeOps
;