1 /*
2  * The APFS container 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_CONTAINER_SUPERBLOCK_H )
23 #define _FSAPFS_CONTAINER_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_container_superblock fsapfs_container_superblock_t;
33 
34 struct fsapfs_container_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: "NXSB"
64 	 */
65 	uint8_t signature[ 4 ];
66 
67 	/* The block size
68 	 * Consists of 4 bytes
69 	 */
70 	uint8_t block_size[ 4 ];
71 
72 	/* The number of block
73 	 * Consists of 8 bytes
74 	 */
75 	uint8_t number_of_blocks[ 8 ];
76 
77 	/* Compatible features flags
78 	 * Consists of 8 bytes
79 	 */
80 	uint8_t compatible_features_flags[ 8 ];
81 
82 	/* Read only compatible features flags
83 	 * Consists of 8 bytes
84 	 */
85 	uint8_t read_only_compatible_features_flags[ 8 ];
86 
87 	/* Incompatible features flags
88 	 * Consists of 8 bytes
89 	 */
90 	uint8_t incompatible_features_flags[ 8 ];
91 
92 	/* The container identifier
93 	 * Consists of 16 bytes
94 	 * Contains an UUID
95 	 */
96 	uint8_t container_identifier[ 16 ];
97 
98 	/* The next object identifier
99 	 * Consists of 8 bytes
100 	 */
101 	uint8_t next_object_identifier[ 8 ];
102 
103 	/* The next transaction identifier
104 	 * Consists of 8 bytes
105 	 */
106 	uint8_t next_transaction_identifier[ 8 ];
107 
108 	/* The checkpoint descriptor area number of blocks
109 	 * Consists of 4 bytes
110 	 */
111 	uint8_t checkpoint_descriptor_area_number_of_blocks[ 4 ];
112 
113 	/* The checkpoint data area number of blocks
114 	 * Consists of 4 bytes
115 	 */
116 	uint8_t checkpoint_data_area_number_of_blocks[ 4 ];
117 
118 	/* The checkpoint descriptor area block number
119 	 * Consists of 8 bytes
120 	 */
121 	uint8_t checkpoint_descriptor_area_block_number[ 8 ];
122 
123 	/* The checkpoint data area block number
124 	 * Consists of 8 bytes
125 	 */
126 	uint8_t checkpoint_data_area_block_number[ 8 ];
127 
128 	/* Unknown
129 	 * Consists of 4 bytes
130 	 */
131 	uint8_t unknown8[ 4 ];
132 
133 	/* Unknown
134 	 * Consists of 4 bytes
135 	 */
136 	uint8_t unknown9[ 4 ];
137 
138 	/* Unknown
139 	 * Consists of 4 bytes
140 	 */
141 	uint8_t unknown10[ 4 ];
142 
143 	/* Unknown
144 	 * Consists of 4 bytes
145 	 */
146 	uint8_t unknown11[ 4 ];
147 
148 	/* Unknown
149 	 * Consists of 4 bytes
150 	 */
151 	uint8_t unknown12[ 4 ];
152 
153 	/* Unknown
154 	 * Consists of 4 bytes
155 	 */
156 	uint8_t unknown13[ 4 ];
157 
158 	/* The space manager object identifier
159 	 * Consists of 8 bytes
160 	 */
161 	uint8_t space_manager_object_identifier[ 8 ];
162 
163 	/* The object map block number
164 	 * Consists of 8 bytes
165 	 */
166 	uint8_t object_map_block_number[ 8 ];
167 
168 	/* The reaper object identifier
169 	 * Consists of 8 bytes
170 	 */
171 	uint8_t reaper_object_identifier[ 8 ];
172 
173 	/* Unknown
174 	 * Consists of 4 bytes
175 	 */
176 	uint8_t unknown17[ 4 ];
177 
178 	/* The maximum number of volumes
179 	 * Consists of 4 bytes
180 	 */
181 	uint8_t maximum_number_of_volumes[ 4 ];
182 
183 	/* The volume object identifiers
184 	 * Consists of 100 x 8 bytes
185 	 */
186 	uint8_t volume_object_identifiers[ 800 ];
187 
188 	/* The counters
189 	 * Consists of 32 x 8 bytes
190 	 */
191 	uint8_t counters[ 256 ];
192 
193 	/* Unknown
194 	 * Consists of 8 bytes
195 	 */
196 	uint8_t unknown20[ 8 ];
197 
198 	/* Unknown
199 	 * Consists of 8 bytes
200 	 */
201 	uint8_t unknown21[ 8 ];
202 
203 	/* Unknown
204 	 * Consists of 8 bytes
205 	 */
206 	uint8_t unknown22[ 8 ];
207 
208 	/* Unknown
209 	 * Consists of 8 bytes
210 	 */
211 	uint8_t unknown23[ 8 ];
212 
213 	/* Unknown
214 	 * Consists of 8 bytes
215 	 */
216 	uint8_t unknown24[ 8 ];
217 
218 	/* The Fusion set identifier
219 	 * Consists of 16 bytes
220 	 * Contains an UUID
221 	 */
222 	uint8_t fusion_set_identifier[ 16 ];
223 
224 	/* The key bag block number
225 	 * Consists of 8 bytes
226 	 */
227 	uint8_t key_bag_block_number[ 8 ];
228 
229 	/* The key bag number of blocks
230 	 * Consists of 8 bytes
231 	 */
232 	uint8_t key_bag_number_of_blocks[ 8 ];
233 
234 	/* Unknown
235 	 * Consists of 4 x 8 bytes
236 	 */
237 	uint8_t unknown29[ 32 ];
238 
239 	/* Unknown
240 	 * Consists of 8 bytes
241 	 */
242 	uint8_t unknown30[ 8 ];
243 
244 	/* The Fusion middle tree block number
245 	 * Consists of 8 bytes
246 	 */
247 	uint8_t fusion_middle_tree_block_number[ 8 ];
248 
249 	/* The Fusion write-back cache object identifier
250 	 * Consists of 8 bytes
251 	 */
252 	uint8_t fusion_write_back_cache_object_identifier[ 8 ];
253 
254 	/* Unknown
255 	 * Consists of 8 bytes
256 	 */
257 	uint8_t unknown33[ 8 ];
258 
259 	/* Unknown
260 	 * Consists of 8 bytes
261 	 */
262 	uint8_t unknown34[ 8 ];
263 };
264 
265 #if defined( __cplusplus )
266 }
267 #endif
268 
269 #endif /* !defined( _FSAPFS_CONTAINER_SUPERBLOCK_H ) */
270 
271