Changeset 67465 in vbox for trunk/src/VBox
- Timestamp:
- Jun 19, 2017 10:09:26 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VISO.cpp
r67455 r67465 32 32 #include <iprt/mem.h> 33 33 #include <iprt/string.h> 34 #include <iprt/uuid.h> 34 35 35 36 #include "VDBackends.h" … … 42 43 /** The maximum file size. */ 43 44 #if ARCH_BITS >= 64 44 # define VISO_MAX_FILE_SIZE _ 64M45 # define VISO_MAX_FILE_SIZE _32M 45 46 #else 46 # define VISO_MAX_FILE_SIZE _ 16M47 # define VISO_MAX_FILE_SIZE _8M 47 48 #endif 48 49 … … 57 58 typedef struct VISOIMAGE 58 59 { 59 /** The ISO maker output file handle. */ 60 /** The ISO maker output file handle. 61 * This is NIL if in VD_OPEN_FLAGS_INFO mode. */ 60 62 RTVFSFILE hIsoFile; 61 63 /** The image size. */ 62 64 uint64_t cbImage; 65 /** The UUID ofr the image. */ 66 RTUUID Uuid; 67 63 68 /** Open flags passed by VD layer. */ 64 69 uint32_t fOpenFlags; 65 66 70 /** Image name (for debug). 67 71 * Allocation follows the region list, no need to free. */ … … 83 87 * Global Variables * 84 88 *********************************************************************************************************************************/ 85 86 89 /** NULL-terminated array of supported file extensions. */ 87 90 static const VDFILEEXTENSION g_aVBoXIsoMakerFileExtensions[] = 88 91 { 89 { "vbox-iso-maker", VDTYPE_OPTICAL_DISC },92 //{ "vbox-iso-maker", VDTYPE_OPTICAL_DISC }, - clumsy. 90 93 { "viso", VDTYPE_OPTICAL_DISC }, 91 94 { NULL, VDTYPE_INVALID } … … 93 96 94 97 95 96 /** 97 * @interface_method_impl{VDIMAGEBACKEND,pfnProbe} 98 */ 99 static DECLCALLBACK(int) visoProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 100 { 101 /* 102 * Validate input. 103 */ 104 AssertPtrReturn(penmType, VERR_INVALID_POINTER); 105 *penmType = VDTYPE_INVALID; 106 107 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 108 AssertReturn(*pszFilename, VERR_INVALID_POINTER); 109 110 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); 111 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 112 113 RT_NOREF(pVDIfsDisk); 114 115 /* 116 * Open the file. 117 */ 98 /** 99 * Parses the UUID that follows the marker argument. 100 * 101 * @returns IPRT status code. 102 * @param pszMarker The marker. 103 * @param pUuid Where to return the UUID. 104 */ 105 static int visoParseUuid(char *pszMarker, PRTUUID pUuid) 106 { 107 /* Skip the marker. */ 108 char ch; 109 while ( (ch = *pszMarker) != '\0' 110 && !RT_C_IS_SPACE(ch) 111 && ch != ':' 112 && ch != '=') 113 pszMarker++; 114 115 /* Skip chars before the value. */ 116 if ( ch == ':' 117 || ch == '=') 118 ch = *++pszMarker; 119 else 120 while (RT_C_IS_SPACE(ch)) 121 ch = *++pszMarker; 122 const char * const pszUuid = pszMarker; 123 124 /* Find the end of the UUID value. */ 125 while ( ch != '\0' 126 && !RT_C_IS_SPACE(ch)) 127 ch = *++pszMarker; 128 129 /* Validate the value (temporarily terminate the value string) */ 130 *pszMarker = '\0'; 131 int rc = RTUuidFromStr(pUuid, pszUuid); 132 if (RT_SUCCESS(rc)) 133 { 134 *pszMarker = ch; 135 return VINF_SUCCESS; 136 } 137 138 /* Complain and return VERR_VD_IMAGE_CORRUPTED to indicate we've identified 139 the right image format, but the producer got something wrong. */ 140 if (pszUuid != pszMarker) 141 LogRel(("visoParseUuid: Malformed UUID '%s': %Rrc\n", pszUuid, rc)); 142 else 143 LogRel(("visoParseUuid: Empty/missing UUID!\n")); 144 *pszMarker = ch; 145 146 return VERR_VD_IMAGE_CORRUPTED; 147 } 148 149 150 static int visoProbeWorker(const char *pszFilename, PVDINTERFACEIOINT pIfIo, PRTUUID pUuid) 151 { 118 152 PVDIOSTORAGE pStorage = NULL; 119 153 int rc = vdIfIoIntFileOpen(pIfIo, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE, &pStorage); … … 121 155 { 122 156 /* 123 * Read a chunk so we can look for the eye-catcher in the first line.157 * Read the first part of the file. 124 158 */ 125 159 uint64_t cbFile = 0; … … 127 161 if (RT_SUCCESS(rc)) 128 162 { 129 char szChunk[256];163 char szChunk[_1K]; 130 164 size_t cbToRead = (size_t)RT_MIN(sizeof(szChunk) - 1, cbFile); 131 165 rc = vdIfIoIntFileReadSync(pIfIo, pStorage, 0 /*off*/, szChunk, cbToRead); … … 133 167 { 134 168 szChunk[cbToRead] = '\0'; 135 const char *psz = szChunk; 169 170 /* 171 * Skip leading spaces and check for the eye-catcher. 172 */ 173 char *psz = szChunk; 136 174 while (RT_C_IS_SPACE(*psz)) 137 175 psz++; 138 if (str cmp(psz, "--iprt-iso-maker-file-marker") == 0)176 if (strncmp(psz, RT_STR_TUPLE("--iprt-iso-maker-file-marker")) == 0) 139 177 { 140 if (cbFile <= VISO_MAX_FILE_SIZE) 178 rc = visoParseUuid(psz, pUuid); 179 if (RT_SUCCESS(rc)) 141 180 { 142 *penmType = VDTYPE_OPTICAL_DISC; 143 rc = VINF_SUCCESS; 144 } 145 else 146 { 147 LogRel(("visoProbe: VERR_FILE_TOO_BIG - cbFile=%#RX64 cbMaxFile=%#RX64\n", 148 cbFile, (uint64_t)VISO_MAX_FILE_SIZE)); 149 rc = VERR_FILE_TOO_BIG; 181 /* 182 * Check the file size. 183 */ 184 if (cbFile <= VISO_MAX_FILE_SIZE) 185 rc = VINF_SUCCESS; 186 else 187 { 188 LogRel(("visoProbeWorker: VERR_VD_INVALID_SIZE - cbFile=%#RX64 cbMaxFile=%#RX64\n", 189 cbFile, (uint64_t)VISO_MAX_FILE_SIZE)); 190 rc = VERR_VD_INVALID_SIZE; 191 } 150 192 } 151 193 } … … 156 198 vdIfIoIntFileClose(pIfIo, pStorage); 157 199 } 200 LogFlowFunc(("returns %Rrc\n", rc)); 201 return rc; 202 } 203 204 /** 205 * @interface_method_impl{VDIMAGEBACKEND,pfnProbe} 206 */ 207 static DECLCALLBACK(int) visoProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, VDTYPE *penmType) 208 { 209 /* 210 * Validate input. 211 */ 212 AssertPtrReturn(penmType, VERR_INVALID_POINTER); 213 *penmType = VDTYPE_INVALID; 214 215 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 216 AssertReturn(*pszFilename, VERR_INVALID_POINTER); 217 218 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); 219 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 220 221 RT_NOREF(pVDIfsDisk); 222 223 /* 224 * Share worker with visoOpen and visoSetFlags. 225 */ 226 RTUUID UuidIgn; 227 int rc = visoProbeWorker(pszFilename, pIfIo, &UuidIgn); 228 if (RT_SUCCESS(rc)) 229 *penmType = VDTYPE_OPTICAL_DISC; 230 158 231 LogFlowFunc(("returns %Rrc - *penmType=%d\n", rc, *penmType)); 159 232 return rc; 160 233 } 161 234 162 /** 163 * @interface_method_impl{VDIMAGEBACKEND,pfnOpen} 164 */ 165 static DECLCALLBACK(int) visoOpen(const char *pszFilename, unsigned uOpenFlags, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 166 VDTYPE enmType, void **ppBackendData) 167 { 168 LogFlowFunc(("pszFilename='%s' fOpenFlags=%#x pVDIfsDisk=%p pVDIfsImage=%p enmType=%u ppBackendData=%p\n", 169 pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, enmType, ppBackendData)); 170 171 /* 172 * Validate input. 173 */ 174 AssertPtrReturn(ppBackendData, VERR_INVALID_POINTER); 175 *ppBackendData = NULL; 176 177 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 178 AssertReturn(*pszFilename, VERR_INVALID_POINTER); 179 180 AssertReturn(!(uOpenFlags & ~VD_OPEN_FLAGS_MASK), VERR_INVALID_FLAGS); 181 182 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); 183 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 184 185 PVDINTERFACEERROR pIfError = VDIfErrorGet(pVDIfsDisk); 186 187 AssertReturn(enmType == VDTYPE_OPTICAL_DISC, VERR_NOT_SUPPORTED); 188 235 236 /** 237 * Worker for visoOpen and visoSetOpenFlags that creates a VFS file for the ISO. 238 * 239 * This also updates cbImage and the Uuid members. 240 * 241 * @returns 242 * @param pThis . 243 */ 244 static int visoOpenWorker(PVISOIMAGE pThis) 245 { 189 246 /* 190 247 * Open the file and read it into memory. 191 248 */ 192 249 PVDIOSTORAGE pStorage = NULL; 193 int rc = vdIfIoIntFileOpen(pIfIo, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE, &pStorage); 250 int rc = vdIfIoIntFileOpen(pThis->pIfIo, pThis->pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE, &pStorage); 251 if (RT_FAILURE(rc)) 252 return rc; 253 254 /* 255 * Read the file into memory, prefixing it with a dummy command name. 256 */ 257 uint64_t cbFile = 0; 258 rc = vdIfIoIntFileGetSize(pThis->pIfIo, pStorage, &cbFile); 194 259 if (RT_SUCCESS(rc)) 195 260 { 196 /* 197 * Read the file into memory. 198 */ 199 uint64_t cbFile = 0; 200 rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile); 201 if (RT_SUCCESS(rc)) 261 if (cbFile <= VISO_MAX_FILE_SIZE) 202 262 { 203 uint64_t const cbMaxFile = ARCH_BITS >= 64 ? _64M : _16M; 204 if (cbFile <= cbMaxFile) 263 static char const s_szCmdPrefix[] = "VBox-Iso-Maker "; 264 265 char *pszContent = (char *)RTMemTmpAlloc(sizeof(s_szCmdPrefix) + cbFile); 266 if (pszContent) 205 267 { 206 static char const s_szCmdPrefix[] = "VBox-Iso-Maker "; 207 208 char *pszContent = (char *)RTMemTmpAlloc(sizeof(s_szCmdPrefix) + cbFile); 209 if (pszContent) 268 char *pszReadDst = &pszContent[sizeof(s_szCmdPrefix) - 1]; 269 rc = vdIfIoIntFileReadSync(pThis->pIfIo, pStorage, 0 /*off*/, pszReadDst, (size_t)cbFile); 270 if (RT_SUCCESS(rc)) 210 271 { 211 char *pszReadDst = &pszContent[sizeof(s_szCmdPrefix) - 1]; 212 rc = vdIfIoIntFileReadSync(pIfIo, pStorage, 0 /*off*/, pszReadDst, (size_t)cbFile); 213 if (RT_SUCCESS(rc)) 272 /* 273 * Check the file marker and get the UUID that follows it. 274 * Ignore leading blanks. 275 */ 276 pszReadDst[(size_t)cbFile] = '\0'; 277 memcpy(pszContent, s_szCmdPrefix, sizeof(s_szCmdPrefix) - 1); 278 279 while (RT_C_IS_SPACE(*pszReadDst)) 280 pszReadDst++; 281 if (strncmp(pszReadDst, RT_STR_TUPLE("--iprt-iso-maker-file-marker")) == 0) 214 282 { 215 pszReadDst[(size_t)cbFile] = '\0'; 216 memcpy(pszContent, s_szCmdPrefix, sizeof(s_szCmdPrefix) - 1); 217 218 while (RT_C_IS_SPACE(*pszReadDst)) 219 pszReadDst++; 220 if (strcmp(pszReadDst, "--iprt-iso-maker-file-marker") == 0) 283 rc = visoParseUuid(pszReadDst, &pThis->Uuid); 284 if (RT_SUCCESS(rc)) 221 285 { 222 286 /* … … 224 288 * Free the content afterwards to reduce memory pressure. 225 289 */ 290 uint32_t fGetOpt = strncmp(pszReadDst, RT_STR_TUPLE("--iprt-iso-maker-file-marker-ms")) != 0 291 ? RTGETOPTARGV_CNV_QUOTE_BOURNE_SH : RTGETOPTARGV_CNV_QUOTE_MS_CRT; 226 292 char **papszArgs; 227 293 int cArgs; 228 rc = RTGetOptArgvFromString(&papszArgs, &cArgs, pszContent, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);294 rc = RTGetOptArgvFromString(&papszArgs, &cArgs, pszContent, fGetOpt, NULL); 229 295 230 296 RTMemTmpFree(pszContent); … … 251 317 { 252 318 /* 253 * We're good! Just allocate and initialize the backend image instance data.319 * Update the state. 254 320 */ 255 size_t cbFilename = strlen(pszFilename); 256 PVISOIMAGE pThis; 257 pThis = (PVISOIMAGE)RTMemAllocZ( RT_UOFFSETOF(VISOIMAGE, RegionList.aRegions[1]) 258 + cbFilename); 259 if (pThis) 260 { 261 pThis->hIsoFile = hVfsFile; 262 hVfsFile = NIL_RTVFSFILE; 263 pThis->cbImage = cbImage; 264 pThis->fOpenFlags = uOpenFlags; 265 pThis->pszFilename = (char *)memcpy(&pThis->RegionList.aRegions[1], 266 pszFilename, cbFilename); 267 pThis->pIfIo = pIfIo; 268 pThis->pIfError = pIfError; 269 270 pThis->RegionList.fFlags = 0; 271 pThis->RegionList.cRegions = 1; 272 pThis->RegionList.aRegions[0].offRegion = 0; 273 pThis->RegionList.aRegions[0].cRegionBlocksOrBytes = pThis->cbImage; 274 pThis->RegionList.aRegions[0].cbBlock = 2048; 275 pThis->RegionList.aRegions[0].enmDataForm = VDREGIONDATAFORM_RAW; 276 pThis->RegionList.aRegions[0].enmMetadataForm = VDREGIONMETADATAFORM_NONE; 277 pThis->RegionList.aRegions[0].cbData = 2048; 278 pThis->RegionList.aRegions[0].cbMetadata = 0; 279 280 *ppBackendData = pThis; 281 rc = VINF_SUCCESS; 282 } 283 else 284 rc = VERR_NO_MEMORY; 321 pThis->cbImage = cbImage; 322 pThis->RegionList.aRegions[0].cRegionBlocksOrBytes = cbImage; 323 324 pThis->hIsoFile = hVfsFile; 325 hVfsFile = NIL_RTVFSFILE; 326 327 rc = VINF_SUCCESS; 285 328 } 329 286 330 RTVfsFileRelease(hVfsFile); 287 331 } … … 289 333 { 290 334 /** @todo better error reporting! */ 335 if (RTErrInfoIsSet(&ErrInfo.Core)) 336 LogRel(("visoOpenWorker: RTFsIsoMakerCmdEx failed: %Rrc - %s\n", rc, ErrInfo.Core.pszMsg)); 337 else 338 LogRel(("visoOpenWorker: RTFsIsoMakerCmdEx failed: %Rrc\n", rc)); 291 339 } 292 340 } 293 341 } 294 else295 rc = VERR_VD_GEN_INVALID_HEADER;296 342 } 297 298 RTMemTmpFree(pszContent);343 else 344 rc = VERR_VD_GEN_INVALID_HEADER; 299 345 } 300 else 301 rc = VERR_NO_TMP_MEMORY;346 347 RTMemTmpFree(pszContent); 302 348 } 303 349 else 304 { 305 LogRel(("visoOpen: VERR_FILE_TOO_BIG - cbFile=%#RX64 cbMaxFile=%#RX64\n", 306 cbFile, (uint64_t)VISO_MAX_FILE_SIZE)); 307 rc = VERR_FILE_TOO_BIG; 308 } 350 rc = VERR_NO_TMP_MEMORY; 309 351 } 310 vdIfIoIntFileClose(pIfIo, pStorage); 352 else 353 { 354 LogRel(("visoOpen: VERR_VD_INVALID_SIZE - cbFile=%#RX64 cbMaxFile=%#RX64\n", 355 cbFile, (uint64_t)VISO_MAX_FILE_SIZE)); 356 rc = VERR_VD_INVALID_SIZE; 357 } 311 358 } 312 LogFlowFunc(("returns %Rrc (pBackendData=%#p)\n", rc, *ppBackendData)); 359 360 vdIfIoIntFileClose(pThis->pIfIo, pStorage); 313 361 return rc; 314 362 } 363 364 365 /** 366 * @interface_method_impl{VDIMAGEBACKEND,pfnOpen} 367 */ 368 static DECLCALLBACK(int) visoOpen(const char *pszFilename, unsigned uOpenFlags, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 369 VDTYPE enmType, void **ppBackendData) 370 { 371 uint32_t const fOpenFlags = uOpenFlags; 372 LogFlowFunc(("pszFilename='%s' fOpenFlags=%#x pVDIfsDisk=%p pVDIfsImage=%p enmType=%u ppBackendData=%p\n", 373 pszFilename, fOpenFlags, pVDIfsDisk, pVDIfsImage, enmType, ppBackendData)); 374 375 /* 376 * Validate input. 377 */ 378 AssertPtrReturn(ppBackendData, VERR_INVALID_POINTER); 379 *ppBackendData = NULL; 380 381 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); 382 AssertReturn(*pszFilename, VERR_INVALID_POINTER); 383 384 AssertReturn(!(fOpenFlags & ~VD_OPEN_FLAGS_MASK), VERR_INVALID_FLAGS); 385 386 PVDINTERFACEIOINT pIfIo = VDIfIoIntGet(pVDIfsImage); 387 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 388 389 PVDINTERFACEERROR pIfError = VDIfErrorGet(pVDIfsDisk); 390 391 AssertReturn(enmType == VDTYPE_OPTICAL_DISC, VERR_NOT_SUPPORTED); 392 393 /* 394 * Allocate and initialize the backend image instance data. 395 */ 396 int rc; 397 size_t cbFilename = strlen(pszFilename) + 1; 398 PVISOIMAGE pThis = (PVISOIMAGE)RTMemAllocZ(RT_UOFFSETOF(VISOIMAGE, RegionList.aRegions[1]) + cbFilename); 399 if (pThis) 400 { 401 pThis->hIsoFile = NIL_RTVFSFILE; 402 pThis->cbImage = 0; 403 pThis->fOpenFlags = fOpenFlags; 404 pThis->pszFilename = (char *)memcpy(&pThis->RegionList.aRegions[1], pszFilename, cbFilename); 405 pThis->pIfIo = pIfIo; 406 pThis->pIfError = pIfError; 407 408 pThis->RegionList.fFlags = 0; 409 pThis->RegionList.cRegions = 1; 410 pThis->RegionList.aRegions[0].offRegion = 0; 411 pThis->RegionList.aRegions[0].cRegionBlocksOrBytes = 0; 412 pThis->RegionList.aRegions[0].cbBlock = 2048; 413 pThis->RegionList.aRegions[0].enmDataForm = VDREGIONDATAFORM_RAW; 414 pThis->RegionList.aRegions[0].enmMetadataForm = VDREGIONMETADATAFORM_NONE; 415 pThis->RegionList.aRegions[0].cbData = 2048; 416 pThis->RegionList.aRegions[0].cbMetadata = 0; 417 418 /* 419 * Only go all the way if this isn't an info query. Re-mastering an ISO 420 * can potentially be a lot of work and we don't want to go thru with it 421 * just because the GUI wants to display the image size. 422 */ 423 if (!(fOpenFlags & VD_OPEN_FLAGS_INFO)) 424 rc = visoOpenWorker(pThis); 425 else 426 rc = visoProbeWorker(pThis->pszFilename, pThis->pIfIo, &pThis->Uuid); 427 if (RT_SUCCESS(rc)) 428 { 429 *ppBackendData = pThis; 430 LogFlowFunc(("returns VINF_SUCCESS (UUID=%RTuuid, pszFilename=%s)\n", &pThis->Uuid, pThis->pszFilename)); 431 return VINF_SUCCESS; 432 } 433 434 RTMemFree(pThis); 435 } 436 else 437 rc = VERR_NO_MEMORY; 438 LogFlowFunc(("returns %Rrc\n", rc)); 439 return rc; 440 } 441 315 442 316 443 /** … … 327 454 vdIfIoIntFileDelete(pThis->pIfIo, pThis->pszFilename); 328 455 329 RTVfsFileRelease(pThis->hIsoFile); 330 pThis->hIsoFile = NIL_RTVFSFILE; 456 if (pThis->hIsoFile != NIL_RTVFSFILE) 457 { 458 RTVfsFileRelease(pThis->hIsoFile); 459 pThis->hIsoFile = NIL_RTVFSFILE; 460 } 331 461 332 462 RTMemFree(pThis); 333 463 } 334 464 335 LogFlowFunc(("returns VINF_SUCCESS\n" , VINF_SUCCESS));465 LogFlowFunc(("returns VINF_SUCCESS\n")); 336 466 return VINF_SUCCESS; 337 467 } … … 419 549 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 420 550 AssertPtrReturn(pThis, 0); 421 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, 0);422 551 LogFlowFunc(("pThis=%#p -> 1\n", pThis)); 423 552 return 1; … … 431 560 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 432 561 AssertPtrReturn(pThis, 0); 433 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, 0); 434 LogFlowFunc(("pThis=%p -> %RX64\n", pThis, pThis->cbImage)); 562 LogFlowFunc(("pThis=%p -> %RX64 (%s)\n", pThis, pThis->cbImage, pThis->hIsoFile == NIL_RTVFSFILE ? "fake!" : "real")); 435 563 return pThis->cbImage; 436 564 } … … 443 571 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 444 572 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 445 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, VERR_VD_NOT_OPENED);446 573 LogFlowFunc(("pThis=%p pPCHSGeometry=%p -> VERR_NOT_SUPPORTED\n", pThis, pPCHSGeometry)); 447 574 RT_NOREF(pPCHSGeometry); … … 456 583 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 457 584 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 458 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, VERR_VD_NOT_OPENED);459 585 LogFlowFunc(("pThis=%p pPCHSGeometry=%p:{%u/%u/%u} -> VERR_VD_IMAGE_READ_ONLY\n", 460 586 pThis, pPCHSGeometry, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); … … 470 596 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 471 597 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 472 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, VERR_VD_NOT_OPENED);473 598 LogFlowFunc(("pThis=%p pLCHSGeometry=%p -> VERR_NOT_SUPPORTED\n", pThis, pLCHSGeometry)); 474 599 RT_NOREF(pLCHSGeometry); … … 483 608 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 484 609 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 485 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, VERR_VD_NOT_OPENED);486 610 LogFlowFunc(("pThis=%p pLCHSGeometry=%p:{%u/%u/%u} -> VERR_VD_IMAGE_READ_ONLY\n", 487 611 pThis, pLCHSGeometry, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors)); … … 496 620 { 497 621 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 498 LogFlowFunc(("pThis=%p ppRegionList=%p\n", pThis, ppRegionList));499 500 622 *ppRegionList = NULL; 501 623 AssertPtrReturn(pThis, VERR_VD_NOT_OPENED); 502 AssertReturn(pThis->hIsoFile != NIL_RTVFSFILE, VERR_VD_NOT_OPENED);503 624 504 625 *ppRegionList = &pThis->RegionList; 626 LogFlowFunc(("returns VINF_SUCCESS (one region: 0 LB %RX64; pThis=%p)\n", pThis->RegionList.aRegions[0].cbData, pThis)); 505 627 return VINF_SUCCESS; 506 628 } … … 525 647 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 526 648 LogFlowFunc(("pThis=%p -> VD_IMAGE_FLAGS_NONE\n", pThis)); 527 AssertPtr (pThis); NOREF(pThis);649 AssertPtrReturn(pThis, VD_IMAGE_FLAGS_NONE); 528 650 return VD_IMAGE_FLAGS_NONE; 529 651 } … … 557 679 558 680 /* 559 * No need to re-open the image, since it's always read-only and we ignore 560 * all the other flags. Just remember them for the getter (visoGetOpenFlags). 681 * Only react if we switch from VD_OPEN_FLAGS_INFO to non-VD_OPEN_FLAGS_INFO mode, 682 * becuase that means we need to open the image. 683 */ 684 if ( (pThis->fOpenFlags & VD_OPEN_FLAGS_INFO) 685 && !(uOpenFlags & VD_OPEN_FLAGS_INFO) 686 && pThis->hIsoFile == NIL_RTVFSFILE) 687 { 688 int rc = visoOpenWorker(pThis); 689 if (RT_FAILURE(rc)) 690 { 691 LogFlowFunc(("returns %Rrc\n", rc)); 692 return rc; 693 } 694 } 695 696 /* 697 * Update the flags. 561 698 */ 562 699 pThis->fOpenFlags &= ~fSupported; 563 700 pThis->fOpenFlags |= fSupported & uOpenFlags; 564 701 pThis->fOpenFlags |= VD_OPEN_FLAGS_READONLY; 702 if (pThis->hIsoFile != NIL_RTVFSFILE) 703 pThis->fOpenFlags &= ~VD_OPEN_FLAGS_INFO; 565 704 566 705 return VINF_SUCCESS; … … 582 721 * @interface_method_impl{VDIMAGEBACKEND,pfnGetUuid} 583 722 */ 584 VD_BACKEND_CALLBACK_GET_UUID_DEF_NOT_SUPPORTED(visoGetUuid); 723 static DECLCALLBACK(int) visoGetUuid(void *pBackendData, PRTUUID pUuid) 724 { 725 PVISOIMAGE pThis = (PVISOIMAGE)pBackendData; 726 *pUuid = pThis->Uuid; 727 LogFlowFunc(("returns VIF_SUCCESS (%RTuuid)\n", pUuid)); 728 return VINF_SUCCESS; 729 } 585 730 586 731 /**
Note:
See TracChangeset
for help on using the changeset viewer.