VirtualBox

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

Last change on this file since 94368 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: fsw_hfs.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * fsw_hfs.h - HFS file system driver header.
4 */
5
6/*
7 * Copyright (C) 2010-2022 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#ifndef HOST_POSIX
43#include <Library/BaseLib.h>
44#endif
45
46//! Block size for HFS volumes.
47#define HFS_BLOCKSIZE 512
48
49//! Block number where the HFS superblock resides.
50#define HFS_SUPERBLOCK_BLOCKNO 2
51
52#ifdef _MSC_VER
53/* vasily: disable warning for non-standard anonymous struct/union
54 * declarations
55 */
56# pragma warning (disable:4201)
57#endif
58
59struct hfs_dirrec {
60 fsw_u8 _dummy;
61};
62
63#pragma pack(1)
64struct fsw_hfs_key
65{
66 union
67 {
68 struct HFSPlusExtentKey ext_key;
69 struct HFSPlusCatalogKey cat_key;
70 fsw_u16 key_len; /* Length is at the beginning of all keys */
71 };
72};
73#pragma pack()
74
75typedef enum {
76 /* Regular HFS */
77 FSW_HFS_PLAIN = 0,
78 /* HFS+ */
79 FSW_HFS_PLUS,
80 /* HFS+ embedded to HFS */
81 FSW_HFS_PLUS_EMB
82} fsw_hfs_kind;
83
84/**
85 * HFS: Dnode structure with HFS-specific data.
86 */
87struct fsw_hfs_dnode
88{
89 struct fsw_dnode g; //!< Generic dnode structure
90 HFSPlusExtentRecord extents;
91 fsw_u32 ctime;
92 fsw_u32 mtime;
93 fsw_u64 used_bytes;
94 fsw_u32 node_num;
95};
96
97/**
98 * HFS: In-memory B-tree structure.
99 */
100struct fsw_hfs_btree
101{
102 fsw_u32 root_node;
103 fsw_u32 node_size;
104 struct fsw_hfs_dnode* file;
105};
106
107
108/**
109 * HFS: In-memory volume structure with HFS-specific data.
110 */
111
112struct fsw_hfs_volume
113{
114 struct fsw_volume g; //!< Generic volume structure
115
116 struct HFSPlusVolumeHeader *primary_voldesc; //!< Volume Descriptor
117 struct fsw_hfs_btree catalog_tree; // Catalog tree
118 struct fsw_hfs_btree extents_tree; // Extents overflow tree
119 struct fsw_hfs_dnode root_file;
120 int case_sensitive;
121 fsw_u32 block_size_shift;
122 fsw_hfs_kind hfs_kind;
123 fsw_u32 emb_block_off;
124};
125
126/* Endianess swappers. */
127DECLINLINE(fsw_u16)
128be16_to_cpu(fsw_u16 x)
129{
130 return RT_BE2H_U16(x);
131}
132
133DECLINLINE(fsw_u16)
134cpu_to_be16(fsw_u16 x)
135{
136 return RT_H2BE_U16(x);
137}
138
139
140DECLINLINE(fsw_u32)
141cpu_to_be32(fsw_u32 x)
142{
143 return RT_H2BE_U32(x);
144}
145
146DECLINLINE(fsw_u32)
147be32_to_cpu(fsw_u32 x)
148{
149 return RT_BE2H_U32(x);
150}
151
152DECLINLINE(fsw_u64)
153be64_to_cpu(fsw_u64 x)
154{
155#ifdef RT_LITTLE_ENDIAN
156#ifdef HOST_POSIX
157 return RT_BE2H_U64(x);
158#else
159 return SwapBytes64(x);
160#endif
161#else
162 return x;
163#endif
164}
165
166#endif
167
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette