1 | /* $Id: fsw_hfs.h 46408 2013-06-06 13:28:44Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * fsw_hfs.h - HFS file system driver header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010 Oracle Corporation
|
---|
8 | *
|
---|
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.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef _FSW_HFS_H_
|
---|
19 | #define _FSW_HFS_H_
|
---|
20 |
|
---|
21 | #define VOLSTRUCTNAME fsw_hfs_volume
|
---|
22 | #define DNODESTRUCTNAME fsw_hfs_dnode
|
---|
23 |
|
---|
24 | #include "fsw_core.h"
|
---|
25 | #include "iprt/formats/hfs.h"
|
---|
26 | #include "iprt/asm.h" /* endian conversion */
|
---|
27 |
|
---|
28 |
|
---|
29 | //! Block size for HFS volumes.
|
---|
30 | #define HFS_BLOCKSIZE 512
|
---|
31 |
|
---|
32 | //! Block number where the HFS superblock resides.
|
---|
33 | #define HFS_SUPERBLOCK_BLOCKNO 2
|
---|
34 |
|
---|
35 | #ifdef _MSC_VER
|
---|
36 | /* vasily: disable warning for non-standard anonymous struct/union
|
---|
37 | * declarations
|
---|
38 | */
|
---|
39 | # pragma warning (disable:4201)
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | struct hfs_dirrec {
|
---|
43 | fsw_u8 _dummy;
|
---|
44 | };
|
---|
45 |
|
---|
46 | #pragma pack(1)
|
---|
47 | struct fsw_hfs_key
|
---|
48 | {
|
---|
49 | union
|
---|
50 | {
|
---|
51 | struct HFSPlusExtentKey ext_key;
|
---|
52 | struct HFSPlusCatalogKey cat_key;
|
---|
53 | fsw_u16 key_len; /* Length is at the beginning of all keys */
|
---|
54 | };
|
---|
55 | };
|
---|
56 | #pragma pack()
|
---|
57 |
|
---|
58 | typedef enum {
|
---|
59 | /* Regular HFS */
|
---|
60 | FSW_HFS_PLAIN = 0,
|
---|
61 | /* HFS+ */
|
---|
62 | FSW_HFS_PLUS,
|
---|
63 | /* HFS+ embedded to HFS */
|
---|
64 | FSW_HFS_PLUS_EMB
|
---|
65 | } fsw_hfs_kind;
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * HFS: Dnode structure with HFS-specific data.
|
---|
69 | */
|
---|
70 | struct fsw_hfs_dnode
|
---|
71 | {
|
---|
72 | struct fsw_dnode g; //!< Generic dnode structure
|
---|
73 | HFSPlusExtentRecord extents;
|
---|
74 | fsw_u32 ctime;
|
---|
75 | fsw_u32 mtime;
|
---|
76 | fsw_u64 used_bytes;
|
---|
77 | };
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * HFS: In-memory B-tree structure.
|
---|
81 | */
|
---|
82 | struct fsw_hfs_btree
|
---|
83 | {
|
---|
84 | fsw_u32 root_node;
|
---|
85 | fsw_u32 node_size;
|
---|
86 | struct fsw_hfs_dnode* file;
|
---|
87 | };
|
---|
88 |
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * HFS: In-memory volume structure with HFS-specific data.
|
---|
92 | */
|
---|
93 |
|
---|
94 | struct fsw_hfs_volume
|
---|
95 | {
|
---|
96 | struct fsw_volume g; //!< Generic volume structure
|
---|
97 |
|
---|
98 | struct HFSPlusVolumeHeader *primary_voldesc; //!< Volume Descriptor
|
---|
99 | struct fsw_hfs_btree catalog_tree; // Catalog tree
|
---|
100 | struct fsw_hfs_btree extents_tree; // Extents overflow tree
|
---|
101 | struct fsw_hfs_dnode root_file;
|
---|
102 | int case_sensitive;
|
---|
103 | fsw_u32 block_size_shift;
|
---|
104 | fsw_hfs_kind hfs_kind;
|
---|
105 | fsw_u32 emb_block_off;
|
---|
106 | };
|
---|
107 |
|
---|
108 | /* Endianess swappers. */
|
---|
109 | DECLINLINE(fsw_u16)
|
---|
110 | be16_to_cpu(fsw_u16 x)
|
---|
111 | {
|
---|
112 | return RT_BE2H_U16(x);
|
---|
113 | }
|
---|
114 |
|
---|
115 | DECLINLINE(fsw_u16)
|
---|
116 | cpu_to_be16(fsw_u16 x)
|
---|
117 | {
|
---|
118 | return RT_H2BE_U16(x);
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | DECLINLINE(fsw_u32)
|
---|
123 | cpu_to_be32(fsw_u32 x)
|
---|
124 | {
|
---|
125 | return RT_H2BE_U32(x);
|
---|
126 | }
|
---|
127 |
|
---|
128 | DECLINLINE(fsw_u32)
|
---|
129 | be32_to_cpu(fsw_u32 x)
|
---|
130 | {
|
---|
131 | return RT_BE2H_U32(x);
|
---|
132 | }
|
---|
133 |
|
---|
134 | DECLINLINE(fsw_u64)
|
---|
135 | be64_to_cpu(fsw_u64 x)
|
---|
136 | {
|
---|
137 | return RT_BE2H_U64(x);
|
---|
138 | }
|
---|
139 |
|
---|
140 | #endif
|
---|
141 |
|
---|