diff options
author | Debarshi Ray <rishi@gnu.org> | 2007-02-19 09:09:44 +0530 |
---|---|---|
committer | দেবর্ষি রায় <rishi@Sunflower.(none)> | 2007-02-19 09:09:44 +0530 |
commit | 9d4a4289659625ef143e8c74a26654a7c4da2906 (patch) | |
tree | 928876d1a7727b3678933ee2450e19b1176bbf0d | |
parent | 4529f6625622b459975c59921f4360afe6b7eb5c (diff) | |
download | parted-9d4a4289659625ef143e8c74a26654a7c4da2906.tar.gz |
Cleaning up nested structs & unions.
-rw-r--r-- | doc/FAT | 91 | ||||
-rw-r--r-- | libparted/fs/fat/bootsector.h | 106 | ||||
-rw-r--r-- | libparted/fs/hfs/hfs.h | 608 |
3 files changed, 397 insertions, 408 deletions
@@ -125,54 +125,49 @@ Microsoft's implementation - they are calculated independently. Taken from libparted/fs_fat/bootsector.h: struct __attribute__ ((packed)) _FatBootSector { - __u8 boot_jump[3]; /* 00: Boot strap short or near jump */ - __u8 system_id[8]; /* 03: system name */ - __u16 sector_size; /* 0b: bytes per logical sector */ - __u8 cluster_size; /* 0d: sectors/cluster */ - __u16 reserved; /* 0e: reserved sectors */ - __u8 fats; /* 10: number of FATs */ - __u16 dir_entries; /* 11: number of root directory entries */ - __u16 sectors; /* 13: if 0, sector_count supersedes */ - __u8 media; /* 15: media code */ - __u16 fat_length; /* 16: sectors/FAT for FAT12/16 */ - __u16 secs_track; /* 18: sectors per track */ - __u16 heads; /* 1a: number of heads */ - __u32 hidden; /* 1c: hidden sectors (partition start) */ - __u32 sector_count; /* 20: no. of sectors (if sectors == 0) */ - -union __attribute__ ((packed)) { -/* FAT16 fields */ -struct __attribute__ ((packed)) { - __u8 drive_num; /* 24: */ - __u8 empty_1; /* 25: */ - __u8 ext_signature; /* 26: always 0x29 */ - __u32 serial_number; /* 27: */ - __u8 volume_name [11]; /* 2b: */ - __u8 fat_name [8]; /* 37: */ - - __u8 boot_code[448]; /* 3f: Boot code (or message) */ -} fat16; - -/* FAT32 fields */ -struct __attribute__ ((packed)) { - __u32 fat_length; /* 24: size of FAT in sectors */ - __u16 flags; /* 28: bit8: fat mirroring, low4: active fat */ - __u16 version; /* 2a: minor * 256 + major */ - __u32 root_dir_cluster; /* 2c: */ - __u16 info_sector; /* 30: */ - __u16 backup_sector; /* 32: */ - - __u8 empty_1 [12]; /* 34: */ - - __u16 drive_num; /* 40: */ - __u8 ext_signature; /* 42: always 0x29 */ - __u32 serial_number; /* 43: */ - __u8 volume_name [11]; /* 47: */ - __u8 fat_name [8]; /* 52: */ - - __u8 boot_code[420]; /* 5a: Boot code (or message) */ -} fat32; -} u; + __u8 boot_jump[3]; /* 00: Boot strap short or near jump */ + __u8 system_id[8]; /* 03: system name */ + __u16 sector_size; /* 0b: bytes per logical sector */ + __u8 cluster_size; /* 0d: sectors/cluster */ + __u16 reserved; /* 0e: reserved sectors */ + __u8 fats; /* 10: number of FATs */ + __u16 dir_entries; /* 11: number of root directory entries */ + __u16 sectors; /* 13: if 0, sector_count supersedes */ + __u8 media; /* 15: media code */ + __u16 fat_length; /* 16: sectors/FAT for FAT12/16 */ + __u16 secs_track; /* 18: sectors per track */ + __u16 heads; /* 1a: number of heads */ + __u32 hidden; /* 1c: hidden sectors (partition start) */ + __u32 sector_count; /* 20: no. of sectors (if sectors == 0) */ + + union __attribute__ ((packed)) { + /* FAT16 fields */ + struct __attribute__ ((packed)) { + __u8 drive_num; /* 24: */ + __u8 empty_1; /* 25: */ + __u8 ext_signature; /* 26: always 0x29 */ + __u32 serial_number; /* 27: */ + __u8 volume_name [11]; /* 2b: */ + __u8 fat_name [8]; /* 37: */ + __u8 boot_code[448]; /* 3f: Boot code (or message) */ + } fat16; + /* FAT32 fields */ + struct __attribute__ ((packed)) { + __u32 fat_length; /* 24: size of FAT in sectors */ + __u16 flags; /* 28: bit8: fat mirroring, low4: active fat */ + __u16 version; /* 2a: minor * 256 + major */ + __u32 root_dir_cluster; /* 2c: */ + __u16 info_sector; /* 30: */ + __u16 backup_sector; /* 32: */ + __u8 empty_1 [12]; /* 34: */ + __u16 drive_num; /* 40: */ + __u8 ext_signature; /* 42: always 0x29 */ + __u32 serial_number; /* 43: */ + __u8 volume_name [11]; /* 47: */ + __u8 fat_name [8]; /* 52: */ + __u8 boot_code[420]; /* 5a: Boot code (or message) */ + } fat32; + } u; __u16 boot_sign; /* 1fe: always 0xAA55 */ }; diff --git a/libparted/fs/fat/bootsector.h b/libparted/fs/fat/bootsector.h index f0ba44d..e800c59 100644 --- a/libparted/fs/fat/bootsector.h +++ b/libparted/fs/fat/bootsector.h @@ -60,67 +60,61 @@ typedef struct _FatInfoSector FatInfoSector; #define FAT_BOOT_CODE_LENGTH 128 struct __attribute__ ((packed)) _FatBootSector { - uint8_t boot_jump[3]; /* 00: Boot strap short or near jump */ - uint8_t system_id[8]; /* 03: system name */ - uint16_t sector_size; /* 0b: bytes per logical sector */ - uint8_t cluster_size; /* 0d: sectors/cluster */ - uint16_t reserved; /* 0e: reserved sectors */ - uint8_t fats; /* 10: number of FATs */ - uint16_t dir_entries; /* 11: number of root directory entries */ - uint16_t sectors; /* 13: if 0, total_sect supersedes */ - uint8_t media; /* 15: media code */ - uint16_t fat_length; /* 16: sectors/FAT for FAT12/16 */ - uint16_t secs_track; /* 18: sectors per track */ - uint16_t heads; /* 1a: number of heads */ - uint32_t hidden; /* 1c: hidden sectors (partition start) */ - uint32_t sector_count; /* 20: no. of sectors (if sectors == 0) */ - -union __attribute__ ((packed)) { - -/* FAT16 fields */ -struct __attribute__ ((packed)) { - uint8_t drive_num; /* 24: */ - uint8_t empty_1; /* 25: */ - uint8_t ext_signature; /* 26: always 0x29 */ - uint32_t serial_number; /* 27: */ - uint8_t volume_name [11]; /* 2b: */ - uint8_t fat_name [8]; /* 36: */ - - uint8_t boot_code[448]; /* 3f: Boot code (or message) */ -} fat16; - -/* FAT32 fields */ -struct __attribute__ ((packed)) { - uint32_t fat_length; /* 24: size of FAT in sectors */ - uint16_t flags; /* 28: bit8: fat mirroring, low4: active fat */ - uint16_t version; /* 2a: minor * 256 + major */ - uint32_t root_dir_cluster; /* 2c: */ - uint16_t info_sector; /* 30: */ - uint16_t backup_sector; /* 32: */ - - uint8_t empty_1 [12]; /* 34: */ - - uint16_t drive_num; /* 40: */ - uint8_t ext_signature; /* 42: always 0x29 */ - uint32_t serial_number; /* 43: */ - uint8_t volume_name [11]; /* 47: */ - uint8_t fat_name [8]; /* 52: */ - - uint8_t boot_code[420]; /* 5a: Boot code (or message) */ -} fat32; -} u; + uint8_t boot_jump[3]; /* 00: Boot strap short or near jump */ + uint8_t system_id[8]; /* 03: system name */ + uint16_t sector_size; /* 0b: bytes per logical sector */ + uint8_t cluster_size; /* 0d: sectors/cluster */ + uint16_t reserved; /* 0e: reserved sectors */ + uint8_t fats; /* 10: number of FATs */ + uint16_t dir_entries; /* 11: number of root directory entries */ + uint16_t sectors; /* 13: if 0, total_sect supersedes */ + uint8_t media; /* 15: media code */ + uint16_t fat_length; /* 16: sectors/FAT for FAT12/16 */ + uint16_t secs_track; /* 18: sectors per track */ + uint16_t heads; /* 1a: number of heads */ + uint32_t hidden; /* 1c: hidden sectors (partition start) */ + uint32_t sector_count; /* 20: no. of sectors (if sectors == 0) */ + + union __attribute__ ((packed)) { + /* FAT16 fields */ + struct __attribute__ ((packed)) { + uint8_t drive_num; /* 24: */ + uint8_t empty_1; /* 25: */ + uint8_t ext_signature; /* 26: always 0x29 */ + uint32_t serial_number; /* 27: */ + uint8_t volume_name [11]; /* 2b: */ + uint8_t fat_name [8]; /* 36: */ + uint8_t boot_code[448]; /* 3f: Boot code (or message) */ + } fat16; + /* FAT32 fields */ + struct __attribute__ ((packed)) { + uint32_t fat_length; /* 24: size of FAT in sectors */ + uint16_t flags; /* 28: bit8: fat mirroring, low4: active fat */ + uint16_t version; /* 2a: minor * 256 + major */ + uint32_t root_dir_cluster; /* 2c: */ + uint16_t info_sector; /* 30: */ + uint16_t backup_sector; /* 32: */ + uint8_t empty_1 [12]; /* 34: */ + uint16_t drive_num; /* 40: */ + uint8_t ext_signature; /* 42: always 0x29 */ + uint32_t serial_number; /* 43: */ + uint8_t volume_name [11]; /* 47: */ + uint8_t fat_name [8]; /* 52: */ + uint8_t boot_code[420]; /* 5a: Boot code (or message) */ + } fat32; + } u; uint16_t boot_sign; /* 1fe: always 0xAA55 */ }; struct __attribute__ ((packed)) _FatInfoSector { - uint32_t signature_1; /* should be 0x41615252 */ - uint8_t unused [480]; - uint32_t signature_2; /* should be 0x61417272 */ - uint32_t free_clusters; - uint32_t next_cluster; /* most recently allocated cluster */ - uint8_t unused2 [0xe]; - uint16_t signature_3; /* should be 0xaa55 */ + uint32_t signature_1; /* should be 0x41615252 */ + uint8_t unused [480]; + uint32_t signature_2; /* should be 0x61417272 */ + uint32_t free_clusters; + uint32_t next_cluster; /* most recently allocated cluster */ + uint8_t unused2 [0xe]; + uint16_t signature_3; /* should be 0xaa55 */ }; int fat_boot_sector_read (FatBootSector* bs, const PedGeometry* geom); diff --git a/libparted/fs/hfs/hfs.h b/libparted/fs/hfs/hfs.h index 1fe6393..bb6d50d 100644 --- a/libparted/fs/hfs/hfs.h +++ b/libparted/fs/hfs/hfs.h @@ -128,160 +128,160 @@ /* Extent descriptor */ struct __attribute__ ((packed)) _HfsExtDescriptor { - uint16_t start_block; - uint16_t block_count; + uint16_t start_block; + uint16_t block_count; }; typedef struct _HfsExtDescriptor HfsExtDescriptor; typedef HfsExtDescriptor HfsExtDataRec[HFS_EXT_NB]; /* Volume header */ struct __attribute__ ((packed)) _HfsMasterDirectoryBlock { - uint16_t signature; - uint32_t create_date; - uint32_t modify_date; - uint16_t volume_attributes; - uint16_t files_in_root; - uint16_t volume_bitmap_block; /* in sectors */ - uint16_t next_allocation; - uint16_t total_blocks; - uint32_t block_size; /* in bytes */ - uint32_t def_clump_size; /* in bytes */ - uint16_t start_block; /* in sectors */ - uint32_t next_free_node; - uint16_t free_blocks; - uint8_t name_length; - char name[27]; - uint32_t backup_date; - uint16_t backup_number; - uint32_t write_count; - uint32_t extents_clump; - uint32_t catalog_clump; - uint16_t dirs_in_root; - uint32_t file_count; - uint32_t dir_count; - uint32_t finder_info[8]; - union __attribute__ ((packed)) { - struct __attribute__ ((packed)) { - uint16_t volume_cache_size; /* in blocks */ - uint16_t bitmap_cache_size; /* in blocks */ - uint16_t common_cache_size; /* in blocks */ - } legacy; - struct __attribute__ ((packed)) { - uint16_t signature; - HfsExtDescriptor location; - } embedded; - } old_new; - uint32_t extents_file_size; /* in bytes, block size multiple */ - HfsExtDataRec extents_file_rec; - uint32_t catalog_file_size; /* in bytes, block size multiple */ - HfsExtDataRec catalog_file_rec; + uint16_t signature; + uint32_t create_date; + uint32_t modify_date; + uint16_t volume_attributes; + uint16_t files_in_root; + uint16_t volume_bitmap_block; /* in sectors */ + uint16_t next_allocation; + uint16_t total_blocks; + uint32_t block_size; /* in bytes */ + uint32_t def_clump_size; /* in bytes */ + uint16_t start_block; /* in sectors */ + uint32_t next_free_node; + uint16_t free_blocks; + uint8_t name_length; + char name[27]; + uint32_t backup_date; + uint16_t backup_number; + uint32_t write_count; + uint32_t extents_clump; + uint32_t catalog_clump; + uint16_t dirs_in_root; + uint32_t file_count; + uint32_t dir_count; + uint32_t finder_info[8]; + union __attribute__ ((packed)) { + struct __attribute__ ((packed)) { + uint16_t volume_cache_size; /* in blocks */ + uint16_t bitmap_cache_size; /* in blocks */ + uint16_t common_cache_size; /* in blocks */ + } legacy; + struct __attribute__ ((packed)) { + uint16_t signature; + HfsExtDescriptor location; + } embedded; + } old_new; + uint32_t extents_file_size; /* in bytes, block size multiple */ + HfsExtDataRec extents_file_rec; + uint32_t catalog_file_size; /* in bytes, block size multiple */ + HfsExtDataRec catalog_file_rec; }; typedef struct _HfsMasterDirectoryBlock HfsMasterDirectoryBlock; /* B*-Tree Node Descriptor */ struct __attribute__ ((packed)) _HfsNodeDescriptor { - uint32_t next; - uint32_t previous; - int8_t type; - uint8_t height; - uint16_t rec_nb; - uint16_t reserved; + uint32_t next; + uint32_t previous; + int8_t type; + uint8_t height; + uint16_t rec_nb; + uint16_t reserved; }; typedef struct _HfsNodeDescriptor HfsNodeDescriptor; /* Header record of a whole B*-Tree */ struct __attribute__ ((packed)) _HfsHeaderRecord { - uint16_t depth; - uint32_t root_node; - uint32_t leaf_records; - uint32_t first_leaf_node; - uint32_t last_leaf_node; - uint16_t node_size; - uint16_t max_key_len; - uint32_t total_nodes; - uint32_t free_nodes; - int8_t reserved[76]; + uint16_t depth; + uint32_t root_node; + uint32_t leaf_records; + uint32_t first_leaf_node; + uint32_t last_leaf_node; + uint16_t node_size; + uint16_t max_key_len; + uint32_t total_nodes; + uint32_t free_nodes; + int8_t reserved[76]; }; typedef struct _HfsHeaderRecord HfsHeaderRecord; /* Catalog key for B*-Tree lookup in the catalog file */ struct __attribute__ ((packed)) _HfsCatalogKey { - uint8_t key_length; /* length of the key without key_length */ - uint8_t reserved; - uint32_t parent_ID; - uint8_t name_length; - char name[31]; /* in fact physicaly 1 upto 31 */ + uint8_t key_length; /* length of the key without key_length */ + uint8_t reserved; + uint32_t parent_ID; + uint8_t name_length; + char name[31]; /* in fact physicaly 1 upto 31 */ }; typedef struct _HfsCatalogKey HfsCatalogKey; /* Extents overflow key for B*-Tree lookup */ struct __attribute__ ((packed)) _HfsExtentKey { - uint8_t key_length; /* length of the key without key_length */ - uint8_t type; /* data or ressource fork */ - uint32_t file_ID; - uint16_t start; + uint8_t key_length; /* length of the key without key_length */ + uint8_t type; /* data or ressource fork */ + uint32_t file_ID; + uint16_t start; }; typedef struct _HfsExtentKey HfsExtentKey; /* Catalog subdata case directory */ struct __attribute__ ((packed)) _HfsDir { - uint16_t flags; - uint16_t valence; /* number of files in this directory */ - uint32_t dir_ID; - uint32_t create_date; - uint32_t modify_date; - uint32_t backup_date; - int8_t DInfo[16]; /* used by Finder, handle as reserved */ - int8_t DXInfo[16]; /* used by Finder, handle as reserved */ - uint32_t reserved[4]; + uint16_t flags; + uint16_t valence; /* number of files in this directory */ + uint32_t dir_ID; + uint32_t create_date; + uint32_t modify_date; + uint32_t backup_date; + int8_t DInfo[16]; /* used by Finder, handle as reserved */ + int8_t DXInfo[16]; /* used by Finder, handle as reserved */ + uint32_t reserved[4]; }; typedef struct _HfsDir HfsDir; /* Catalog subdata case file */ struct __attribute__ ((packed)) _HfsFile { - int8_t flags; - int8_t type; /* should be 0 */ - int8_t FInfo[16]; /* used by Finder, handle as reserved */ - uint32_t file_ID; - uint16_t data_start_block; - uint32_t data_sz_byte; - uint32_t data_sz_block; - uint16_t res_start_block; - uint32_t res_sz_byte; - uint32_t res_sz_block; - uint32_t create_date; - uint32_t modify_date; - uint32_t backup_date; - int8_t FXInfo[16]; /* used by Finder, handle as reserved */ - uint16_t clump_size; - HfsExtDataRec extents_data; - HfsExtDataRec extents_res; - uint32_t reserved; + int8_t flags; + int8_t type; /* should be 0 */ + int8_t FInfo[16]; /* used by Finder, handle as reserved */ + uint32_t file_ID; + uint16_t data_start_block; + uint32_t data_sz_byte; + uint32_t data_sz_block; + uint16_t res_start_block; + uint32_t res_sz_byte; + uint32_t res_sz_block; + uint32_t create_date; + uint32_t modify_date; + uint32_t backup_date; + int8_t FXInfo[16]; /* used by Finder, handle as reserved */ + uint16_t clump_size; + HfsExtDataRec extents_data; + HfsExtDataRec extents_res; + uint32_t reserved; }; typedef struct _HfsFile HfsFile; /* Catalog subdata case directory thread */ struct __attribute__ ((packed)) _HfsDirTh { - uint32_t reserved[2]; - uint32_t parent_ID; - int8_t name_length; - char name[31]; + uint32_t reserved[2]; + uint32_t parent_ID; + int8_t name_length; + char name[31]; }; typedef struct _HfsDirTh HfsDirTh; /* Catalog subdata case file thread */ -typedef struct _HfsDirTh HfsFileTh; /* same as directory thread */ +typedef struct _HfsDirTh HfsFileTh; /* same as directory thread */ /* Catalog data */ struct __attribute__ ((packed)) _HfsCatalog { - int8_t type; - int8_t reserved; - union { - HfsDir dir; - HfsFile file; - HfsDirTh dir_th; - HfsFileTh file_th; - } sel; + int8_t type; + int8_t reserved; + union { + HfsDir dir; + HfsFile file; + HfsDirTh dir_th; + HfsFileTh file_th; + } sel; }; typedef struct _HfsCatalog HfsCatalog; @@ -293,27 +293,27 @@ typedef struct _HfsCatalog HfsCatalog; /* documented since 2004 in tn1150 */ struct __attribute__ ((packed)) _HfsPPerms { - uint32_t owner_ID; - uint32_t group_ID; - uint32_t permissions; - uint32_t special_devices; + uint32_t owner_ID; + uint32_t group_ID; + uint32_t permissions; + uint32_t special_devices; }; typedef struct _HfsPPerms HfsPPerms; /* HFS+ extent descriptor*/ struct __attribute__ ((packed)) _HfsPExtDescriptor { - uint32_t start_block; - uint32_t block_count; + uint32_t start_block; + uint32_t block_count; }; typedef struct _HfsPExtDescriptor HfsPExtDescriptor; typedef HfsPExtDescriptor HfsPExtDataRec[HFSP_EXT_NB]; /* HFS+ fork data structure */ struct __attribute__ ((packed)) _HfsPForkData { - uint64_t logical_size; - uint32_t clump_size; - uint32_t total_blocks; - HfsPExtDataRec extents; + uint64_t logical_size; + uint32_t clump_size; + uint32_t total_blocks; + HfsPExtDataRec extents; }; typedef struct _HfsPForkData HfsPForkData; @@ -323,158 +323,158 @@ typedef uint32_t HfsPNodeID; /* HFS+ file names */ typedef uint16_t unichar; struct __attribute__ ((packed)) _HfsPUniStr255 { - uint16_t length; - unichar unicode[255]; /* 1 upto 255 */ + uint16_t length; + unichar unicode[255]; /* 1 upto 255 */ }; typedef struct _HfsPUniStr255 HfsPUniStr255; /* HFS+ volume header */ struct __attribute__ ((packed)) _HfsPVolumeHeader { - uint16_t signature; - uint16_t version; - uint32_t attributes; - uint32_t last_mounted_version; - uint32_t journal_info_block; - - uint32_t create_date; - uint32_t modify_date; - uint32_t backup_date; - uint32_t checked_date; - - uint32_t file_count; - uint32_t dir_count; - - uint32_t block_size; - uint32_t total_blocks; - uint32_t free_blocks; - - uint32_t next_allocation; - uint32_t res_clump_size; - uint32_t data_clump_size; - HfsPNodeID next_catalog_ID; - - uint32_t write_count; - uint64_t encodings_bitmap; - - uint8_t finder_info[32]; - - HfsPForkData allocation_file; - HfsPForkData extents_file; - HfsPForkData catalog_file; - HfsPForkData attributes_file; - HfsPForkData startup_file; + uint16_t signature; + uint16_t version; + uint32_t attributes; + uint32_t last_mounted_version; + uint32_t journal_info_block; + + uint32_t create_date; + uint32_t modify_date; + uint32_t backup_date; + uint32_t checked_date; + + uint32_t file_count; + uint32_t dir_count; + + uint32_t block_size; + uint32_t total_blocks; + uint32_t free_blocks; + + uint32_t next_allocation; + uint32_t res_clump_size; + uint32_t data_clump_size; + HfsPNodeID next_catalog_ID; + + uint32_t write_count; + uint64_t encodings_bitmap; + + uint8_t finder_info[32]; + + HfsPForkData allocation_file; + HfsPForkData extents_file; + HfsPForkData catalog_file; + HfsPForkData attributes_file; + HfsPForkData startup_file; }; typedef struct _HfsPVolumeHeader HfsPVolumeHeader; -/* HFS+ B-Tree Node Descriptor */ /* same as HFS btree */ +/* HFS+ B-Tree Node Descriptor. Same as HFS btree. */ struct __attribute__ ((packed)) _HfsPNodeDescriptor { - uint32_t next; - uint32_t previous; - int8_t type; - uint8_t height; - uint16_t rec_nb; - uint16_t reserved; + uint32_t next; + uint32_t previous; + int8_t type; + uint8_t height; + uint16_t rec_nb; + uint16_t reserved; }; typedef struct _HfsPNodeDescriptor HfsPNodeDescriptor; -/* Header record of a whole HFS+ B-Tree */ +/* Header record of a whole HFS+ B-Tree. */ struct __attribute__ ((packed)) _HfsPHeaderRecord { - uint16_t depth; - uint32_t root_node; - uint32_t leaf_records; - uint32_t first_leaf_node; - uint32_t last_leaf_node; - uint16_t node_size; - uint16_t max_key_len; - uint32_t total_nodes; - uint32_t free_nodes; /* same as hfs btree until here */ - uint16_t reserved1; - - uint32_t clump_size; - uint8_t btree_type; /* must be 0 for HFS+ B-Tree */ - uint8_t key_compare_type; /* hfsx => 0xCF = case folding */ - /* 0xBC = binary compare */ - /* otherwise, reserved */ - uint32_t attributes; - uint32_t reserved3[16]; + uint16_t depth; + uint32_t root_node; + uint32_t leaf_records; + uint32_t first_leaf_node; + uint32_t last_leaf_node; + uint16_t node_size; + uint16_t max_key_len; + uint32_t total_nodes; + uint32_t free_nodes; /* same as hfs btree until here */ + uint16_t reserved1; + + uint32_t clump_size; + uint8_t btree_type; /* must be 0 for HFS+ B-Tree */ + uint8_t key_compare_type; /* hfsx => 0xCF = case folding */ + /* 0xBC = binary compare */ + /* otherwise, reserved */ + uint32_t attributes; + uint32_t reserved3[16]; }; typedef struct _HfsPHeaderRecord HfsPHeaderRecord; /* Catalog key for B-Tree lookup in the HFS+ catalog file */ struct __attribute__ ((packed)) _HfsPCatalogKey { - uint16_t key_length; - HfsPNodeID parent_ID; - HfsPUniStr255 node_name; + uint16_t key_length; + HfsPNodeID parent_ID; + HfsPUniStr255 node_name; }; typedef struct _HfsPCatalogKey HfsPCatalogKey; /* HFS+ catalog subdata case dir */ struct __attribute__ ((packed)) _HfsPDir { - uint16_t flags; - uint32_t valence; - HfsPNodeID dir_ID; - uint32_t create_date; - uint32_t modify_date; - uint32_t attrib_mod_date; - uint32_t access_date; - uint32_t backup_date; - HfsPPerms permissions; - int8_t DInfo[16]; /* used by Finder, handle as reserved */ - int8_t DXInfo[16]; /* used by Finder, handle as reserved */ - uint32_t text_encoding; - uint32_t reserved; + uint16_t flags; + uint32_t valence; + HfsPNodeID dir_ID; + uint32_t create_date; + uint32_t modify_date; + uint32_t attrib_mod_date; + uint32_t access_date; + uint32_t backup_date; + HfsPPerms permissions; + int8_t DInfo[16]; /* used by Finder, handle as reserved */ + int8_t DXInfo[16]; /* used by Finder, handle as reserved */ + uint32_t text_encoding; + uint32_t reserved; }; typedef struct _HfsPDir HfsPDir; /* HFS+ catalog subdata case file */ struct __attribute__ ((packed)) _HfsPFile { - uint16_t flags; - uint32_t reserved1; - HfsPNodeID file_ID; - uint32_t create_date; - uint32_t modify_date; - uint32_t attrib_mod_date; - uint32_t access_date; - uint32_t backup_date; - HfsPPerms permissions; - int8_t FInfo[16]; /* used by Finder, handle as reserved */ - int8_t FXInfo[16]; /* used by Finder, handle as reserved */ - uint32_t text_encoding; - uint32_t reserved2; - - HfsPForkData data_fork; - HfsPForkData res_fork; + uint16_t flags; + uint32_t reserved1; + HfsPNodeID file_ID; + uint32_t create_date; + uint32_t modify_date; + uint32_t attrib_mod_date; + uint32_t access_date; + uint32_t backup_date; + HfsPPerms permissions; + int8_t FInfo[16]; /* used by Finder, handle as reserved */ + int8_t FXInfo[16]; /* used by Finder, handle as reserved */ + uint32_t text_encoding; + uint32_t reserved2; + + HfsPForkData data_fork; + HfsPForkData res_fork; }; typedef struct _HfsPFile HfsPFile; /* HFS+ catalog subdata case thread */ struct __attribute__ ((packed)) _HfsPThread { - int16_t reserved; - HfsPNodeID parent_ID; - HfsPUniStr255 node_name; + int16_t reserved; + HfsPNodeID parent_ID; + HfsPUniStr255 node_name; }; typedef struct _HfsPThread HfsPDirTh; typedef struct _HfsPThread HfsPFileTh; /* HFS+ Catalog leaf data */ struct __attribute__ ((packed)) _HfsPCatalog { - int16_t type; - union { - HfsPDir dir; - HfsPFile file; - HfsPDirTh dir_th; - HfsPFileTh file_th; - } sel; + int16_t type; + union { + HfsPDir dir; + HfsPFile file; + HfsPDirTh dir_th; + HfsPFileTh file_th; + } sel; }; typedef struct _HfsPCatalog HfsPCatalog; /* HFS+ extents file key */ struct __attribute__ ((packed)) _HfsPExtentKey { - uint16_t key_length; - uint8_t type; - uint8_t pad; - HfsPNodeID file_ID; - uint32_t start; + uint16_t key_length; + uint8_t type; + uint8_t pad; + HfsPNodeID file_ID; + uint32_t start; }; typedef struct _HfsPExtentKey HfsPExtentKey; @@ -482,12 +482,12 @@ typedef struct _HfsPExtentKey HfsPExtentKey; /* Fork data attribute file */ struct __attribute__ ((packed)) _HfsPForkDataAttr { - uint32_t record_type; - uint32_t reserved; - union __attribute__ ((packed)) { - HfsPForkData fork; - HfsPExtDataRec extents; - } fork_res; + uint32_t record_type; + uint32_t reserved; + union __attribute__ ((packed)) { + HfsPForkData fork; + HfsPExtDataRec extents; + } fork_res; }; typedef struct _HfsPForkDataAttr HfsPForkDataAttr; @@ -496,40 +496,40 @@ typedef struct _HfsPForkDataAttr HfsPForkDataAttr; /* Info block : stored in a block # defined in the VH */ struct __attribute__ ((packed)) _HfsJJournalInfoBlock { - uint32_t flags; - uint32_t device_signature[8]; - uint64_t offset; - uint64_t size; - uint32_t reserved[32]; + uint32_t flags; + uint32_t device_signature[8]; + uint64_t offset; + uint64_t size; + uint32_t reserved[32]; }; typedef struct _HfsJJournalInfoBlock HfsJJournalInfoBlock; struct __attribute__ ((packed)) _HfsJJournalHeader { - uint32_t magic; - uint32_t endian; - uint64_t start; - uint64_t end; - uint64_t size; - uint32_t blhdr_size; - uint32_t checksum; - uint32_t jhdr_size; + uint32_t magic; + uint32_t endian; + uint64_t start; + uint64_t end; + uint64_t size; + uint32_t blhdr_size; + uint32_t checksum; + uint32_t jhdr_size; }; typedef struct _HfsJJournalHeader HfsJJournalHeader; struct __attribute__ ((packed)) _HfsJBlockInfo { - uint64_t bnum; /* sector number */ - uint32_t bsize; /* size in bytes */ - uint32_t next; + uint64_t bnum; /* sector number */ + uint32_t bsize; /* size in bytes */ + uint32_t next; }; typedef struct _HfsJBlockInfo HfsJBlockInfo; struct __attribute__ ((packed)) _HfsJBlockListHeader { - uint16_t max_blocks; /* reserved */ - uint16_t num_blocks; - uint32_t bytes_used; - uint32_t checksum; - uint32_t pad; - HfsJBlockInfo binfo[1]; + uint16_t max_blocks; /* reserved */ + uint16_t num_blocks; + uint32_t bytes_used; + uint32_t checksum; + uint32_t pad; + HfsJBlockInfo binfo[1]; }; typedef struct _HfsJBlockListHeader HfsJBlockListHeader; @@ -541,38 +541,38 @@ typedef struct _HfsJBlockListHeader HfsJBlockListHeader; /* Data of an opened HFS file */ struct _HfsPrivateFile { - PedSector sect_nb; - PedFileSystem* fs; - uint32_t CNID; /* disk order (BE) */ - HfsExtDataRec first; /* disk order (BE) */ - HfsExtDataRec cache; /* disk order (BE) */ - uint16_t start_cache; /* CPU order */ + PedSector sect_nb; + PedFileSystem* fs; + uint32_t CNID; /* disk order (BE) */ + HfsExtDataRec first; /* disk order (BE) */ + HfsExtDataRec cache; /* disk order (BE) */ + uint16_t start_cache; /* CPU order */ }; typedef struct _HfsPrivateFile HfsPrivateFile; /* To store bad block list */ struct _HfsPrivateLinkExtent { - HfsExtDescriptor extent; - struct _HfsPrivateLinkExtent* next; + HfsExtDescriptor extent; + struct _HfsPrivateLinkExtent* next; }; typedef struct _HfsPrivateLinkExtent HfsPrivateLinkExtent; /* HFS Filesystem specific data */ struct _HfsPrivateFSData { - uint8_t alloc_map[(1<<16) / 8]; - HfsMasterDirectoryBlock* mdb; - HfsPrivateFile* extent_file; - HfsPrivateFile* catalog_file; - HfsPrivateLinkExtent* bad_blocks_xtent_list; - unsigned int bad_blocks_xtent_nb; - char bad_blocks_loaded; + uint8_t alloc_map[(1<<16) / 8]; + HfsMasterDirectoryBlock* mdb; + HfsPrivateFile* extent_file; + HfsPrivateFile* catalog_file; + HfsPrivateLinkExtent* bad_blocks_xtent_list; + unsigned int bad_blocks_xtent_nb; + char bad_blocks_loaded; }; typedef struct _HfsPrivateFSData HfsPrivateFSData; /* Generic btree key */ struct __attribute__ ((packed)) _HfsPrivateGenericKey { - uint8_t key_length; - uint8_t key_content[1]; /* we use 1 as a minimum size */ + uint8_t key_length; + uint8_t key_content[1]; /* we use 1 as a minimum size */ }; typedef struct _HfsPrivateGenericKey HfsPrivateGenericKey; @@ -580,52 +580,52 @@ typedef struct _HfsPrivateGenericKey HfsPrivateGenericKey; /* Data of an opened HFS file */ struct _HfsPPrivateFile { - PedSector sect_nb; - PedFileSystem* fs; - HfsPNodeID CNID; /* disk order (BE) */ - HfsPExtDataRec first; /* disk order (BE) */ - HfsPExtDataRec cache; /* disk order (BE) */ - uint32_t start_cache; /* CPU order */ + PedSector sect_nb; + PedFileSystem* fs; + HfsPNodeID CNID; /* disk order (BE) */ + HfsPExtDataRec first; /* disk order (BE) */ + HfsPExtDataRec cache; /* disk order (BE) */ + uint32_t start_cache; /* CPU order */ }; typedef struct _HfsPPrivateFile HfsPPrivateFile; struct _HfsPPrivateExtent { - PedSector start_sector; - PedSector sector_count; + PedSector start_sector; + PedSector sector_count; }; typedef struct _HfsPPrivateExtent HfsPPrivateExtent; /* To store bad block list */ struct _HfsPPrivateLinkExtent { - HfsPExtDescriptor extent; - struct _HfsPPrivateLinkExtent* next; + HfsPExtDescriptor extent; + struct _HfsPPrivateLinkExtent* next; }; typedef struct _HfsPPrivateLinkExtent HfsPPrivateLinkExtent; /* HFS+ file system specific data */ struct _HfsPPrivateFSData { - PedFileSystem* wrapper; /* NULL if hfs+ is not embedded */ - PedGeometry* plus_geom; /* Geometry of HFS+ _volume_ */ - uint8_t* alloc_map; - uint8_t* dirty_alloc_map; - HfsPVolumeHeader* vh; - HfsPPrivateFile* extents_file; - HfsPPrivateFile* catalog_file; - HfsPPrivateFile* attributes_file; - HfsPPrivateFile* allocation_file; - HfsPPrivateLinkExtent* bad_blocks_xtent_list; - uint32_t jib_start_block; - uint32_t jl_start_block; - unsigned int bad_blocks_xtent_nb; - char bad_blocks_loaded; - char free_geom; /* 1 = plus_geom must be freed */ + PedFileSystem* wrapper; /* NULL if hfs+ is not embedded */ + PedGeometry* plus_geom; /* Geometry of HFS+ _volume_ */ + uint8_t* alloc_map; + uint8_t* dirty_alloc_map; + HfsPVolumeHeader* vh; + HfsPPrivateFile* extents_file; + HfsPPrivateFile* catalog_file; + HfsPPrivateFile* attributes_file; + HfsPPrivateFile* allocation_file; + HfsPPrivateLinkExtent* bad_blocks_xtent_list; + uint32_t jib_start_block; + uint32_t jl_start_block; + unsigned int bad_blocks_xtent_nb; + char bad_blocks_loaded; + char free_geom; /* 1 = plus_geom must be freed */ }; typedef struct _HfsPPrivateFSData HfsPPrivateFSData; /* Generic + btree key */ struct __attribute__ ((packed)) _HfsPPrivateGenericKey { - uint16_t key_length; - uint8_t key_content[1]; /* we use 1 as a minimum size */ + uint16_t key_length; + uint8_t key_content[1]; /* we use 1 as a minimum size */ }; typedef struct _HfsPPrivateGenericKey HfsPPrivateGenericKey; @@ -633,16 +633,16 @@ typedef struct _HfsPPrivateGenericKey HfsPPrivateGenericKey; /* node and lead record reference for a BTree search */ struct _HfsCPrivateLeafRec { - unsigned int node_size; /* in sectors */ - unsigned int node_number; - unsigned int record_pos; - unsigned int record_number; + unsigned int node_size; /* in sectors */ + unsigned int node_number; + unsigned int record_pos; + unsigned int record_number; }; typedef struct _HfsCPrivateLeafRec HfsCPrivateLeafRec; -extern uint8_t* hfs_block; -extern uint8_t* hfsp_block; -extern unsigned hfs_block_count; -extern unsigned hfsp_block_count; +extern uint8_t* hfs_block; +extern uint8_t* hfsp_block; +extern unsigned hfs_block_count; +extern unsigned hfsp_block_count; #endif /* _HFS_H */ |