Lines Matching refs:pCache

394 static int vciFlushImage(PVCICACHE pCache)
398 if ( pCache->pStorage
399 && !(pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY))
401 rc = vdIfIoIntFileFlushSync(pCache->pIfIo, pCache->pStorage);
408 * Internal. Free all allocated space for representing an image except pCache,
411 static int vciFreeImage(PVCICACHE pCache, bool fDelete)
417 if (pCache)
419 if (pCache->pStorage)
423 vciFlushImage(pCache);
425 vdIfIoIntFileClose(pCache->pIfIo, pCache->pStorage);
426 pCache->pStorage = NULL;
429 if (fDelete && pCache->pszFilename)
430 vdIfIoIntFileDelete(pCache->pIfIo, pCache->pszFilename);
1060 * @param pCache The cache image instance.
1066 static PVCICACHEEXTENT vciCacheExtentLookup(PVCICACHE pCache, uint64_t offBlockOffset,
1071 PVCITREENODE pNodeCur = pCache->pRoot;
1112 rc = vdIfIoIntFileReadSync(pCache->pIfIo, pCache->pStorage,
1199 static int vciOpenImage(PVCICACHE pCache, unsigned uOpenFlags)
1205 pCache->uOpenFlags = uOpenFlags;
1207 pCache->pIfError = VDIfErrorGet(pCache->pVDIfsDisk);
1208 pCache->pIfIo = VDIfIoIntGet(pCache->pVDIfsImage);
1209 AssertPtrReturn(pCache->pIfIo, VERR_INVALID_PARAMETER);
1214 rc = vdIfIoIntFileOpen(pCache->pIfIo, pCache->pszFilename,
1217 &pCache->pStorage);
1225 rc = vdIfIoIntFileGetSize(pCache->pIfIo, pCache->pStorage, &cbFile);
1232 rc = vdIfIoIntFileReadSync(pCache->pIfIo, pCache->pStorage, 0, &Hdr,
1251 pCache->offTreeRoot = Hdr.offTreeRoot;
1252 pCache->offBlksBitmap = Hdr.offBlkMap;
1255 rc = vciBlkMapLoad(pCache, pCache->offBlksBitmap, Hdr.cBlkMap, &pCache->pBlkMap);
1261 rc = vdIfIoIntFileReadSync(pCache->pIfIo, pCache->pStorage,
1262 pCache->offTreeRoot, &RootNode,
1266 pCache->pRoot = vciTreeNodeImage2Host(pCache->offTreeRoot, &RootNode);
1267 if (!pCache->pRoot)
1277 vciFreeImage(pCache, false);
1284 static int vciCreateImage(PVCICACHE pCache, uint64_t cbSize,
1295 pCache->uImageFlags = uImageFlags;
1296 pCache->uOpenFlags = uOpenFlags & ~VD_OPEN_FLAGS_READONLY;
1298 pCache->pIfError = VDIfErrorGet(pCache->pVDIfsDisk);
1299 pCache->pIfIo = VDIfIoIntGet(pCache->pVDIfsImage);
1300 AssertPtrReturn(pCache->pIfIo, VERR_INVALID_PARAMETER);
1304 rc = vdIfError(pCache->pIfError, VERR_VD_RAW_INVALID_TYPE, RT_SRC_POS, N_("VCI: cannot create diff image '%s'"), pCache->pszFilename);
1311 rc = vdIfIoIntFileOpen(pCache->pIfIo, pCache->pszFilename,
1314 &pCache->pStorage);
1317 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot create image '%s'"), pCache->pszFilename);
1323 rc = vciBlkMapCreate(cBlocks, &pCache->pBlkMap, &cBlkMap);
1326 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot create block bitmap '%s'"), pCache->pszFilename);
1335 rc = vciBlkMapAllocate(pCache->pBlkMap, VCI_BYTE2BLOCK(sizeof(VciHdr)), VCIBLKMAP_ALLOC_META, &offHdr);
1338 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot allocate space for header in block bitmap '%s'"), pCache->pszFilename);
1348 rc = vciBlkMapAllocate(pCache->pBlkMap, cBlkMap, VCIBLKMAP_ALLOC_META, &offBlkMap);
1351 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot allocate space for block map in block map '%s'"), pCache->pszFilename);
1359 rc = vciBlkMapAllocate(pCache->pBlkMap, VCI_BYTE2BLOCK(sizeof(VciTreeNode)), VCIBLKMAP_ALLOC_META, &offTreeRoot);
1362 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot allocate space for block map in block map '%s'"), pCache->pszFilename);
1369 pCache->pRoot = (PVCITREENODE)RTMemAllocZ(sizeof(VCITREENODELEAF));
1370 if (!pCache->pRoot)
1372 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot allocate B+-Tree root pointer '%s'"), pCache->pszFilename);
1376 pCache->pRoot->u8Type = VCI_TREE_NODE_TYPE_LEAF;
1397 rc = vdIfIoIntFileWriteSync(pCache->pIfIo, pCache->pStorage, offHdr, &Hdr,
1401 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot write header '%s'"), pCache->pszFilename);
1405 rc = vciBlkMapSave(pCache->pBlkMap, pCache, offBlkMap, cBlkMap);
1408 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot write block map '%s'"), pCache->pszFilename);
1416 rc = vdIfIoIntFileWriteSync(pCache->pIfIo, pCache->pStorage, offTreeRoot,
1420 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot write root node '%s'"), pCache->pszFilename);
1424 rc = vciFlushImage(pCache);
1427 rc = vdIfError(pCache->pIfError, rc, RT_SRC_POS, N_("VCI: cannot flush '%s'"), pCache->pszFilename);
1431 pCache->cbSize = cbSize;
1439 vciFreeImage(pCache, rc != VERR_ALREADY_EXISTS);
1507 PVCICACHE pCache;
1525 pCache = (PVCICACHE)RTMemAllocZ(sizeof(VCICACHE));
1526 if (!pCache)
1531 pCache->pszFilename = pszFilename;
1532 pCache->pStorage = NULL;
1533 pCache->pVDIfsDisk = pVDIfsDisk;
1534 pCache->pVDIfsImage = pVDIfsImage;
1536 rc = vciOpenImage(pCache, uOpenFlags);
1538 *ppBackendData = pCache;
1540 RTMemFree(pCache);
1558 PVCICACHE pCache;
1584 pCache = (PVCICACHE)RTMemAllocZ(sizeof(VCICACHE));
1585 if (!pCache)
1590 pCache->pszFilename = pszFilename;
1591 pCache->pStorage = NULL;
1592 pCache->pVDIfsDisk = pVDIfsDisk;
1593 pCache->pVDIfsImage = pVDIfsImage;
1595 rc = vciCreateImage(pCache, cbSize, uImageFlags, pszComment, uOpenFlags,
1603 vciFreeImage(pCache, false);
1604 rc = vciOpenImage(pCache, uOpenFlags);
1607 RTMemFree(pCache);
1611 *ppBackendData = pCache;
1614 RTMemFree(pCache);
1625 PVCICACHE pCache = (PVCICACHE)pBackendData;
1628 rc = vciFreeImage(pCache, fDelete);
1629 RTMemFree(pCache);
1641 PVCICACHE pCache = (PVCICACHE)pBackendData;
1647 AssertPtr(pCache);
1651 pExtent = vciCacheExtentLookup(pCache, offBlockAddr, NULL);
1657 rc = vdIfIoIntFileReadUser(pCache->pIfIo, pCache->pStorage,
1681 PVCICACHE pCache = (PVCICACHE)pBackendData;
1686 AssertPtr(pCache);
1705 PVCICACHE pCache = (PVCICACHE)pBackendData;
1708 rc = vciFlushImage(pCache);
1717 PVCICACHE pCache = (PVCICACHE)pBackendData;
1719 AssertPtr(pCache);
1721 if (pCache)
1731 PVCICACHE pCache = (PVCICACHE)pBackendData;
1734 AssertPtr(pCache);
1736 if (pCache && pCache->pStorage)
1737 cb = pCache->cbSize;
1747 PVCICACHE pCache = (PVCICACHE)pBackendData;
1750 AssertPtr(pCache);
1752 if (pCache)
1755 if (pCache->pStorage)
1757 int rc = vdIfIoIntFileGetSize(pCache->pIfIo, pCache->pStorage, &cbFile);
1771 PVCICACHE pCache = (PVCICACHE)pBackendData;
1774 AssertPtr(pCache);
1776 if (pCache)
1777 uImageFlags = pCache->uImageFlags;
1789 PVCICACHE pCache = (PVCICACHE)pBackendData;
1792 AssertPtr(pCache);
1794 if (pCache)
1795 uOpenFlags = pCache->uOpenFlags;
1807 PVCICACHE pCache = (PVCICACHE)pBackendData;
1812 if (!pCache || (uOpenFlags & ~(VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_INFO)))
1819 rc = vciFreeImage(pCache, false);
1822 rc = vciOpenImage(pCache, uOpenFlags);
1834 PVCICACHE pCache = (PVCICACHE)pBackendData;
1837 AssertPtr(pCache);
1839 if (pCache)
1852 PVCICACHE pCache = (PVCICACHE)pBackendData;
1855 AssertPtr(pCache);
1857 if (pCache)
1859 if (pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY)
1875 PVCICACHE pCache = (PVCICACHE)pBackendData;
1878 AssertPtr(pCache);
1880 if (pCache)
1893 PVCICACHE pCache = (PVCICACHE)pBackendData;
1897 AssertPtr(pCache);
1899 if (pCache)
1901 if (!(pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY))
1917 PVCICACHE pCache = (PVCICACHE)pBackendData;
1920 AssertPtr(pCache);
1922 if (pCache)
1935 PVCICACHE pCache = (PVCICACHE)pBackendData;
1938 AssertPtr(pCache);
1940 if (pCache)
1942 if (!(pCache->uOpenFlags & VD_OPEN_FLAGS_READONLY))