- Timestamp:
- Mar 30, 2010 8:43:53 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r27808 r27815 215 215 typedef struct VDIOSTORAGE 216 216 { 217 /** Storage handle */ 218 void *pStorage; 217 union 218 { 219 /** Storage handle */ 220 void *pStorage; 221 /** File handle for the limited I/O version. */ 222 RTFILE hFile; 223 } u; 219 224 } VDIOSTORAGE; 220 225 … … 1200 1205 vdIOReqCompleted, 1201 1206 pDisk->pVDIfsDisk, 1202 &pIoStorage-> pStorage);1207 &pIoStorage->u.pStorage); 1203 1208 if (RT_SUCCESS(rc)) 1204 1209 *ppIoStorage = pIoStorage; … … 1214 1219 1215 1220 int rc = pDisk->pInterfaceAsyncIOCallbacks->pfnClose(pDisk->pInterfaceAsyncIO->pvUser, 1216 pIoStorage-> pStorage);1221 pIoStorage->u.pStorage); 1217 1222 AssertRC(rc); 1218 1223 … … 1227 1232 1228 1233 return pDisk->pInterfaceAsyncIOCallbacks->pfnGetSize(pDisk->pInterfaceAsyncIO->pvUser, 1229 pIoStorage-> pStorage,1234 pIoStorage->u.pStorage, 1230 1235 pcbSize); 1231 1236 } … … 1237 1242 1238 1243 return pDisk->pInterfaceAsyncIOCallbacks->pfnSetSize(pDisk->pInterfaceAsyncIO->pvUser, 1239 pIoStorage-> pStorage,1244 pIoStorage->u.pStorage, 1240 1245 cbSize); 1241 1246 } … … 1247 1252 1248 1253 return pDisk->pInterfaceAsyncIOCallbacks->pfnWriteSync(pDisk->pInterfaceAsyncIO->pvUser, 1249 pIoStorage-> pStorage,1254 pIoStorage->u.pStorage, 1250 1255 uOffset, cbWrite, pvBuf, 1251 1256 pcbWritten); … … 1258 1263 1259 1264 return pDisk->pInterfaceAsyncIOCallbacks->pfnReadSync(pDisk->pInterfaceAsyncIO->pvUser, 1260 pIoStorage-> pStorage,1265 pIoStorage->u.pStorage, 1261 1266 uOffset, cbRead, pvBuf, 1262 1267 pcbRead); … … 1268 1273 1269 1274 return pDisk->pInterfaceAsyncIOCallbacks->pfnFlushSync(pDisk->pInterfaceAsyncIO->pvUser, 1270 pIoStorage-> pStorage);1275 pIoStorage->u.pStorage); 1271 1276 } 1272 1277 … … 1326 1331 return vdIoCtxSet(pIoCtx, ch, cb); 1327 1332 } 1333 1334 /** 1335 * VD I/O interface callback for opening a file (limited version for VDGetFormat). 1336 */ 1337 static int vdIOOpenLimited(void *pvUser, const char *pszLocation, 1338 unsigned uOpenFlags, PPVDIOSTORAGE ppIoStorage) 1339 { 1340 int rc = VINF_SUCCESS; 1341 PVDIOSTORAGE pIoStorage = (PVDIOSTORAGE)RTMemAllocZ(sizeof(VDIOSTORAGE)); 1342 1343 if (!pIoStorage) 1344 return VERR_NO_MEMORY; 1345 1346 uint32_t fOpen = 0; 1347 1348 if (uOpenFlags & VD_INTERFACEASYNCIO_OPEN_FLAGS_READONLY) 1349 fOpen |= RTFILE_O_READ | RTFILE_O_DENY_NONE; 1350 else 1351 fOpen |= RTFILE_O_READWRITE | RTFILE_O_DENY_WRITE; 1352 1353 if (uOpenFlags & VD_INTERFACEASYNCIO_OPEN_FLAGS_CREATE) 1354 fOpen |= RTFILE_O_CREATE; 1355 else 1356 fOpen |= RTFILE_O_OPEN; 1357 1358 rc = RTFileOpen(&pIoStorage->u.hFile, pszLocation, fOpen); 1359 if (RT_SUCCESS(rc)) 1360 *ppIoStorage = pIoStorage; 1361 else 1362 RTMemFree(pIoStorage); 1363 1364 return rc; 1365 } 1366 1367 static int vdIOCloseLimited(void *pvUser, PVDIOSTORAGE pIoStorage) 1368 { 1369 int rc = RTFileClose(pIoStorage->u.hFile); 1370 AssertRC(rc); 1371 1372 RTMemFree(pIoStorage); 1373 return VINF_SUCCESS; 1374 } 1375 1376 static int vdIOGetSizeLimited(void *pvUser, PVDIOSTORAGE pIoStorage, 1377 uint64_t *pcbSize) 1378 { 1379 return RTFileGetSize(pIoStorage->u.hFile, pcbSize); 1380 } 1381 1382 static int vdIOSetSizeLimited(void *pvUser, PVDIOSTORAGE pIoStorage, 1383 uint64_t cbSize) 1384 { 1385 return RTFileSetSize(pIoStorage->u.hFile, cbSize); 1386 } 1387 1388 static int vdIOWriteSyncLimited(void *pvUser, PVDIOSTORAGE pIoStorage, uint64_t uOffset, 1389 size_t cbWrite, const void *pvBuf, size_t *pcbWritten) 1390 { 1391 return RTFileWriteAt(pIoStorage->u.hFile, uOffset, pvBuf, cbWrite, pcbWritten); 1392 } 1393 1394 static int vdIOReadSyncLimited(void *pvUser, PVDIOSTORAGE pIoStorage, uint64_t uOffset, 1395 size_t cbRead, void *pvBuf, size_t *pcbRead) 1396 { 1397 return RTFileReadAt(pIoStorage->u.hFile, uOffset, pvBuf, cbRead, pcbRead); 1398 } 1399 1400 static int vdIOFlushSyncLimited(void *pvUser, PVDIOSTORAGE pIoStorage) 1401 { 1402 return RTFileFlush(pIoStorage->u.hFile); 1403 } 1404 1328 1405 1329 1406 /** … … 1643 1720 VDIIOCallbacks.cbSize = sizeof(VDINTERFACEIO); 1644 1721 VDIIOCallbacks.enmInterface = VDINTERFACETYPE_IO; 1645 VDIIOCallbacks.pfnOpen = vdIOOpen ;1646 VDIIOCallbacks.pfnClose = vdIOClose ;1647 VDIIOCallbacks.pfnGetSize = vdIOGetSize ;1648 VDIIOCallbacks.pfnSetSize = vdIOSetSize ;1649 VDIIOCallbacks.pfnReadSync = vdIOReadSync ;1650 VDIIOCallbacks.pfnWriteSync = vdIOWriteSync ;1651 VDIIOCallbacks.pfnFlushSync = vdIOFlushSync ;1722 VDIIOCallbacks.pfnOpen = vdIOOpenLimited; 1723 VDIIOCallbacks.pfnClose = vdIOCloseLimited; 1724 VDIIOCallbacks.pfnGetSize = vdIOGetSizeLimited; 1725 VDIIOCallbacks.pfnSetSize = vdIOSetSizeLimited; 1726 VDIIOCallbacks.pfnReadSync = vdIOReadSyncLimited; 1727 VDIIOCallbacks.pfnWriteSync = vdIOWriteSyncLimited; 1728 VDIIOCallbacks.pfnFlushSync = vdIOFlushSyncLimited; 1652 1729 VDIIOCallbacks.pfnReadUserAsync = NULL; 1653 1730 VDIIOCallbacks.pfnWriteUserAsync = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.