VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/fsw_hfs.h

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: fsw_hfs.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * fsw_hfs.h - HFS file system driver header.
4 */
5
6/*
7 * Copyright (C) 2010-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef _FSW_HFS_H_
38#define _FSW_HFS_H_
39
40#define VOLSTRUCTNAME fsw_hfs_volume
41#define DNODESTRUCTNAME fsw_hfs_dnode
42
43#include "fsw_core.h"
44
45#define IN_RING0
46#if !defined(ARCH_BITS) || !defined(HC_ARCH_BITS)
47# error "please add right bitness"
48#endif
49#include "iprt/formats/hfs.h"
50#include "iprt/asm.h" /* endian conversion */
51
52#ifndef HOST_POSIX
53#include <Library/BaseLib.h>
54#endif
55
56//! Block size for HFS volumes.
57#define HFS_BLOCKSIZE 512
58
59//! Block number where the HFS superblock resides.
60#define HFS_SUPERBLOCK_BLOCKNO 2
61
62#ifdef _MSC_VER
63/* vasily: disable warning for non-standard anonymous struct/union
64 * declarations
65 */
66# pragma warning (disable:4201)
67#endif
68
69struct hfs_dirrec {
70 fsw_u8 _dummy;
71};
72
73#pragma pack(1)
74struct fsw_hfs_key
75{
76 union
77 {
78 struct HFSPlusExtentKey ext_key;
79 struct HFSPlusCatalogKey cat_key;
80 fsw_u16 key_len; /* Length is at the beginning of all keys */
81 };
82};
83#pragma pack()
84
85typedef enum {
86 /* Regular HFS */
87 FSW_HFS_PLAIN = 0,
88 /* HFS+ */
89 FSW_HFS_PLUS,
90 /* HFS+ embedded to HFS */
91 FSW_HFS_PLUS_EMB
92} fsw_hfs_kind;
93
94/**
95 * HFS: Dnode structure with HFS-specific data.
96 */
97struct fsw_hfs_dnode
98{
99 struct fsw_dnode g; //!< Generic dnode structure
100 HFSPlusExtentRecord extents;
101 fsw_u32 ctime;
102 fsw_u32 mtime;
103 fsw_u64 used_bytes;
104 fsw_u32 node_num;
105};
106
107/**
108 * HFS: In-memory B-tree structure.
109 */
110struct fsw_hfs_btree
111{
112 fsw_u32 root_node;
113 fsw_u32 node_size;
114 struct fsw_hfs_dnode* file;
115};
116
117
118/**
119 * HFS: In-memory volume structure with HFS-specific data.
120 */
121
122struct fsw_hfs_volume
123{
124 struct fsw_volume g; //!< Generic volume structure
125
126 struct HFSPlusVolumeHeader *primary_voldesc; //!< Volume Descriptor
127 struct fsw_hfs_btree catalog_tree; // Catalog tree
128 struct fsw_hfs_btree extents_tree; // Extents overflow tree
129 struct fsw_hfs_dnode root_file;
130 int case_sensitive;
131 fsw_u32 block_size_shift;
132 fsw_hfs_kind hfs_kind;
133 fsw_u32 emb_block_off;
134};
135
136/* Endianess swappers. */
137DECLINLINE(fsw_u16)
138be16_to_cpu(fsw_u16 x)
139{
140 return RT_BE2H_U16(x);
141}
142
143DECLINLINE(fsw_u16)
144cpu_to_be16(fsw_u16 x)
145{
146 return RT_H2BE_U16(x);
147}
148
149
150DECLINLINE(fsw_u32)
151cpu_to_be32(fsw_u32 x)
152{
153 return RT_H2BE_U32(x);
154}
155
156DECLINLINE(fsw_u32)
157be32_to_cpu(fsw_u32 x)
158{
159 return RT_BE2H_U32(x);
160}
161
162DECLINLINE(fsw_u64)
163be64_to_cpu(fsw_u64 x)
164{
165#ifdef RT_LITTLE_ENDIAN
166#ifdef HOST_POSIX
167 return RT_BE2H_U64(x);
168#else
169 return SwapBytes64(x);
170#endif
171#else
172 return x;
173#endif
174}
175
176#endif
177
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use