1 | /** @file
|
---|
2 | * IPRT - Filesystem, VFS implementations.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_fsvfs_h
|
---|
37 | #define IPRT_INCLUDED_fsvfs_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/cdefs.h>
|
---|
43 | #include <iprt/types.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | RT_C_DECLS_BEGIN
|
---|
47 |
|
---|
48 | /** @defgroup grp_rt_fs_vfs VFS File System Implementations
|
---|
49 | * @ingroup grp_rt_fs
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * Opens a FAT file system volume.
|
---|
55 | *
|
---|
56 | * @returns IPRT status code.
|
---|
57 | * @param hVfsFileIn The file or device backing the volume.
|
---|
58 | * @param fReadOnly Whether to mount it read-only.
|
---|
59 | * @param offBootSector The offset of the boot sector relative to the start
|
---|
60 | * of @a hVfsFileIn. Pass 0 for floppies.
|
---|
61 | * @param phVfs Where to return the virtual file system handle.
|
---|
62 | * @param pErrInfo Where to return additional error information.
|
---|
63 | */
|
---|
64 | RTDECL(int) RTFsFatVolOpen(RTVFSFILE hVfsFileIn, bool fReadOnly, uint64_t offBootSector, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
65 |
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * FAT type (format).
|
---|
69 | */
|
---|
70 | typedef enum RTFSFATTYPE
|
---|
71 | {
|
---|
72 | RTFSFATTYPE_INVALID = 0,
|
---|
73 | RTFSFATTYPE_FAT12,
|
---|
74 | RTFSFATTYPE_FAT16,
|
---|
75 | RTFSFATTYPE_FAT32,
|
---|
76 | RTFSFATTYPE_END
|
---|
77 | } RTFSFATTYPE;
|
---|
78 |
|
---|
79 |
|
---|
80 | /** @name RTFSFATVOL_FMT_F_XXX - RTFsFatVolFormat flags
|
---|
81 | * @{ */
|
---|
82 | /** Perform a full format, filling unused sectors with 0xf6. */
|
---|
83 | #define RTFSFATVOL_FMT_F_FULL UINT32_C(0)
|
---|
84 | /** Perform a quick format.
|
---|
85 | * I.e. just write the boot sector, FATs and root directory. */
|
---|
86 | #define RTFSFATVOL_FMT_F_QUICK RT_BIT_32(0)
|
---|
87 | /** Mask containing all valid flags. */
|
---|
88 | #define RTFSFATVOL_FMT_F_VALID_MASK UINT32_C(0x00000001)
|
---|
89 | /** @} */
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * Formats a FAT volume.
|
---|
93 | *
|
---|
94 | * @returns IRPT status code.
|
---|
95 | * @param hVfsFile The volume file.
|
---|
96 | * @param offVol The offset into @a hVfsFile of the file.
|
---|
97 | * Typically 0.
|
---|
98 | * @param cbVol The size of the volume. Pass 0 if the rest of
|
---|
99 | * hVfsFile should be used.
|
---|
100 | * @param fFlags See RTFSFATVOL_FMT_F_XXX.
|
---|
101 | * @param cbSector The logical sector size. Must be power of two.
|
---|
102 | * Optional, pass zero to use 512.
|
---|
103 | * @param cSectorsPerCluster Number of sectors per cluster. Power of two.
|
---|
104 | * Optional, pass zero to auto detect.
|
---|
105 | * @param enmFatType The FAT type (12, 16, 32) to use.
|
---|
106 | * Optional, pass RTFSFATTYPE_INVALID for default.
|
---|
107 | * @param cHeads The number of heads to report in the BPB.
|
---|
108 | * Optional, pass zero to auto detect.
|
---|
109 | * @param cSectorsPerTrack The number of sectors per track to put in the
|
---|
110 | * BPB. Optional, pass zero to auto detect.
|
---|
111 | * @param bMedia The media byte value and FAT ID to use.
|
---|
112 | * Optional, pass zero to auto detect.
|
---|
113 | * @param cRootDirEntries Number of root directory entries.
|
---|
114 | * Optional, pass zero to auto detect.
|
---|
115 | * @param cHiddenSectors Number of hidden sectors. Pass 0 for
|
---|
116 | * unpartitioned media.
|
---|
117 | * @param pErrInfo Additional error information, maybe. Optional.
|
---|
118 | */
|
---|
119 | RTDECL(int) RTFsFatVolFormat(RTVFSFILE hVfsFile, uint64_t offVol, uint64_t cbVol, uint32_t fFlags, uint16_t cbSector,
|
---|
120 | uint16_t cSectorsPerCluster, RTFSFATTYPE enmFatType, uint32_t cHeads, uint32_t cSectorsPerTrack,
|
---|
121 | uint8_t bMedia, uint16_t cRootDirEntries, uint32_t cHiddenSectors, PRTERRINFO pErrInfo);
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Formats a 1.44MB floppy image.
|
---|
125 | *
|
---|
126 | * @returns IPRT status code.
|
---|
127 | * @param hVfsFile The image. Will be grown to 1.44MB if
|
---|
128 | * necessary.
|
---|
129 | * @param fQuick Whether to quick format the floppy or not.
|
---|
130 | */
|
---|
131 | RTDECL(int) RTFsFatVolFormat144(RTVFSFILE hVfsFile, bool fQuick);
|
---|
132 |
|
---|
133 | /**
|
---|
134 | * Formats a 2.88MB floppy image.
|
---|
135 | *
|
---|
136 | * @returns IPRT status code.
|
---|
137 | * @param hVfsFile The image. Will be grown to 1.44MB if
|
---|
138 | * necessary.
|
---|
139 | * @param fQuick Whether to quick format the floppy or not.
|
---|
140 | */
|
---|
141 | RTDECL(int) RTFsFatVolFormat288(RTVFSFILE hVfsFile, bool fQuick);
|
---|
142 |
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Opens an EXT2/3/4 file system volume.
|
---|
146 | *
|
---|
147 | * @returns IPRT status code.
|
---|
148 | * @param hVfsFileIn The file or device backing the volume.
|
---|
149 | * @param fMntFlags RTVFSMNT_F_XXX.
|
---|
150 | * @param fExtFlags Reserved, MBZ.
|
---|
151 | * @param phVfs Where to return the virtual file system handle.
|
---|
152 | * @param pErrInfo Where to return additional error information.
|
---|
153 | */
|
---|
154 | RTDECL(int) RTFsExtVolOpen(RTVFSFILE hVfsFileIn, uint32_t fMntFlags, uint32_t fExtFlags, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 | /** @name RTFSISO9660_F_XXX - ISO 9660 mount flags.
|
---|
159 | * @{ */
|
---|
160 | /** Do not use the UDF part if present. */
|
---|
161 | #define RTFSISO9660_F_NO_UDF RT_BIT_32(0)
|
---|
162 | /** Do not use the joliet part. */
|
---|
163 | #define RTFSISO9660_F_NO_JOLIET RT_BIT_32(1)
|
---|
164 | /** Do not use the rock ridge extensions if present. */
|
---|
165 | #define RTFSISO9660_F_NO_ROCK RT_BIT_32(2)
|
---|
166 | /** Valid ISO 9660 mount option mask. */
|
---|
167 | #define RTFSISO9660_F_VALID_MASK UINT32_C(0x00000007)
|
---|
168 | /** Checks if @a a_fNoType is the only acceptable volume type. */
|
---|
169 | #define RTFSISO9660_F_IS_ONLY_TYPE(a_fFlags, a_fNoType) \
|
---|
170 | ( ((a_fFlags) & (RTFSISO9660_F_NO_UDF | RTFSISO9660_F_NO_JOLIET | RTFSISO9660_F_NO_ROCK)) \
|
---|
171 | == (~(a_fNoType) & (RTFSISO9660_F_NO_UDF | RTFSISO9660_F_NO_JOLIET | RTFSISO9660_F_NO_ROCK)) )
|
---|
172 | /** @} */
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Opens an ISO 9660 file system volume.
|
---|
176 | *
|
---|
177 | * @returns IPRT status code.
|
---|
178 | * @param hVfsFileIn The file or device backing the volume.
|
---|
179 | * @param fFlags RTFSISO9660_F_XXX.
|
---|
180 | * @param phVfs Where to return the virtual file system handle.
|
---|
181 | * @param pErrInfo Where to return additional error information.
|
---|
182 | */
|
---|
183 | RTDECL(int) RTFsIso9660VolOpen(RTVFSFILE hVfsFileIn, uint32_t fFlags, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
184 |
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Opens an NTFS file system volume.
|
---|
188 | *
|
---|
189 | * @returns IPRT status code.
|
---|
190 | * @param hVfsFileIn The file or device backing the volume.
|
---|
191 | * @param fMntFlags RTVFSMNT_F_XXX.
|
---|
192 | * @param fNtfsFlags Reserved, MBZ.
|
---|
193 | * @param phVfs Where to return the virtual file system handle.
|
---|
194 | * @param pErrInfo Where to return additional error information.
|
---|
195 | */
|
---|
196 | RTDECL(int) RTFsNtfsVolOpen(RTVFSFILE hVfsFileIn, uint32_t fMntFlags, uint32_t fNtfsFlags, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
197 |
|
---|
198 |
|
---|
199 | /** @name RTFSPDB_F_XXX - PDB mount flags.
|
---|
200 | * @{ */
|
---|
201 | /** Don't provide module names, just plain stream numbering. */
|
---|
202 | #define RTFSPDB_F_NO_NAMES RT_BIT_32(0)
|
---|
203 | /** @} */
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * Opens an PDB container volume.
|
---|
207 | *
|
---|
208 | * The program database container files are used by the Microsoft Visual C++
|
---|
209 | * toolchain for storing debug information (.pdb), intermediate compiler state
|
---|
210 | * (.idb) and possibly other things. They are supposedly a win9x alternative to
|
---|
211 | * using NTFS file streams, so the container contains "streams" rather than
|
---|
212 | * "files". (There are some really old version of the PDB files (v1) which does
|
---|
213 | * not contain streams, just plain type/debug info. That is not supported.)
|
---|
214 | *
|
---|
215 | * The streams are numbered and can all be opened by their number, e.g. "1" will
|
---|
216 | * open the PDB metadata header stream. If the stream is special or have an
|
---|
217 | * name table entry, the name will be appended to the stream number together
|
---|
218 | * with a dash. So, stream "1" can also be accessed as "1-pdb". Named streams
|
---|
219 | * will also be recognized by just the name w/o the stream prefix, so stream
|
---|
220 | * also be accessed as just "pdb". The only caveat to this last naming
|
---|
221 | * variation is that it doesn't work of the name starts with a digit, as that is
|
---|
222 | * taken to mean a stream number.
|
---|
223 | *
|
---|
224 | * The RTVFSQIEX_VOL_LABEL returns the PDB cache subdirectory, i.e. UUID+Age or
|
---|
225 | * Timestamp+Age depending on the PDB version.
|
---|
226 | *
|
---|
227 | * The PDB version can be obtained by querying RTVFSQIEX_VOL_LABEL_ALT, which
|
---|
228 | * will return "pdb-v2-xxxxxx" or "pdb-v7-xxxxxxxx", where the 'x' sequences are
|
---|
229 | * digits making up a year-month-date figure for the visual C++ compiler
|
---|
230 | * creating the PDB. Version 2 may have both 6 and 8 digit variants.
|
---|
231 | *
|
---|
232 | * @returns IPRT status code.
|
---|
233 | * @param hVfsFileIn The file or device backing the volume.
|
---|
234 | * @param fFlags RTFSPDB_F_XXX.
|
---|
235 | * @param phVfs Where to return the virtual file system handle.
|
---|
236 | * @param pErrInfo Where to return additional error information.
|
---|
237 | */
|
---|
238 | RTDECL(int) RTFsPdbVolOpen(RTVFSFILE hVfsFileIn, uint32_t fFlags, PRTVFS phVfs, PRTERRINFO pErrInfo);
|
---|
239 |
|
---|
240 | /** @} */
|
---|
241 |
|
---|
242 | RT_C_DECLS_END
|
---|
243 |
|
---|
244 | #endif /* !IPRT_INCLUDED_fsvfs_h */
|
---|
245 |
|
---|