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