1 | /* $Id: HostDrivePartitionImpl.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Main - IHostDrivePartition implementation, VBoxSVC.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2024 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 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #define LOG_GROUP LOG_GROUP_MAIN_HOSTDRIVEPARTITION
|
---|
29 | #include "HostDrivePartitionImpl.h"
|
---|
30 | #include "LoggingNew.h"
|
---|
31 |
|
---|
32 | #include <iprt/errcore.h>
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * HostDrivePartition implementation.
|
---|
36 | */
|
---|
37 | DEFINE_EMPTY_CTOR_DTOR(HostDrivePartition)
|
---|
38 |
|
---|
39 | HRESULT HostDrivePartition::FinalConstruct()
|
---|
40 | {
|
---|
41 | return BaseFinalConstruct();
|
---|
42 | }
|
---|
43 |
|
---|
44 | void HostDrivePartition::FinalRelease()
|
---|
45 | {
|
---|
46 | uninit();
|
---|
47 |
|
---|
48 | BaseFinalRelease();
|
---|
49 | }
|
---|
50 |
|
---|
51 | /*
|
---|
52 | * Initializes the instance.
|
---|
53 | */
|
---|
54 | HRESULT HostDrivePartition::initFromDvmVol(RTDVMVOLUME hVol)
|
---|
55 | {
|
---|
56 | LogFlowThisFunc(("\n"));
|
---|
57 |
|
---|
58 | AssertReturn(hVol != NIL_RTDVMVOLUME, E_INVALIDARG);
|
---|
59 |
|
---|
60 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
61 | AutoInitSpan autoInitSpan(this);
|
---|
62 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
63 |
|
---|
64 | /* Common attributes: */
|
---|
65 | m.number = RTDvmVolumeGetIndex(hVol, RTDVMVOLIDX_HOST);
|
---|
66 | m.cbVol = (LONG64)RTDvmVolumeGetSize(hVol);
|
---|
67 | if (m.cbVol < 0)
|
---|
68 | m.cbVol = INT64_MAX;
|
---|
69 |
|
---|
70 | uint64_t offStart = 0;
|
---|
71 | uint64_t offLastIgnored = 0;
|
---|
72 | int vrc = RTDvmVolumeQueryRange(hVol, &offStart, &offLastIgnored);
|
---|
73 | AssertRC(vrc);
|
---|
74 | m.offStart = RT_SUCCESS(vrc) ? (LONG64)offStart : 0;
|
---|
75 | Assert((uint64_t)m.cbVol == offLastIgnored - offStart + 1 || RT_FAILURE(vrc));
|
---|
76 | if (m.offStart < 0)
|
---|
77 | m.offStart = INT64_MAX;
|
---|
78 |
|
---|
79 | uint64_t fFlags = RTDvmVolumeGetFlags(hVol);
|
---|
80 | m.active = (fFlags & (DVMVOLUME_FLAGS_BOOTABLE | DVMVOLUME_FLAGS_ACTIVE)) != 0;
|
---|
81 |
|
---|
82 | /* MBR: */
|
---|
83 | m.firstCylinder = (uint16_t)RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_FIRST_CYLINDER, 0);
|
---|
84 | m.firstHead = (uint8_t )RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_FIRST_HEAD, 0);
|
---|
85 | m.firstSector = (uint8_t )RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_FIRST_SECTOR, 0);
|
---|
86 | m.lastCylinder = (uint16_t)RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_LAST_CYLINDER, 0);
|
---|
87 | m.lastHead = (uint8_t )RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_LAST_HEAD, 0);
|
---|
88 | m.lastSector = (uint8_t )RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_LAST_SECTOR, 0);
|
---|
89 | m.bMBRType = (uint8_t )RTDvmVolumeGetPropU64(hVol, RTDVMVOLPROP_MBR_TYPE, 0);
|
---|
90 |
|
---|
91 | /* GPT: */
|
---|
92 | RTUUID Uuid;
|
---|
93 | vrc = RTDvmVolumeQueryProp(hVol, RTDVMVOLPROP_GPT_TYPE, &Uuid, sizeof(Uuid), NULL);
|
---|
94 | if (RT_SUCCESS(vrc))
|
---|
95 | m.typeUuid = Uuid;
|
---|
96 | vrc = RTDvmVolumeQueryProp(hVol, RTDVMVOLPROP_GPT_UUID, &Uuid, sizeof(Uuid), NULL);
|
---|
97 | if (RT_SUCCESS(vrc))
|
---|
98 | m.uuid = Uuid;
|
---|
99 |
|
---|
100 | char *pszName = NULL;
|
---|
101 | vrc = RTDvmVolumeQueryName(hVol, &pszName);
|
---|
102 | if (RT_SUCCESS(vrc))
|
---|
103 | {
|
---|
104 | HRESULT hrc = m.name.assignEx(pszName);
|
---|
105 | RTStrFree(pszName);
|
---|
106 | AssertComRCReturn(hrc, hrc);
|
---|
107 | }
|
---|
108 |
|
---|
109 | /*
|
---|
110 | * Do the type translation to the best of our ability.
|
---|
111 | */
|
---|
112 | m.enmType = PartitionType_Unknown;
|
---|
113 | if (m.typeUuid.isZero())
|
---|
114 | switch ((PartitionType_T)m.bMBRType)
|
---|
115 | {
|
---|
116 | case PartitionType_FAT12:
|
---|
117 | case PartitionType_FAT16:
|
---|
118 | case PartitionType_FAT:
|
---|
119 | case PartitionType_IFS:
|
---|
120 | case PartitionType_FAT32CHS:
|
---|
121 | case PartitionType_FAT32LBA:
|
---|
122 | case PartitionType_FAT16B:
|
---|
123 | case PartitionType_Extended:
|
---|
124 | case PartitionType_WindowsRE:
|
---|
125 | case PartitionType_LinuxSwapOld:
|
---|
126 | case PartitionType_LinuxOld:
|
---|
127 | case PartitionType_DragonFlyBSDSlice:
|
---|
128 | case PartitionType_LinuxSwap:
|
---|
129 | case PartitionType_Linux:
|
---|
130 | case PartitionType_LinuxExtended:
|
---|
131 | case PartitionType_LinuxLVM:
|
---|
132 | case PartitionType_BSDSlice:
|
---|
133 | case PartitionType_AppleUFS:
|
---|
134 | case PartitionType_AppleHFS:
|
---|
135 | case PartitionType_Solaris:
|
---|
136 | case PartitionType_GPT:
|
---|
137 | case PartitionType_EFI:
|
---|
138 | m.enmType = (PartitionType_T)m.bMBRType;
|
---|
139 | break;
|
---|
140 |
|
---|
141 | case PartitionType_Empty:
|
---|
142 | default:
|
---|
143 | break;
|
---|
144 | }
|
---|
145 | else
|
---|
146 | {
|
---|
147 | static struct { const char *pszUuid; PartitionType_T enmType; } const s_aUuidToType[] =
|
---|
148 | {
|
---|
149 | { "024dee41-33e7-11d3-9d69-0008c781f39f", PartitionType_MBR },
|
---|
150 | { "c12a7328-f81f-11d2-ba4b-00a0c93ec93b", PartitionType_EFI },
|
---|
151 | { "d3bfe2de-3daf-11df-ba40-e3a556d89593", PartitionType_iFFS },
|
---|
152 | { "f4019732-066e-4e12-8273-346c5641494f", PartitionType_SonyBoot },
|
---|
153 | { "bfbfafe7-a34f-448a-9a5b-6213eb736c22", PartitionType_LenovoBoot },
|
---|
154 | /* Win: */
|
---|
155 | { "e3c9e316-0b5c-4db8-817d-f92df00215ae", PartitionType_WindowsMSR },
|
---|
156 | { "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7", PartitionType_WindowsBasicData },
|
---|
157 | { "5808c8aa-7e8f-42e0-85d2-e1e90434cfb3", PartitionType_WindowsLDMMeta },
|
---|
158 | { "af9b60a0-1431-4f62-bc68-3311714a69ad", PartitionType_WindowsLDMData },
|
---|
159 | { "de94bba4-06d1-4d40-a16a-bfd50179d6ac", PartitionType_WindowsRecovery },
|
---|
160 | { "e75caf8f-f680-4cee-afa3-b001e56efc2d", PartitionType_WindowsStorageSpaces },
|
---|
161 | { "558d43c5-a1ac-43c0-aac8-d1472b2923d1", PartitionType_WindowsStorageReplica },
|
---|
162 | { "37affc90-ef7d-4e96-91c3-2d7ae055b174", PartitionType_IBMGPFS },
|
---|
163 | /* Linux: */
|
---|
164 | { "0fc63daf-8483-4772-8e79-3d69d8477de4", PartitionType_LinuxData },
|
---|
165 | { "a19d880f-05fc-4d3b-a006-743f0f84911e", PartitionType_LinuxRAID },
|
---|
166 | { "44479540-f297-41b2-9af7-d131d5f0458a", PartitionType_LinuxRootX86 },
|
---|
167 | { "4f68bce3-e8cd-4db1-96e7-fbcaf984b709", PartitionType_LinuxRootAMD64 },
|
---|
168 | { "69dad710-2ce4-4e3c-b16c-21a1d49abed3", PartitionType_LinuxRootARM32 },
|
---|
169 | { "b921b045-1df0-41c3-af44-4c6f280d3fae", PartitionType_LinuxRootARM64 },
|
---|
170 | { "933ac7e1-2eb4-4f13-b844-0e14e2aef915", PartitionType_LinuxHome },
|
---|
171 | { "3b8f8425-20e0-4f3b-907f-1a25a76f98e8", PartitionType_LinuxSrv },
|
---|
172 | { "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f", PartitionType_LinuxSwap },
|
---|
173 | { "e6d6d379-f507-44c2-a23c-238f2a3df928", PartitionType_LinuxLVM },
|
---|
174 | { "7ffec5c9-2d00-49b7-8941-3ea10a5586b7", PartitionType_LinuxPlainDmCrypt },
|
---|
175 | { "ca7d7ccb-63ed-4c53-861c-1742536059cc", PartitionType_LinuxLUKS },
|
---|
176 | { "8da63339-0007-60c0-c436-083ac8230908", PartitionType_LinuxReserved },
|
---|
177 | /* FreeBSD: */
|
---|
178 | { "83bd6b9d-7f41-11dc-be0b-001560b84f0f", PartitionType_FreeBSDBoot },
|
---|
179 | { "516e7cb4-6ecf-11d6-8ff8-00022d09712b", PartitionType_FreeBSDData },
|
---|
180 | { "516e7cb5-6ecf-11d6-8ff8-00022d09712b", PartitionType_FreeBSDSwap },
|
---|
181 | { "516e7cb6-6ecf-11d6-8ff8-00022d09712b", PartitionType_FreeBSDUFS },
|
---|
182 | { "516e7cb8-6ecf-11d6-8ff8-00022d09712b", PartitionType_FreeBSDVinum },
|
---|
183 | { "516e7cba-6ecf-11d6-8ff8-00022d09712b", PartitionType_FreeBSDZFS },
|
---|
184 | /* Apple/macOS: */
|
---|
185 | { "48465300-0000-11aa-aa11-00306543ecac", PartitionType_AppleHFSPlus },
|
---|
186 | { "7c3457ef-0000-11aa-aa11-00306543ecac", PartitionType_AppleAPFS },
|
---|
187 | { "55465300-0000-11aa-aa11-00306543ecac", PartitionType_AppleUFS },
|
---|
188 | { "52414944-0000-11aa-aa11-00306543ecac", PartitionType_AppleRAID },
|
---|
189 | { "52414944-5f4f-11aa-aa11-00306543ecac", PartitionType_AppleRAIDOffline },
|
---|
190 | { "426f6f74-0000-11aa-aa11-00306543ecac", PartitionType_AppleBoot },
|
---|
191 | { "4c616265-6c00-11aa-aa11-00306543ecac", PartitionType_AppleLabel },
|
---|
192 | { "5265636f-7665-11aa-aa11-00306543ecac", PartitionType_AppleTvRecovery },
|
---|
193 | { "53746f72-6167-11aa-aa11-00306543ecac", PartitionType_AppleCoreStorage },
|
---|
194 | { "b6fa30da-92d2-4a9a-96f1-871ec6486200", PartitionType_SoftRAIDStatus },
|
---|
195 | { "2e313465-19b9-463f-8126-8a7993773801", PartitionType_SoftRAIDScratch },
|
---|
196 | { "fa709c7e-65b1-4593-bfd5-e71d61de9b02", PartitionType_SoftRAIDVolume },
|
---|
197 | { "bbba6df5-f46f-4a89-8f59-8765b2727503", PartitionType_SoftRAIDCache },
|
---|
198 | /* Solaris */
|
---|
199 | { "6a82cb45-1dd2-11b2-99a6-080020736631", PartitionType_SolarisBoot },
|
---|
200 | { "6a85cf4d-1dd2-11b2-99a6-080020736631", PartitionType_SolarisRoot },
|
---|
201 | { "6a87c46f-1dd2-11b2-99a6-080020736631", PartitionType_SolarisSwap },
|
---|
202 | { "6a8b642b-1dd2-11b2-99a6-080020736631", PartitionType_SolarisBackup },
|
---|
203 | { "6a898cc3-1dd2-11b2-99a6-080020736631", PartitionType_SolarisUsr },
|
---|
204 | { "6a8ef2e9-1dd2-11b2-99a6-080020736631", PartitionType_SolarisVar },
|
---|
205 | { "6a90ba39-1dd2-11b2-99a6-080020736631", PartitionType_SolarisHome },
|
---|
206 | { "6a9283a5-1dd2-11b2-99a6-080020736631", PartitionType_SolarisAltSector },
|
---|
207 | { "6a945a3b-1dd2-11b2-99a6-080020736631", PartitionType_SolarisReserved },
|
---|
208 | { "6a9630d1-1dd2-11b2-99a6-080020736631", PartitionType_SolarisReserved },
|
---|
209 | { "6a980767-1dd2-11b2-99a6-080020736631", PartitionType_SolarisReserved },
|
---|
210 | { "6a96237f-1dd2-11b2-99a6-080020736631", PartitionType_SolarisReserved },
|
---|
211 | { "6a8d2ac7-1dd2-11b2-99a6-080020736631", PartitionType_SolarisReserved },
|
---|
212 | /* NetBSD: */
|
---|
213 | { "49f48d32-b10e-11dc-b99b-0019d1879648", PartitionType_NetBSDSwap },
|
---|
214 | { "49f48d5a-b10e-11dc-b99b-0019d1879648", PartitionType_NetBSDFFS },
|
---|
215 | { "49f48d82-b10e-11dc-b99b-0019d1879648", PartitionType_NetBSDLFS },
|
---|
216 | { "49f48daa-b10e-11dc-b99b-0019d1879648", PartitionType_NetBSDRAID },
|
---|
217 | { "2db519c4-b10f-11dc-b99b-0019d1879648", PartitionType_NetBSDConcatenated },
|
---|
218 | { "2db519ec-b10f-11dc-b99b-0019d1879648", PartitionType_NetBSDEncrypted },
|
---|
219 | /* Chrome OS: */
|
---|
220 | { "fe3a2a5d-4f32-41a7-b725-accc3285a309", PartitionType_ChromeOSKernel },
|
---|
221 | { "3cb8e202-3b7e-47dd-8a3c-7ff2a13cfcec", PartitionType_ChromeOSRootFS },
|
---|
222 | { "2e0a753d-9e48-43b0-8337-b15192cb1b5e", PartitionType_ChromeOSFuture },
|
---|
223 | /* Container Linux: */
|
---|
224 | { "5dfbf5f4-2848-4bac-aa5e-0d9a20b745a6", PartitionType_ContLnxUsr },
|
---|
225 | { "3884dd41-8582-4404-b9a8-e9b84f2df50e", PartitionType_ContLnxRoot },
|
---|
226 | { "c95dc21a-df0e-4340-8d7b-26cbfa9a03e0", PartitionType_ContLnxReserved },
|
---|
227 | { "be9067b9-ea49-4f15-b4f6-f36f8c9e1818", PartitionType_ContLnxRootRAID },
|
---|
228 | /* Haiku: */
|
---|
229 | { "42465331-3ba3-10f1-802a-4861696b7521", PartitionType_HaikuBFS },
|
---|
230 | /* MidnightBSD */
|
---|
231 | { "85d5e45e-237c-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDBoot },
|
---|
232 | { "85d5e45a-237c-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDData },
|
---|
233 | { "85d5e45b-237c-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDSwap },
|
---|
234 | { "0394ef8b-237e-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDUFS },
|
---|
235 | { "85d5e45c-237c-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDVium },
|
---|
236 | { "85d5e45d-237c-11e1-b4b3-e89a8f7fc3a7", PartitionType_MidntBSDZFS },
|
---|
237 | /* OpenBSD: */
|
---|
238 | { "824cc7a0-36a8-11e3-890a-952519ad3f61", PartitionType_OpenBSDData },
|
---|
239 | /* QNX: */
|
---|
240 | { "cef5a9ad-73bc-4601-89f3-cdeeeee321a1", PartitionType_QNXPowerSafeFS },
|
---|
241 | /* Plan 9: */
|
---|
242 | { "c91818f9-8025-47af-89d2-f030d7000c2c", PartitionType_Plan9 },
|
---|
243 | /* VMWare ESX: */
|
---|
244 | { "9d275380-40ad-11db-bf97-000c2911d1b8", PartitionType_VMWareVMKCore },
|
---|
245 | { "aa31e02a-400f-11db-9590-000c2911d1b8", PartitionType_VMWareVMFS },
|
---|
246 | { "9198effc-31c0-11db-8f78-000c2911d1b8", PartitionType_VMWareReserved },
|
---|
247 | /* Android-x86: */
|
---|
248 | { "2568845d-2332-4675-bc39-8fa5a4748d15", PartitionType_AndroidX86Bootloader },
|
---|
249 | { "114eaffe-1552-4022-b26e-9b053604cf84", PartitionType_AndroidX86Bootloader2 },
|
---|
250 | { "49a4d17f-93a3-45c1-a0de-f50b2ebe2599", PartitionType_AndroidX86Boot },
|
---|
251 | { "4177c722-9e92-4aab-8644-43502bfd5506", PartitionType_AndroidX86Recovery },
|
---|
252 | { "ef32a33b-a409-486c-9141-9ffb711f6266", PartitionType_AndroidX86Misc },
|
---|
253 | { "20ac26be-20b7-11e3-84c5-6cfdb94711e9", PartitionType_AndroidX86Metadata },
|
---|
254 | { "38f428e6-d326-425d-9140-6e0ea133647c", PartitionType_AndroidX86System },
|
---|
255 | { "a893ef21-e428-470a-9e55-0668fd91a2d9", PartitionType_AndroidX86Cache },
|
---|
256 | { "dc76dda9-5ac1-491c-af42-a82591580c0d", PartitionType_AndroidX86Data },
|
---|
257 | { "ebc597d0-2053-4b15-8b64-e0aac75f4db1", PartitionType_AndroidX86Persistent },
|
---|
258 | { "c5a0aeec-13ea-11e5-a1b1-001e67ca0c3c", PartitionType_AndroidX86Vendor },
|
---|
259 | { "bd59408b-4514-490d-bf12-9878d963f378", PartitionType_AndroidX86Config },
|
---|
260 | { "8f68cc74-c5e5-48da-be91-a0c8c15e9c80", PartitionType_AndroidX86Factory },
|
---|
261 | { "9fdaa6ef-4b3f-40d2-ba8d-bff16bfb887b", PartitionType_AndroidX86FactoryAlt },
|
---|
262 | { "767941d0-2085-11e3-ad3b-6cfdb94711e9", PartitionType_AndroidX86Fastboot },
|
---|
263 | { "ac6d7924-eb71-4df8-b48d-e267b27148ff", PartitionType_AndroidX86OEM },
|
---|
264 | /* Android ARM: */
|
---|
265 | { "19a710a2-b3ca-11e4-b026-10604b889dcf", PartitionType_AndroidARMMeta },
|
---|
266 | { "193d1ea4-b3ca-11e4-b075-10604b889dcf", PartitionType_AndroidARMExt },
|
---|
267 | /* Open Network Install Environment: */
|
---|
268 | { "7412f7d5-a156-4b13-81dc-867174929325", PartitionType_ONIEBoot },
|
---|
269 | { "d4e6e2cd-4469-46f3-b5cb-1bff57afc149", PartitionType_ONIEConfig },
|
---|
270 | /* PowerPC: */
|
---|
271 | { "9e1a2d38-c612-4316-aa26-8b49521e5a8b", PartitionType_PowerPCPrep },
|
---|
272 | /* freedesktop.org: */
|
---|
273 | { "bc13c2ff-59e6-4262-a352-b275fd6f7172", PartitionType_XDGShrBootConfig },
|
---|
274 | /* Ceph: */
|
---|
275 | { "cafecafe-9b03-4f30-b4c6-b4b80ceff106", PartitionType_CephBlock },
|
---|
276 | { "30cd0809-c2b2-499c-8879-2d6b78529876", PartitionType_CephBlockDB },
|
---|
277 | { "93b0052d-02d9-4d8a-a43b-33a3ee4dfbc3", PartitionType_CephBlockDBDmc },
|
---|
278 | { "166418da-c469-4022-adf4-b30afd37f176", PartitionType_CephBlockDBDmcLUKS },
|
---|
279 | { "cafecafe-9b03-4f30-b4c6-5ec00ceff106", PartitionType_CephBlockDmc },
|
---|
280 | { "cafecafe-9b03-4f30-b4c6-35865ceff106", PartitionType_CephBlockDmcLUKS },
|
---|
281 | { "5ce17fce-4087-4169-b7ff-056cc58473f9", PartitionType_CephBlockWALog },
|
---|
282 | { "306e8683-4fe2-4330-b7c0-00a917c16966", PartitionType_CephBlockWALogDmc },
|
---|
283 | { "86a32090-3647-40b9-bbbd-38d8c573aa86", PartitionType_CephBlockWALogDmcLUKS },
|
---|
284 | { "89c57f98-2fe5-4dc0-89c1-f3ad0ceff2be", PartitionType_CephDisk },
|
---|
285 | { "89c57f98-2fe5-4dc0-89c1-5ec00ceff2be", PartitionType_CephDiskDmc },
|
---|
286 | { "45b0969e-9b03-4f30-b4c6-b4b80ceff106", PartitionType_CephJournal },
|
---|
287 | { "45b0969e-9b03-4f30-b4c6-5ec00ceff106", PartitionType_CephJournalDmc },
|
---|
288 | { "45b0969e-9b03-4f30-b4c6-35865ceff106", PartitionType_CephJournalDmcLUKS },
|
---|
289 | { "fb3aabf9-d25f-47cc-bf5e-721d1816496b", PartitionType_CephLockbox },
|
---|
290 | { "cafecafe-8ae0-4982-bf9d-5a8d867af560", PartitionType_CephMultipathBlock1 },
|
---|
291 | { "7f4a666a-16f3-47a2-8445-152ef4d03f6c", PartitionType_CephMultipathBlock2 },
|
---|
292 | { "ec6d6385-e346-45dc-be91-da2a7c8b3261", PartitionType_CephMultipathBlockDB },
|
---|
293 | { "01b41e1b-002a-453c-9f17-88793989ff8f", PartitionType_CephMultipathBLockWALog },
|
---|
294 | { "45b0969e-8ae0-4982-bf9d-5a8d867af560", PartitionType_CephMultipathJournal },
|
---|
295 | { "4fbd7e29-8ae0-4982-bf9d-5a8d867af560", PartitionType_CephMultipathOSD },
|
---|
296 | { "4fbd7e29-9d25-41b8-afd0-062c0ceff05d", PartitionType_CephOSD },
|
---|
297 | { "4fbd7e29-9d25-41b8-afd0-5ec00ceff05d", PartitionType_CephOSDDmc },
|
---|
298 | { "4fbd7e29-9d25-41b8-afd0-35865ceff05d", PartitionType_CephOSDDmcLUKS },
|
---|
299 | };
|
---|
300 | for (size_t i = 0; i < RT_ELEMENTS(s_aUuidToType); i++)
|
---|
301 | if (m.typeUuid.equalsString(s_aUuidToType[i].pszUuid))
|
---|
302 | {
|
---|
303 | m.enmType = s_aUuidToType[i].enmType;
|
---|
304 | break;
|
---|
305 | }
|
---|
306 |
|
---|
307 | /* Some OSes are using non-random UUIDs and we can at least identify the
|
---|
308 | OS if not the exact type. */
|
---|
309 | if (m.enmType == PartitionType_Unknown)
|
---|
310 | {
|
---|
311 | char szType[RTUUID_STR_LENGTH];
|
---|
312 | m.typeUuid.toString(szType, sizeof(szType));
|
---|
313 | RTStrToLower(szType);
|
---|
314 | if (RTStrSimplePatternMatch(szType, "516e7c??-6ecf-11d6-8ff8-00022d09712b"))
|
---|
315 | m.enmType = PartitionType_FreeBSDUnknown;
|
---|
316 | else if (RTStrSimplePatternMatch(szType, "????????-????-11aa-aa11-00306543ecac"))
|
---|
317 | m.enmType = PartitionType_AppleUnknown;
|
---|
318 | else if (RTStrSimplePatternMatch(szType, "????????-1dd2-11b2-99a6-080020736631"))
|
---|
319 | m.enmType = PartitionType_SolarisUnknown;
|
---|
320 | else if (RTStrSimplePatternMatch(szType, "????????-b1??-11dc-b99b-0019d1879648"))
|
---|
321 | m.enmType = PartitionType_NetBSDUnknown;
|
---|
322 | else if (RTStrSimplePatternMatch(szType, "????????-23??-11e1-b4b3-e89a8f7fc3a7"))
|
---|
323 | m.enmType = PartitionType_MidntBSDUnknown;
|
---|
324 | else if (RTStrSimplePatternMatch(szType, "????????-????-11db-????-000c2911d1b8"))
|
---|
325 | m.enmType = PartitionType_VMWareUnknown;
|
---|
326 | }
|
---|
327 |
|
---|
328 | #ifdef VBOX_STRICT
|
---|
329 | /* Make sure we've done have any duplicates in the translation table: */
|
---|
330 | static bool s_fCheckedForDuplicates = false;
|
---|
331 | if (!s_fCheckedForDuplicates)
|
---|
332 | {
|
---|
333 | for (size_t i = 0; i < RT_ELEMENTS(s_aUuidToType); i++)
|
---|
334 | for (size_t j = i + 1; j < RT_ELEMENTS(s_aUuidToType); j++)
|
---|
335 | AssertMsg(RTUuidCompare2Strs(s_aUuidToType[i].pszUuid, s_aUuidToType[j].pszUuid) != 0,
|
---|
336 | ("%d & %d: %s\n", i, j, s_aUuidToType[i].pszUuid));
|
---|
337 | s_fCheckedForDuplicates = true;
|
---|
338 | }
|
---|
339 | #endif
|
---|
340 |
|
---|
341 | }
|
---|
342 |
|
---|
343 | /* Confirm a successful initialization */
|
---|
344 | autoInitSpan.setSucceeded();
|
---|
345 |
|
---|
346 | return S_OK;
|
---|
347 | }
|
---|
348 |
|
---|
349 | /*
|
---|
350 | * Uninitializes the instance.
|
---|
351 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
352 | */
|
---|
353 | void HostDrivePartition::uninit()
|
---|
354 | {
|
---|
355 | LogFlowThisFunc(("\n"));
|
---|
356 |
|
---|
357 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
358 | AutoUninitSpan autoUninitSpan(this);
|
---|
359 | if (autoUninitSpan.uninitDone())
|
---|
360 | return;
|
---|
361 |
|
---|
362 | m.number = 0;
|
---|
363 | m.cbVol = 0;
|
---|
364 | m.offStart = 0;
|
---|
365 | m.enmType = PartitionType_Empty;
|
---|
366 | m.active = 0;
|
---|
367 |
|
---|
368 | m.bMBRType = 0;
|
---|
369 | m.firstCylinder = 0;
|
---|
370 | m.firstHead = 0;
|
---|
371 | m.firstSector = 0;
|
---|
372 | m.lastCylinder = 0;
|
---|
373 | m.lastHead = 0;
|
---|
374 | m.lastSector = 0;
|
---|
375 |
|
---|
376 | m.typeUuid.clear();
|
---|
377 | m.uuid.clear();
|
---|
378 | m.name.setNull();
|
---|
379 | }
|
---|
380 |
|
---|
381 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|