1 | /* $Id: fsw_hfs.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * fsw_hfs.h - HFS file system driver header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2019 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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef _FSW_HFS_H_
|
---|
28 | #define _FSW_HFS_H_
|
---|
29 |
|
---|
30 | #define VOLSTRUCTNAME fsw_hfs_volume
|
---|
31 | #define DNODESTRUCTNAME fsw_hfs_dnode
|
---|
32 |
|
---|
33 | #include "fsw_core.h"
|
---|
34 |
|
---|
35 | #define IN_RING0
|
---|
36 | #if !defined(ARCH_BITS) || !defined(HC_ARCH_BITS)
|
---|
37 | # error "please add right bitness"
|
---|
38 | #endif
|
---|
39 | #include "iprt/formats/hfs.h"
|
---|
40 | #include "iprt/asm.h" /* endian conversion */
|
---|
41 |
|
---|
42 |
|
---|
43 | //! Block size for HFS volumes.
|
---|
44 | #define HFS_BLOCKSIZE 512
|
---|
45 |
|
---|
46 | //! Block number where the HFS superblock resides.
|
---|
47 | #define HFS_SUPERBLOCK_BLOCKNO 2
|
---|
48 |
|
---|
49 | #ifdef _MSC_VER
|
---|
50 | /* vasily: disable warning for non-standard anonymous struct/union
|
---|
51 | * declarations
|
---|
52 | */
|
---|
53 | # pragma warning (disable:4201)
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | struct hfs_dirrec {
|
---|
57 | fsw_u8 _dummy;
|
---|
58 | };
|
---|
59 |
|
---|
60 | #pragma pack(1)
|
---|
61 | struct fsw_hfs_key
|
---|
62 | {
|
---|
63 | union
|
---|
64 | {
|
---|
65 | struct HFSPlusExtentKey ext_key;
|
---|
66 | struct HFSPlusCatalogKey cat_key;
|
---|
67 | fsw_u16 key_len; /* Length is at the beginning of all keys */
|
---|
68 | };
|
---|
69 | };
|
---|
70 | #pragma pack()
|
---|
71 |
|
---|
72 | typedef enum {
|
---|
73 | /* Regular HFS */
|
---|
74 | FSW_HFS_PLAIN = 0,
|
---|
75 | /* HFS+ */
|
---|
76 | FSW_HFS_PLUS,
|
---|
77 | /* HFS+ embedded to HFS */
|
---|
78 | FSW_HFS_PLUS_EMB
|
---|
79 | } fsw_hfs_kind;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * HFS: Dnode structure with HFS-specific data.
|
---|
83 | */
|
---|
84 | struct fsw_hfs_dnode
|
---|
85 | {
|
---|
86 | struct fsw_dnode g; //!< Generic dnode structure
|
---|
87 | HFSPlusExtentRecord extents;
|
---|
88 | fsw_u32 ctime;
|
---|
89 | fsw_u32 mtime;
|
---|
90 | fsw_u64 used_bytes;
|
---|
91 | fsw_u32 node_num;
|
---|
92 | };
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * HFS: In-memory B-tree structure.
|
---|
96 | */
|
---|
97 | struct fsw_hfs_btree
|
---|
98 | {
|
---|
99 | fsw_u32 root_node;
|
---|
100 | fsw_u32 node_size;
|
---|
101 | struct fsw_hfs_dnode* file;
|
---|
102 | };
|
---|
103 |
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * HFS: In-memory volume structure with HFS-specific data.
|
---|
107 | */
|
---|
108 |
|
---|
109 | struct fsw_hfs_volume
|
---|
110 | {
|
---|
111 | struct fsw_volume g; //!< Generic volume structure
|
---|
112 |
|
---|
113 | struct HFSPlusVolumeHeader *primary_voldesc; //!< Volume Descriptor
|
---|
114 | struct fsw_hfs_btree catalog_tree; // Catalog tree
|
---|
115 | struct fsw_hfs_btree extents_tree; // Extents overflow tree
|
---|
116 | struct fsw_hfs_dnode root_file;
|
---|
117 | int case_sensitive;
|
---|
118 | fsw_u32 block_size_shift;
|
---|
119 | fsw_hfs_kind hfs_kind;
|
---|
120 | fsw_u32 emb_block_off;
|
---|
121 | };
|
---|
122 |
|
---|
123 | /* Endianess swappers. */
|
---|
124 | DECLINLINE(fsw_u16)
|
---|
125 | be16_to_cpu(fsw_u16 x)
|
---|
126 | {
|
---|
127 | return RT_BE2H_U16(x);
|
---|
128 | }
|
---|
129 |
|
---|
130 | DECLINLINE(fsw_u16)
|
---|
131 | cpu_to_be16(fsw_u16 x)
|
---|
132 | {
|
---|
133 | return RT_H2BE_U16(x);
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | DECLINLINE(fsw_u32)
|
---|
138 | cpu_to_be32(fsw_u32 x)
|
---|
139 | {
|
---|
140 | return RT_H2BE_U32(x);
|
---|
141 | }
|
---|
142 |
|
---|
143 | DECLINLINE(fsw_u32)
|
---|
144 | be32_to_cpu(fsw_u32 x)
|
---|
145 | {
|
---|
146 | return RT_BE2H_U32(x);
|
---|
147 | }
|
---|
148 |
|
---|
149 | DECLINLINE(fsw_u64)
|
---|
150 | be64_to_cpu(fsw_u64 x)
|
---|
151 | {
|
---|
152 | return RT_BE2H_U64(x);
|
---|
153 | }
|
---|
154 |
|
---|
155 | #endif
|
---|
156 |
|
---|