Changeset 66615 in vbox for trunk/src/VBox/Runtime/common/vfs
- Timestamp:
- Apr 19, 2017 7:29:36 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114658
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r66601 r66615 80 80 AssertPtr((a_pSetOps)->pfnSetOwner); \ 81 81 Assert((a_pSetOps)->uEndMarker == RTVFSOBJSETOPS_VERSION); \ 82 } while (0) 83 84 /** Asserts that the VFS directory vtable is valid. */ 85 #define RTVFSDIR_ASSERT_OPS(pDirOps, a_enmType) \ 86 do { \ 87 RTVFSOBJ_ASSERT_OPS(&(pDirOps)->Obj, a_enmType); \ 88 RTVFSOBJSET_ASSERT_OPS(&(pDirOps)->ObjSet, RT_OFFSETOF(RTVFSDIROPS, Obj) - RT_OFFSETOF(RTVFSDIROPS, ObjSet)); \ 89 Assert((pDirOps)->uVersion == RTVFSDIROPS_VERSION); \ 90 Assert(!(pDirOps)->fReserved); \ 91 AssertPtr((pDirOps)->pfnTraversalOpen); \ 92 AssertPtr((pDirOps)->pfnOpenFile); \ 93 AssertPtr((pDirOps)->pfnOpenDir); \ 94 AssertPtr((pDirOps)->pfnCreateDir); \ 95 AssertPtr((pDirOps)->pfnOpenSymlink); \ 96 AssertPtr((pDirOps)->pfnCreateSymlink); \ 97 AssertPtr((pDirOps)->pfnUnlinkEntry); \ 98 AssertPtr((pDirOps)->pfnRewindDir); \ 99 AssertPtr((pDirOps)->pfnReadDir); \ 100 Assert((pDirOps)->uEndMarker == RTVFSDIROPS_VERSION); \ 82 101 } while (0) 83 102 … … 1634 1653 AssertReturn(pVfsOps->uVersion == RTVFSOPS_VERSION, VERR_VERSION_MISMATCH); 1635 1654 AssertReturn(pVfsOps->uEndMarker == RTVFSOPS_VERSION, VERR_VERSION_MISMATCH); 1655 RTVFSOBJ_ASSERT_OPS(&pVfsOps->Obj, RTVFSOBJTYPE_VFS); 1636 1656 Assert(cbInstance > 0); 1637 1657 AssertPtr(ppvInstance); … … 1647 1667 return VERR_NO_MEMORY; 1648 1668 1649 int rc = rtVfsObjInitNewObject(&pThis->Base, NULL, hVfs, hLock,1669 int rc = rtVfsObjInitNewObject(&pThis->Base, &pVfsOps->Obj, hVfs, hLock, 1650 1670 (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT)); 1651 1671 if (RT_FAILURE(rc)) … … 1660 1680 *phVfs = pThis; 1661 1681 *ppvInstance = pThis->Base.pvThis; 1682 1662 1683 return VINF_SUCCESS; 1663 1684 } … … 1832 1853 * 1833 1854 */ 1855 1856 1857 RTDECL(int) RTVfsNewDir(PCRTVFSDIROPS pDirOps, size_t cbInstance, uint32_t fFlags, RTVFS hVfs, RTVFSLOCK hLock, 1858 PRTVFSDIR phVfsDir, void **ppvInstance) 1859 { 1860 /* 1861 * Validate the input, be extra strict in strict builds. 1862 */ 1863 AssertPtr(pDirOps); 1864 AssertReturn(pDirOps->uVersion == RTVFSDIROPS_VERSION, VERR_VERSION_MISMATCH); 1865 AssertReturn(pDirOps->uEndMarker == RTVFSDIROPS_VERSION, VERR_VERSION_MISMATCH); 1866 Assert(!pDirOps->fReserved); 1867 RTVFSDIR_ASSERT_OPS(pDirOps, RTVFSOBJTYPE_DIR); 1868 Assert(cbInstance > 0); 1869 AssertReturn(!fFlags, VERR_INVALID_FLAGS); 1870 AssertPtr(ppvInstance); 1871 AssertPtr(phVfsDir); 1872 RTVFS_ASSERT_VALID_HANDLE_OR_NIL_RETURN(hVfs, VERR_INVALID_HANDLE); 1873 1874 /* 1875 * Allocate the handle + instance data. 1876 */ 1877 size_t const cbThis = RT_ALIGN_Z(sizeof(RTVFSDIRINTERNAL), RTVFS_INST_ALIGNMENT) 1878 + RT_ALIGN_Z(cbInstance, RTVFS_INST_ALIGNMENT); 1879 RTVFSDIRINTERNAL *pThis = (RTVFSDIRINTERNAL *)RTMemAllocZ(cbThis); 1880 if (!pThis) 1881 return VERR_NO_MEMORY; 1882 1883 int rc = rtVfsObjInitNewObject(&pThis->Base, &pDirOps->Obj, hVfs, hLock, 1884 (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT)); 1885 if (RT_FAILURE(rc)) 1886 { 1887 RTMemFree(pThis); 1888 return rc; 1889 } 1890 1891 pThis->uMagic = RTVFSDIR_MAGIC; 1892 pThis->fReserved = 0; 1893 pThis->pOps = pDirOps; 1894 1895 *phVfsDir = pThis; 1896 *ppvInstance = pThis->Base.pvThis; 1897 return VINF_SUCCESS; 1898 } 1899 1834 1900 1835 1901 RTDECL(uint32_t) RTVfsDirRetain(RTVFSDIR hVfsDir) … … 2801 2867 2802 2868 2869 RTDECL(int) RTVfsFileSgRead(RTVFSFILE hVfsFile, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead) 2870 { 2871 AssertPtrNullReturn(pcbRead, VERR_INVALID_POINTER); 2872 if (pcbRead) 2873 *pcbRead = 0; 2874 RTVFSFILEINTERNAL *pThis = hVfsFile; 2875 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 2876 AssertReturn(pThis->uMagic == RTVFSFILE_MAGIC, VERR_INVALID_HANDLE); 2877 2878 return RTVfsIoStrmSgRead(&pThis->Stream, off, pSgBuf, fBlocking, pcbRead); 2879 } 2880 2881 2882 RTDECL(int) RTVfsFileSgWrite(RTVFSFILE hVfsFile, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten) 2883 { 2884 AssertPtrNullReturn(pcbWritten, VERR_INVALID_POINTER); 2885 if (pcbWritten) 2886 *pcbWritten = 0; 2887 RTVFSFILEINTERNAL *pThis = hVfsFile; 2888 AssertPtrReturn(pThis, VERR_INVALID_HANDLE); 2889 AssertReturn(pThis->uMagic == RTVFSFILE_MAGIC, VERR_INVALID_HANDLE); 2890 2891 return RTVfsIoStrmSgWrite(&pThis->Stream, off, pSgBuf, fBlocking, pcbWritten); 2892 } 2893 2894 2803 2895 RTDECL(int) RTVfsFileFlush(RTVFSFILE hVfsFile) 2804 2896 {
Note:
See TracChangeset
for help on using the changeset viewer.