|
|
1.1 ! root 1: /* ! 2: * libhfsp - library for reading and writing Macintosh HFS+ volumes ! 3: * ! 4: * This file includes definitions for the structures found on ! 5: * HFS+ Volumes. The structures are further wrapped by struct ! 6: * found in libhfsp.h. fucntions on those enhanced structures ! 7: * are found in files mentioned in comments below. ! 8: * ! 9: * Copyright (C) 2000 Klaus Halfmann <[email protected]> ! 10: * Original code 1996-1998 by Robert Leslie <[email protected]> ! 11: * other work 2000 from Brad Boyer ([email protected]) ! 12: * ! 13: * This program is free software; you can redistribute it and/or modify ! 14: * it under the terms of the GNU General Public License as published by ! 15: * the Free Software Foundation; either version 2 of the License, or ! 16: * (at your option) any later version. ! 17: * ! 18: * This program is distributed in the hope that it will be useful, ! 19: * but WITHOUT ANY WARRANTY; without even the implied warranty of ! 20: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! 21: * GNU General Public License for more details. ! 22: * ! 23: * You should have received a copy of the GNU General Public License ! 24: * along with this program; if not, write to the Free Software ! 25: * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, ! 26: * MA 02110-1301, USA. ! 27: * ! 28: * $Id: hfsp.h,v 1.17 2000/10/20 06:16:52 hasi Exp $ ! 29: */ ! 30: ! 31: #define HFSP_BLOCKSZ 512 /* A sector for Apple is always 512 bytes */ ! 32: #define HFSP_BLOCKSZ_BITS 9 /* 1<<9 == 512 */ ! 33: #define HFSP_VOLHEAD_SIG 0x482B /* 'H+' */ ! 34: ! 35: /* HFS+ includes POSIX permissions , although marked as reserved they will be ! 36: * used as such. Is ignored by MacOS 8-9 but probably not by MacOS X. ! 37: */ ! 38: typedef struct { ! 39: UInt32 owner; ! 40: UInt32 group; ! 41: UInt32 mode; ! 42: UInt32 dev; ! 43: } hfsp_perm; ! 44: ! 45: /* A single contiguous area (fragment) of a file */ ! 46: typedef struct { ! 47: UInt32 start_block; ! 48: UInt32 block_count; ! 49: } hfsp_extent; ! 50: ! 51: /* A file may contain up to 8 normale extents, all other ! 52: are found in some extra extent area */ ! 53: typedef hfsp_extent hfsp_extent_rec[8]; ! 54: ! 55: /* Information for a "Fork" in a file ! 56: * Forks are the "usual" DATA and RSRC forks or special files ! 57: * (e.g. the Volume Bitmap) ! 58: */ ! 59: typedef struct { ! 60: UInt64 total_size; // logical size ! 61: UInt32 clump_size; // number of bytes to preallocate ! 62: UInt32 total_blocks; ! 63: hfsp_extent_rec extents; // initial (8) extents ! 64: } hfsp_fork_raw; ! 65: ! 66: /* HFS+ Volume Header ! 67: * Always found at block 2 of the disk, a copy is stored ! 68: * at the second to last block of the disk. ! 69: */ ! 70: typedef struct hfsp_vh { ! 71: UInt16 signature; // must be HFSPLUS_VOLHEAD_SIG 'H+' ! 72: UInt16 version; // currently 4, ignored ! 73: UInt32 attributes; // See bit constants below ! 74: UInt32 last_mount_vers; ! 75: // Use a registered creator code here (what do we use ?) ! 76: // Mac OS uses '8.10' well ! 77: UInt32 reserved; ! 78: ! 79: UInt32 create_date; // local time ! ! 80: UInt32 modify_date; // GMT (?) ! 81: UInt32 backup_date; // GMT (?) ! 82: UInt32 checked_date; // GMT (?) fsck ? ! 83: ! 84: UInt32 file_count; ! 85: // not including special files but including DATA and RSRC forks ! 86: UInt32 folder_count; // excluding the root folder ! 87: ! 88: UInt32 blocksize; ! 89: // must be multiple of HFSPLUS_SECTOR_SIZE, ! 90: // should be a multiple of 4k for harddisk ! 91: UInt32 total_blocks; ! 92: UInt32 free_blocks; ! 93: // The total number of unused allocation blocks on the disk. ! 94: ! 95: UInt32 next_alloc; ! 96: // hint wher to search for next allocation blocks ! 97: UInt32 rsrc_clump_sz; ! 98: // default clump size for rsrc forks ! 99: UInt32 data_clump_sz; ! 100: // default clump size for data forks ! 101: UInt32 next_cnid; ! 102: // next unused catalog id ! 103: UInt32 write_count; ! 104: // increment on every mount (and write ?) ! 105: UInt64 encodings_bmp; ! 106: // for every encoding used on the disk a bit is set ! 107: // ignored but eventually must be cared for ! 108: Char finder_info[32]; ! 109: hfsp_fork_raw alloc_file; ! 110: // stores bitmap of use/free blocks ! 111: hfsp_fork_raw ext_file; ! 112: // stores oferflow extents ! 113: hfsp_fork_raw cat_file; ! 114: // This contains the root directory ! 115: hfsp_fork_raw attr_file; ! 116: hfsp_fork_raw start_file; ! 117: // a special startup file may be described here (used by ?) ! 118: } hfsp_vh; ! 119: ! 120: /* HFS+ volume attributes */ ! 121: /* 0-6 reserved, may be used in memory only */ ! 122: #define HFSPLUS_VOL_RESERVED1 0x000000FF ! 123: #define HFSPLUS_VOL_HARDLOCK 0x00000080 // Used in Memory by finder only ! 124: #define HFSPLUS_VOL_UNMNT 0x00000100 ! 125: // clear this bit when mounting, set as last step of unmounting ! 126: // This is checked by (slower) ROM code ! 127: #define HFSPLUS_VOL_SPARE_BLK 0x00000200 ! 128: #define HFSPLUS_VOL_NOCACHE 0x00000400 ! 129: // in case of RAM or ROM disk (try a HFS+ Ramdisk :) ! 130: #define HFSPLUS_VOL_INCNSTNT 0x00000800 ! 131: // Reverse meaning as of HFSPLUS_VOL_UNMNT ! 132: // This is checked by (faster) Mac OS code ! 133: /* 12-14 reserved */ ! 134: #define HFSPLUS_VOL_RESERVED2 0x00007000 ! 135: #define HFSPLUS_VOL_SOFTLOCK 0x00008000 ! 136: #define HFSPLUS_VOL_RESERVED3 0xFFFF0000 ! 137: ! 138: /* HFS+ Btree node descriptor */ ! 139: typedef struct { ! 140: UInt32 next; /* pointer to next node of this kind, or 0 */ ! 141: UInt32 prev; /* pointer to previous node of this kind, or 0 */ ! 142: UInt8 kind; /* see below */ ! 143: UInt8 height; /* root node starts with 0 */ ! 144: UInt16 num_rec; /* number of records in this node */ ! 145: UInt16 reserved; /* fill up to 4 byte alignment */ ! 146: } btree_node_desc; ! 147: ! 148: /* HFS+ Btree Node types */ ! 149: #define HFSP_NODE_NDX 0x00 ! 150: #define HFSP_NODE_HEAD 0x01 ! 151: #define HFSP_NODE_MAP 0x02 ! 152: #define HFSP_NODE_LEAF 0xFF ! 153: ! 154: #define HFSP_CATALOG_MIN_NODE_SIZE 0x1000 ! 155: #define HFSP_ATTRMIN_DOE_SIZE 0x1000 ! 156: ! 157: /* The record offsets are found at the end of the fork ! 158: * containing the Btree */ ! 159: ! 160: typedef UInt16 btree_record_offset; ! 161: ! 162: typedef struct { ! 163: UInt16 depth; ! 164: // equal to height of btree_node_desc ! 165: UInt32 root; ! 166: // root node of the hierarchy ! 167: UInt32 leaf_count; ! 168: UInt32 leaf_head; ! 169: UInt32 leaf_tail; ! 170: UInt16 node_size; ! 171: // node size of _all_ nodes in this fork ! 172: UInt16 max_key_len; ! 173: UInt32 node_count; ! 174: // count of all (free and used) nodes in tree ! 175: UInt32 free_nodes; ! 176: UInt16 reserved1; ! 177: UInt32 clump_size; ! 178: // ignored my MacOS used by ? ! 179: UInt8 btree_type; ! 180: // always 0 for HFS+ ! 181: UInt8 reserved2; ! 182: UInt32 attributes; ! 183: // see below ! 184: UInt32 reserved3[16]; ! 185: } btree_head; ! 186: ! 187: /* BTree attributes */ ! 188: #define HFSPLUS_BAD_CLOSE 0x01 ! 189: // Btree was not properly closed and should be checked ! 190: // not used for HFS+ but reserved ! 191: #define HFSPLUS_TREE_BIGKEYS 0x02 ! 192: // always set for HFS+ ! 193: #define HFSPLUS_TREE_VAR_NDXKEY_SIZE 0x04 ! 194: // use variable length index nodes, always set for catalog btree, ! 195: // always cleared for extents btree. ! 196: ! 197: #define HFSPLUS_TREE_UNUSED 0xFFFFFFF8 ! 198: ! 199: /* Some special File ID numbers */ ! 200: #define HFSP_POR_CNID 1 /* Parent Of the Root */ ! 201: #define HFSP_ROOT_CNID 2 /* ROOT directory */ ! 202: #define HFSP_EXT_CNID 3 /* EXTents B-tree */ ! 203: #define HFSP_CAT_CNID 4 /* CATalog B-tree */ ! 204: #define HFSP_BAD_CNID 5 /* BAD blocks file */ ! 205: #define HFSP_ALLOC_CNID 6 /* ALLOCation file */ ! 206: #define HFSP_START_CNID 7 /* STARTup file */ ! 207: #define HFSP_ATTR_CNID 8 /* ATTRibutes file */ ! 208: #define HFSP_EXCH_CNID 15 /* ExchangeFiles temp id */ ! 209: #define HFPS_MIN_CNID 15 /* Minimum expected value */ ! 210: ! 211: /* Unicode String */ ! 212: typedef struct { ! 213: UInt16 strlen; ! 214: UInt16 name[255]; // unicode charcters ! 215: } hfsp_unistr255; ! 216: ! 217: /* HFS+ catalog entry key */ ! 218: typedef struct { ! 219: UInt16 key_length; /* excluding length */ ! 220: UInt32 parent_cnid; ! 221: hfsp_unistr255 name; ! 222: } hfsp_cat_key; ! 223: ! 224: /* HFS+ exnteds entry key */ ! 225: typedef struct { ! 226: UInt16 key_length; /* excluding length */ ! 227: UInt8 fork_type; /* Seee below */ ! 228: UInt8 filler; ! 229: UInt32 file_id; ! 230: UInt32 start_block; ! 231: } hfsp_extent_key; ! 232: ! 233: #define HFSP_EXTENT_DATA 0x00 ! 234: #define HFSP_EXTENT_RSRC 0xFF ! 235: ! 236: /* The key is followed by a record, an index or some other data */ ! 237: ! 238: /* The types of these records are defined as follows */ ! 239: ! 240: #define HFSP_FOLDER 0x0001 // entry fo a Folder ! 241: #define HFSP_FILE 0x0002 // entry for a File ! 242: #define HFSP_FOLDER_THREAD 0x0003 ! 243: // Like '.' in unix, identifies the folder by its id, only ! 244: #define HFSP_FILE_THREAD 0x0004 ! 245: // Im unsure if this is used by HFS+, too ! 246: ! 247: /* HFS+ folder data (part of an hfsp_cat_entry) */ ! 248: typedef struct { ! 249: UInt16 flags; /* no flags defined yet */ ! 250: UInt32 valence; /* Numer of files and folders contained in folder */ ! 251: UInt32 id; ! 252: UInt32 create_date; // GMT ! 253: UInt32 content_mod_date; // GMT ! 254: UInt32 attribute_mod_date; // GMT ! 255: UInt32 access_date; // GMT ! 256: UInt32 backup_date; // GMT ! 257: hfsp_perm permissions; ! 258: DInfo user_info; ! 259: DXInfo finder_info; ! 260: UInt32 text_encoding; ! 261: // hint fo the finder what encoding to use, unused here ! 262: UInt32 reserved; ! 263: } hfsp_cat_folder; ! 264: ! 265: /* HFS+ file data (part of a cat_entry) */ ! 266: typedef struct { ! 267: UInt16 flags; /* See below */ ! 268: UInt32 reserved1; ! 269: UInt32 id; ! 270: UInt32 create_date; ! 271: UInt32 content_mod_date; ! 272: UInt32 attribute_mod_date; ! 273: UInt32 access_date; ! 274: UInt32 backup_date; ! 275: hfsp_perm permissions; ! 276: FInfo user_info; ! 277: FXInfo finder_info; ! 278: UInt32 text_encoding; ! 279: UInt32 reserved2; ! 280: ! 281: hfsp_fork_raw data_fork; ! 282: hfsp_fork_raw res_fork; ! 283: } hfsp_cat_file; ! 284: ! 285: /* File attribute bits */ ! 286: #define HFSP_FILE_LOCKED 0x0001 ! 287: #define HFSP_THREAD_EXISTS 0x0002 /* Always set in HFS+ */ ! 288: ! 289: /* HFS+ catalog thread (part of a cat_entry) */ ! 290: typedef struct { ! 291: UInt16 reserved; ! 292: UInt32 parentID; ! 293: hfsp_unistr255 nodeName; ! 294: } hfsp_cat_thread; ! 295: ! 296: ! 297: /* A data record in the catalog tree */ ! 298: typedef struct { ! 299: UInt16 type; ! 300: union { ! 301: hfsp_cat_folder folder; ! 302: hfsp_cat_file file; ! 303: hfsp_cat_thread thread; ! 304: } u; ! 305: } hfsp_cat_entry;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.