Changeset 48854 in vbox for trunk/src/VBox/Storage
- Timestamp:
- Oct 3, 2013 9:48:48 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89523
- Location:
- trunk/src/VBox/Storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/DMG.cpp
r48852 r48854 457 457 { 458 458 /* 459 * The I/O context stuff seems to complicated and undocument that I'm 460 * not going to bother trying implement this efficiently right now. 459 * Alloate a temporary buffer on the stack or heap and use 460 * vdIfIoIntIoCtxCopyTo to work the context. 461 * 462 * The I/O context stuff seems too complicated and undocument that I'm 463 * not going to bother trying to implement this efficiently right now. 461 464 */ 462 465 void *pvFree = NULL; … … 466 469 else 467 470 pvFree = pvBuf = RTMemTmpAlloc(cbToRead); 468 if ( !pvBuf)471 if (pvBuf) 469 472 { 470 473 rc = RTVfsFileReadAt(pThis->hDmgFileInXar, off, pvBuf, cbToRead, NULL); … … 1441 1444 * @returns VBox status code. 1442 1445 * @param fOpen Flags for defining the open type. 1443 * @param pVDIfs Io The storage I/O interface touse.1446 * @param pVDIfs List of VD I/O interfaces that we can use. 1444 1447 * @param pvStorage The storage pointer that goes with @a pVDIfsIo. 1445 1448 * @param pszFilename The input filename, optional. … … 1452 1455 * is being in serveral places. 1453 1456 */ 1454 static int dmgOpenImageWithinXar(uint32_t fOpen, PVDINTERFACE IO pVDIfsIo, void *pvStorage, const char *pszFilename,1457 static int dmgOpenImageWithinXar(uint32_t fOpen, PVDINTERFACE pVDIfs, void *pvStorage, const char *pszFilename, 1455 1458 PRTVFSFSSTREAM phXarFss, PRTVFSFILE phDmgFileInXar) 1456 1459 { … … 1458 1461 * Open the XAR file stream. 1459 1462 */ 1460 if (!pVDIfsIo)1461 return VERR_INVALID_PARAMETER;1462 1463 1463 RTVFSFILE hVfsFile; 1464 int rc = VDIfCreateVfsFile(pVDIfs Io, pvStorage, fOpen, &hVfsFile);1464 int rc = VDIfCreateVfsFile(pVDIfs, pvStorage, fOpen, &hVfsFile); 1465 1465 if (RT_FAILURE(rc)) 1466 1466 return rc; … … 1566 1566 { 1567 1567 rc = dmgOpenImageWithinXar(VDOpenFlagsToFileOpenFlags(uOpenFlags, false /* fCreate */), 1568 VDIfIoGet(pThis->pVDIfsImage),1568 pThis->pVDIfsImage, 1569 1569 pThis->pStorage, 1570 1570 pThis->pszFilename, … … 1710 1710 { 1711 1711 rc = dmgOpenImageWithinXar(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, 1712 VDIfIoGet(pVDIfsImage), pStorage, NULL /* pszFilename */,1712 pVDIfsImage, pStorage, NULL /* pszFilename */, 1713 1713 &hXarFss, &hDmgFileInXar); 1714 1714 if (RT_FAILURE(rc)) -
trunk/src/VBox/Storage/VDIfVfs.cpp
r48849 r48854 31 31 #include <iprt/poll.h> 32 32 #include <VBox/vd.h> 33 #include <VBox/vd-ifs-internal.h> 33 34 34 35 /******************************************************************************* … … 41 42 typedef struct VDIFVFSIOSFILE 42 43 { 43 /** The VD I/O interface we wrap. */ 44 PVDINTERFACEIO pVDIfsIo; 44 /** The VD I/O interface we prefer wrap. 45 * Can be NULL, in which case pVDIfsIoInt must be valid. */ 46 PVDINTERFACEIO pVDIfsIo; 47 /** The VD I/O interface we alternatively can wrap. 48 Can be NULL, in which case pVDIfsIo must be valid. */ 49 PVDINTERFACEIOINT pVDIfsIoInt; 45 50 /** User pointer to pass to the VD I/O interface methods. */ 46 void *pvStorage;51 PVDIOSTORAGE pStorage; 47 52 /** The current stream position. */ 48 RTFOFF offCurPos;53 RTFOFF offCurPos; 49 54 } VDIFVFSIOSFILE; 50 55 /** Pointer to a the internal data of a DVM volume file. */ … … 89 94 if (off == -1) 90 95 off = pThis->offCurPos; 91 int rc = vdIfIoFileReadSync(pThis->pVDIfsIo, pThis->pvStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbRead); 96 int rc; 97 if (pThis->pVDIfsIo) 98 rc = vdIfIoFileReadSync(pThis->pVDIfsIo, pThis->pStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbRead); 99 else 100 { 101 rc = vdIfIoIntFileReadSync(pThis->pVDIfsIoInt, (PVDIOSTORAGE)pThis->pStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg); 102 if (pcbRead) 103 *pcbRead = RT_SUCCESS(rc) ? pSgBuf->paSegs[0].cbSeg : 0; 104 } 92 105 if (RT_SUCCESS(rc)) 93 106 { … … 115 128 if (off == -1) 116 129 off = pThis->offCurPos; 117 int rc = vdIfIoFileWriteSync(pThis->pVDIfsIo, pThis->pvStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbWritten); 130 int rc; 131 if (pThis->pVDIfsIo) 132 rc = vdIfIoFileWriteSync(pThis->pVDIfsIo, pThis->pStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg, pcbWritten); 133 else 134 { 135 rc = vdIfIoIntFileWriteSync(pThis->pVDIfsIoInt, pThis->pStorage, off, pSgBuf[0].pvSegCur, pSgBuf->paSegs[0].cbSeg); 136 if (pcbWritten) 137 *pcbWritten = RT_SUCCESS(rc) ? pSgBuf->paSegs[0].cbSeg : 0; 138 } 118 139 if (RT_SUCCESS(rc)) 119 140 pThis->offCurPos = off + (pcbWritten ? *pcbWritten : pSgBuf->paSegs[0].cbSeg); … … 128 149 { 129 150 PVDIFVFSIOSFILE pThis = (PVDIFVFSIOSFILE)pvThis; 130 return vdIfIoFileFlushSync(pThis->pVDIfsIo, pThis->pvStorage); 151 int rc; 152 if (pThis->pVDIfsIo) 153 rc = vdIfIoFileFlushSync(pThis->pVDIfsIo, pThis->pStorage); 154 else 155 rc = vdIfIoIntFileFlushSync(pThis->pVDIfsIoInt, pThis->pStorage); 156 return rc; 131 157 } 132 158 … … 202 228 if (RT_SUCCESS(rc)) 203 229 { 204 pThis->pVDIfsIo = pVDIfsIo; 205 pThis->pvStorage = pvStorage; 206 pThis->offCurPos = 0; 230 pThis->pVDIfsIo = pVDIfsIo; 231 pThis->pVDIfsIoInt = NULL; 232 pThis->pStorage = (PVDIOSTORAGE)pvStorage; 233 pThis->offCurPos = 0; 207 234 208 235 *phVfsIos = hVfsIos; … … 262 289 263 290 uint64_t cbFile; 264 int rc = vdIfIoFileGetSize(pThis->pVDIfsIo, pThis->pvStorage, &cbFile); 291 int rc; 292 if (pThis->pVDIfsIo) 293 rc = vdIfIoFileGetSize(pThis->pVDIfsIo, pThis->pStorage, &cbFile); 294 else 295 rc = vdIfIoIntFileGetSize(pThis->pVDIfsIoInt, pThis->pStorage, &cbFile); 265 296 if (RT_FAILURE(rc)) 266 297 return rc; … … 304 335 { 305 336 PVDIFVFSIOSFILE pThis = (PVDIFVFSIOSFILE)pvThis; 306 return vdIfIoFileGetSize(pThis->pVDIfsIo, pThis->pvStorage, pcbFile); 337 int rc; 338 if (pThis->pVDIfsIo) 339 rc = vdIfIoFileGetSize(pThis->pVDIfsIo, pThis->pStorage, pcbFile); 340 else 341 rc = vdIfIoIntFileGetSize(pThis->pVDIfsIoInt, pThis->pStorage, pcbFile); 342 return rc; 307 343 } 308 344 … … 350 386 351 387 352 VBOXDDU_DECL(int) VDIfCreateVfsFile(PVDINTERFACE IO pVDIfsIo, void *pvStorage, uint32_t fFlags, PRTVFSFILE phVfsFile)353 { 354 AssertPtrReturn(pVDIfs Io, VERR_INVALID_HANDLE);388 VBOXDDU_DECL(int) VDIfCreateVfsFile(PVDINTERFACE pVDIfs, void *pvStorage, uint32_t fFlags, PRTVFSFILE phVfsFile) 389 { 390 AssertPtrReturn(pVDIfs, VERR_INVALID_HANDLE); 355 391 AssertPtrReturn(phVfsFile, VERR_INVALID_POINTER); 392 393 PVDINTERFACEIO pPreferred = VDIfIoGet(pVDIfs); 394 PVDINTERFACEIOINT pAlternative = VDIfIoIntGet(pVDIfs); 395 AssertReturn(pPreferred || pAlternative, VERR_INVALID_HANDLE); 356 396 357 397 /* … … 364 404 if (RT_SUCCESS(rc)) 365 405 { 366 pThis->pVDIfsIo = pVDIfsIo; 367 pThis->pvStorage = pvStorage; 368 pThis->offCurPos = 0; 406 pThis->pVDIfsIo = pPreferred; 407 pThis->pVDIfsIoInt = pAlternative; 408 pThis->pStorage = (PVDIOSTORAGE)pvStorage; 409 pThis->offCurPos = 0; 369 410 370 411 *phVfsFile = hVfsFile;
Note:
See TracChangeset
for help on using the changeset viewer.