1 /* 2 * The HFS B-tree definitions 3 * 4 * Copyright (C) 2009-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( _FSHFS_BTREE_H ) 23 #define _FSHFS_BTREE_H 24 25 #include <common.h> 26 #include <types.h> 27 28 #if defined( __cplusplus ) 29 extern "C" { 30 #endif 31 32 typedef struct fshfs_btree_node_descriptor fshfs_btree_node_descriptor_t; 33 34 struct fshfs_btree_node_descriptor 35 { 36 /* The next node number 37 * Consists of 4 bytes 38 */ 39 uint8_t next_node_number[ 4 ]; 40 41 /* The previous node number 42 * Consists of 4 bytes 43 */ 44 uint8_t previous_node_number[ 4 ]; 45 46 /* The node type 47 * Consists of 1 byte 48 */ 49 uint8_t node_type; 50 51 /* The node level 52 * Consists of 1 byte 53 */ 54 uint8_t node_level; 55 56 /* The number of records 57 * Consists of 2 bytes 58 */ 59 uint8_t number_of_records[ 2 ]; 60 61 /* Unknown 62 * Consists of 2 bytes 63 */ 64 uint8_t unknown1[ 2 ]; 65 }; 66 67 typedef struct fshfs_btree_header_record fshfs_btree_header_record_t; 68 69 struct fshfs_btree_header_record 70 { 71 /* The depth 72 * Consists of 2 bytes 73 */ 74 uint8_t depth[ 2 ]; 75 76 /* The root node number 77 * Consists of 4 bytes 78 */ 79 uint8_t root_node_number[ 4 ]; 80 81 /* The number of data records 82 * Consists of 4 bytes 83 */ 84 uint8_t number_of_data_records[ 4 ]; 85 86 /* The first leaf node number 87 * Consists of 4 bytes 88 */ 89 uint8_t first_leaf_node_number[ 4 ]; 90 91 /* The last leaf node number 92 * Consists of 4 bytes 93 */ 94 uint8_t last_leaf_node_number[ 4 ]; 95 96 /* The node size 97 * Consists of 2 bytes 98 */ 99 uint8_t node_size[ 2 ]; 100 101 /* The maximum key size 102 * Consists of 2 bytes 103 */ 104 uint8_t maximum_key_size[ 2 ]; 105 106 /* The number of nodes 107 * Consists of 4 bytes 108 */ 109 uint8_t number_of_nodes[ 4 ]; 110 111 /* The number of free nodes 112 * Consists of 4 bytes 113 */ 114 uint8_t number_of_free_nodes[ 4 ]; 115 116 /* Unknown (Reserved) 117 * Consists of 2 bytes 118 */ 119 uint8_t unknown1[ 2 ]; 120 121 /* Introduced in HFS+ */ 122 123 /* The clump size 124 * Consists of 4 bytes 125 */ 126 uint8_t clump_size[ 4 ]; 127 128 /* The file type 129 * Consists of 1 byte 130 */ 131 uint8_t file_type; 132 133 /* The key compare type 134 * Consists of 1 byte 135 */ 136 uint8_t key_compare_type; 137 138 /* The attributes 139 * Consists of 4 bytes 140 */ 141 uint8_t attributes[ 4 ]; 142 143 /* Unknown (Reserved) 144 * Consists of 64 bytes 145 */ 146 uint8_t unknown2[ 64 ]; 147 }; 148 149 #if defined( __cplusplus ) 150 } 151 #endif 152 153 #endif /* !defined( _FSHFS_BTREE_H ) */ 154 155