1 /* $Id: fsw_hfs.h 29125 2010-05-06 09:43:05Z vboxsync $ */
3 * fsw_hfs.h - HFS file system driver header.
7 * Copyright (C) 2010 Oracle Corporation
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21 #define VOLSTRUCTNAME fsw_hfs_volume
22 #define DNODESTRUCTNAME fsw_hfs_dnode
27 //! Block size for HFS volumes.
28 #define HFS_BLOCKSIZE 512
30 //! Block number where the HFS superblock resides.
31 #define HFS_SUPERBLOCK_BLOCKNO 2
33 /* Make world look Applish enough for the system header describing HFS layout */
34 #define __APPLE_API_PRIVATE
35 #define __APPLE_API_UNSTABLE
37 #define u_int8_t fsw_u8
38 #define u_int16_t fsw_u16
39 #define u_int32_t fsw_u32
40 #define u_int64_t fsw_u64
42 #define int16_t fsw_s16
43 #define int32_t fsw_s32
44 #define int64_t fsw_s64
46 #include "hfs_format.h"
59 /* vasily: disable warning for non-standard anonymous struct/union
62 # pragma warning (disable:4201)
63 # define inline __inline
74 struct HFSPlusExtentKey ext_key
;
75 struct HFSPlusCatalogKey cat_key
;
76 fsw_u16 key_len
; /* Length is at the beginning of all keys */
87 /* HFS+ embedded to HFS */
92 * HFS: Dnode structure with HFS-specific data.
97 struct fsw_dnode g
; //!< Generic dnode structure
98 HFSPlusExtentRecord extents
;
105 * HFS: In-memory B-tree structure.
111 struct fsw_hfs_dnode
* file
;
116 * HFS: In-memory volume structure with HFS-specific data.
119 struct fsw_hfs_volume
121 struct fsw_volume g
; //!< Generic volume structure
123 struct HFSPlusVolumeHeader
*primary_voldesc
; //!< Volume Descriptor
124 struct fsw_hfs_btree catalog_tree
; // Catalog tree
125 struct fsw_hfs_btree extents_tree
; // Extents overflow tree
126 struct fsw_hfs_dnode root_file
;
128 fsw_u32 block_size_shift
;
129 fsw_hfs_kind hfs_kind
;
130 fsw_u32 emb_block_off
;
133 /* Endianess swappers */
134 static inline fsw_u16
137 return (x
<<8 | ((x
& 0xff00)>>8));
140 static inline fsw_u32
143 return x
<<24 | x
>>24 |
144 (x
& (fsw_u32
)0x0000ff00UL
)<<8 |
145 (x
& (fsw_u32
)0x00ff0000UL
)>>8;
149 static inline fsw_u64
152 return x
<<56 | x
>>56 |
153 (x
& (fsw_u64
)0x000000000000ff00ULL
)<<40 |
154 (x
& (fsw_u64
)0x0000000000ff0000ULL
)<<24 |
155 (x
& (fsw_u64
)0x00000000ff000000ULL
)<< 8 |
156 (x
& (fsw_u64
)0x000000ff00000000ULL
)>> 8 |
157 (x
& (fsw_u64
)0x0000ff0000000000ULL
)>>24 |
158 (x
& (fsw_u64
)0x00ff000000000000ULL
)>>40;
161 static inline fsw_u16
162 be16_to_cpu(fsw_u16 x
)
167 static inline fsw_u16
168 cpu_to_be16(fsw_u16 x
)
174 static inline fsw_u32
175 cpu_to_be32(fsw_u32 x
)
180 static inline fsw_u32
181 be32_to_cpu(fsw_u32 x
)
186 static inline fsw_u64
187 be64_to_cpu(fsw_u64 x
)