1 /*
2  * The APFS volume superblock definition
3  *
4  * Copyright (C) 2018-2021, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _FSAPFS_VOLUME_SUPERBLOCK_H )
23 #define _FSAPFS_VOLUME_SUPERBLOCK_H
24 
25 #include <common.h>
26 #include <types.h>
27 
28 #if defined( __cplusplus )
29 extern "C" {
30 #endif
31 
32 typedef struct fsapfs_volume_superblock fsapfs_volume_superblock_t;
33 
34 struct fsapfs_volume_superblock
35 {
36 	/* The object checksum
37 	 * Consists of 8 bytes
38 	 */
39 	uint8_t object_checksum[ 8 ];
40 
41 	/* The object identifier
42 	 * Consists of 8 bytes
43 	 */
44 	uint8_t object_identifier[ 8 ];
45 
46 	/* The object transaction identifier
47 	 * Consists of 8 bytes
48 	 */
49 	uint8_t object_transaction_identifier[ 8 ];
50 
51 	/* The object type
52 	 * Consists of 4 bytes
53 	 */
54 	uint8_t object_type[ 4 ];
55 
56 	/* The object subtype
57 	 * Consists of 4 bytes
58 	 */
59 	uint8_t object_subtype[ 4 ];
60 
61 	/* The file system signature
62 	 * Consists of 4 bytes
63 	 * Contains: "APSB"
64 	 */
65 	uint8_t signature[ 4 ];
66 
67 	/* Unknown
68 	 * Consists of 4 bytes
69 	 */
70 	uint8_t unknown1[ 4 ];
71 
72 	/* Compatible features flags
73 	 * Consists of 8 bytes
74 	 */
75 	uint8_t compatible_features_flags[ 8 ];
76 
77 	/* Read only compatible features flags
78 	 * Consists of 8 bytes
79 	 */
80 	uint8_t read_only_compatible_features_flags[ 8 ];
81 
82 	/* Incompatible features flags
83 	 * Consists of 8 bytes
84 	 */
85 	uint8_t incompatible_features_flags[ 8 ];
86 
87 	/* Unknown
88 	 * Consists of 8 bytes
89 	 */
90 	uint8_t unknown5[ 8 ];
91 
92 	/* The number of reserved blocks
93 	 * Consists of 8 bytes
94 	 */
95 	uint8_t number_of_reserved_blocks[ 8 ];
96 
97 	/* The number of quota blocks
98 	 * Consists of 8 bytes
99 	 */
100 	uint8_t number_of_quota_blocks[ 8 ];
101 
102 	/* Unknown
103 	 * Consists of 8 bytes
104 	 */
105 	uint8_t unknown8[ 8 ];
106 
107 	/* Unknown
108 	 * Consists of 8 bytes
109 	 */
110 	uint8_t unknown9[ 8 ];
111 
112 	/* Unknown
113 	 * Consists of 4 bytes
114 	 */
115 	uint8_t unknown10[ 4 ];
116 
117 	/* Unknown
118 	 * Consists of 4 bytes
119 	 */
120 	uint8_t unknown11[ 4 ];
121 
122 	/* Unknown
123 	 * Consists of 4 bytes
124 	 */
125 	uint8_t unknown12[ 4 ];
126 
127 	/* The file system root tree object type
128 	 * Consists of 4 bytes
129 	 */
130 	uint8_t file_system_root_tree_object_type[ 4 ];
131 
132 	/* The extent-reference tree object type
133 	 * Consists of 8 bytes
134 	 */
135 	uint8_t extent_reference_tree_object_type[ 4 ];
136 
137 	/* The snapshot metadata tree object type
138 	 * Consists of 4 bytes
139 	 */
140 	uint8_t snapshot_metadata_tree_object_type[ 4 ];
141 
142 	/* The object map block number
143 	 * Consists of 8 bytes
144 	 */
145 	uint8_t object_map_block_number[ 8 ];
146 
147 	/* The file system root object identifier
148 	 * Consists of 8 bytes
149 	 */
150 	uint8_t file_system_root_object_identifier[ 8 ];
151 
152 	/* The extent-reference tree block number
153 	 * Consists of 8 bytes
154 	 */
155 	uint8_t extent_reference_tree_block_number[ 8 ];
156 
157 	/* The snapshot metadata tree block number
158 	 * Consists of 8 bytes
159 	 */
160 	uint8_t snapshot_metadata_tree_block_number[ 8 ];
161 
162 	/* Unknown
163 	 * Consists of 8 bytes
164 	 */
165 	uint8_t unknown20[ 8 ];
166 
167 	/* Unknown
168 	 * Consists of 8 bytes
169 	 */
170 	uint8_t unknown21[ 8 ];
171 
172 	/* The next file system object identifier
173 	 * Consists of 8 bytes
174 	 */
175 	uint8_t next_file_system_object_identifier[ 8 ];
176 
177 	/* Unknown
178 	 * Consists of 8 bytes
179 	 */
180 	uint8_t unknown23[ 8 ];
181 
182 	/* Unknown
183 	 * Consists of 8 bytes
184 	 */
185 	uint8_t unknown24[ 8 ];
186 
187 	/* Unknown
188 	 * Consists of 8 bytes
189 	 */
190 	uint8_t unknown25[ 8 ];
191 
192 	/* Unknown
193 	 * Consists of 8 bytes
194 	 */
195 	uint8_t unknown26[ 8 ];
196 
197 	/* Unknown
198 	 * Consists of 8 bytes
199 	 */
200 	uint8_t unknown27[ 8 ];
201 
202 	/* Unknown
203 	 * Consists of 8 bytes
204 	 */
205 	uint8_t unknown28[ 8 ];
206 
207 	/* Unknown
208 	 * Consists of 8 bytes
209 	 */
210 	uint8_t unknown29[ 8 ];
211 
212 	/* The volume identifier
213 	 * Consists of 16 bytes
214 	 * Contains an UUID
215 	 */
216 	uint8_t volume_identifier[ 16 ];
217 
218 	/* The volume (last) modification date and time
219 	 * Consists of 8 bytes
220 	 */
221 	uint8_t modification_time[ 8 ];
222 
223 	/* The volume flags
224 	 * Consists of 8 bytes
225 	 */
226 	uint8_t volume_flags[ 8 ];
227 
228 	/* Unknown
229 	 * Consists of 32 bytes
230 	 */
231 	uint8_t unknown32[ 32 ];
232 
233 	/* Unknown
234 	 * Consists of 8 bytes
235 	 */
236 	uint8_t unknown33[ 8 ];
237 
238 	/* Unknown
239 	 * Consists of 8 bytes
240 	 */
241 	uint8_t unknown34[ 8 ];
242 
243 	/* Unknown
244 	 * Consists of 32 bytes
245 	 */
246 	uint8_t unknown35[ 32 ];
247 
248 	/* Unknown
249 	 * Consists of 8 bytes
250 	 */
251 	uint8_t unknown36[ 8 ];
252 
253 	/* Unknown
254 	 * Consists of 8 bytes
255 	 */
256 	uint8_t unknown37[ 8 ];
257 
258 	/* Unknown
259 	 * Consists of 32 bytes
260 	 */
261 	uint8_t unknown38[ 32 ];
262 
263 	/* Unknown
264 	 * Consists of 8 bytes
265 	 */
266 	uint8_t unknown39[ 8 ];
267 
268 	/* Unknown
269 	 * Consists of 8 bytes
270 	 */
271 	uint8_t unknown40[ 8 ];
272 
273 	/* Unknown
274 	 * Consists of 32 bytes
275 	 */
276 	uint8_t unknown41[ 32 ];
277 
278 	/* Unknown
279 	 * Consists of 8 bytes
280 	 */
281 	uint8_t unknown42[ 8 ];
282 
283 	/* Unknown
284 	 * Consists of 8 bytes
285 	 */
286 	uint8_t unknown43[ 8 ];
287 
288 	/* Unknown
289 	 * Consists of 32 bytes
290 	 */
291 	uint8_t unknown44[ 32 ];
292 
293 	/* Unknown
294 	 * Consists of 8 bytes
295 	 */
296 	uint8_t unknown45[ 8 ];
297 
298 	/* Unknown
299 	 * Consists of 8 bytes
300 	 */
301 	uint8_t unknown46[ 8 ];
302 
303 	/* Unknown
304 	 * Consists of 32 bytes
305 	 */
306 	uint8_t unknown47[ 32 ];
307 
308 	/* Unknown
309 	 * Consists of 8 bytes
310 	 */
311 	uint8_t unknown48[ 8 ];
312 
313 	/* Unknown
314 	 * Consists of 8 bytes
315 	 */
316 	uint8_t unknown49[ 8 ];
317 
318 	/* Unknown
319 	 * Consists of 32 bytes
320 	 */
321 	uint8_t unknown50[ 32 ];
322 
323 	/* Unknown
324 	 * Consists of 8 bytes
325 	 */
326 	uint8_t unknown51[ 8 ];
327 
328 	/* Unknown
329 	 * Consists of 8 bytes
330 	 */
331 	uint8_t unknown52[ 8 ];
332 
333 	/* Unknown
334 	 * Consists of 32 bytes
335 	 */
336 	uint8_t unknown53[ 32 ];
337 
338 	/* Unknown
339 	 * Consists of 8 bytes
340 	 */
341 	uint8_t unknown54[ 8 ];
342 
343 	/* Unknown
344 	 * Consists of 8 bytes
345 	 */
346 	uint8_t unknown55[ 8 ];
347 
348 	/* Unknown
349 	 * Consists of 32 bytes
350 	 */
351 	uint8_t unknown56[ 32 ];
352 
353 	/* Unknown
354 	 * Consists of 8 bytes
355 	 */
356 	uint8_t unknown57[ 8 ];
357 
358 	/* Unknown
359 	 * Consists of 8 bytes
360 	 */
361 	uint8_t unknown58[ 8 ];
362 
363 	/* The volume name
364 	 * Consists of 256 bytes
365 	 */
366 	uint8_t volume_name[ 256 ];
367 
368 	/* The next (available) document identifier
369 	 * Consists of 4 bytes
370 	 */
371 	uint8_t next_document_identifier[ 4 ];
372 
373 	/* Unknown
374 	 * Consists of 4 bytes
375 	 */
376 	uint8_t unknown60[ 4 ];
377 
378 	/* Unknown
379 	 * Consists of 8 bytes
380 	 */
381 	uint8_t unknown61[ 8 ];
382 
383 	/* Unknown
384 	 * Consists of 32 bytes
385 	 */
386 	uint8_t unknown62[ 32 ];
387 };
388 
389 #if defined( __cplusplus )
390 }
391 #endif
392 
393 #endif /* !defined( _FSAPFS_VOLUME_SUPERBLOCK_H ) */
394 
395