Changeset 34002 in vbox for trunk/src/VBox/Runtime/common/vfs
- Timestamp:
- Nov 11, 2010 5:16:37 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67667
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r33979 r34002 68 68 /** The max number of symbolic links to resolve in a path. */ 69 69 #define RTVFS_MAX_LINKS 20U 70 71 72 /** Asserts that the VFS base object vtable is valid. */ 73 #define RTVFSOBJ_ASSERT_OPS(pObj, enmTypeArg) \ 74 do \ 75 { \ 76 Assert((pObj)->uVersion == RTVFSOBJOPS_VERSION); \ 77 Assert((pObj)->enmType == (enmTypeArg) || (enmTypeArg) == RTVFSOBJTYPE_INVALID); \ 78 AssertPtr((pObj)->pszName); \ 79 Assert(*(pObj)->pszName); \ 80 AssertPtr((pObj)->pfnClose); \ 81 AssertPtr((pObj)->pfnQueryInfo); \ 82 Assert((pObj)->uEndMarker == RTVFSOBJOPS_VERSION); \ 83 } while (0) 84 85 /** Asserts that the VFS I/O stream vtable is valid. */ 86 #define RTVFSIOSTREAM_ASSERT_OPS(pIoStreamOps, enmTypeArg) \ 87 do { \ 88 RTVFSOBJ_ASSERT_OPS(&(pIoStreamOps)->Obj, enmTypeArg); \ 89 Assert((pIoStreamOps)->uVersion == RTVFSIOSTREAMOPS_VERSION); \ 90 Assert(!(pIoStreamOps)->fReserved); \ 91 AssertPtr((pIoStreamOps)->pfnRead); \ 92 AssertPtr((pIoStreamOps)->pfnWrite); \ 93 AssertPtr((pIoStreamOps)->pfnFlush); \ 94 AssertPtr((pIoStreamOps)->pfnPollOne); \ 95 AssertPtr((pIoStreamOps)->pfnTell); \ 96 AssertPtrNull((pIoStreamOps)->pfnSkip); \ 97 AssertPtrNull((pIoStreamOps)->pfnZeroFill); \ 98 Assert((pIoStreamOps)->uEndMarker == RTVFSIOSTREAMOPS_VERSION); \ 99 } while (0) 70 100 71 101 … … 1095 1125 PRTVFSFSSTREAM phVfsFss, void **ppvInstance) 1096 1126 { 1097 return VERR_NOT_IMPLEMENTED; 1127 /* 1128 * Validate the input, be extra strict in strict builds. 1129 */ 1130 AssertPtr(pFsStreamOps); 1131 AssertReturn(pFsStreamOps->uVersion == RTVFSFSSTREAMOPS_VERSION, VERR_VERSION_MISMATCH); 1132 AssertReturn(pFsStreamOps->uEndMarker == RTVFSFSSTREAMOPS_VERSION, VERR_VERSION_MISMATCH); 1133 Assert(!pFsStreamOps->fReserved); 1134 RTVFSOBJ_ASSERT_OPS(&pFsStreamOps->Obj, RTVFSOBJTYPE_FS_STREAM); 1135 AssertPtr(pFsStreamOps->pfnNext); 1136 Assert(cbInstance > 0); 1137 AssertPtr(ppvInstance); 1138 AssertPtr(phVfsFss); 1139 1140 RTVFSINTERNAL *pVfs = NULL; 1141 if (hVfs != NIL_RTVFS) 1142 { 1143 pVfs = hVfs; 1144 AssertPtrReturn(pVfs, VERR_INVALID_HANDLE); 1145 AssertReturn(pVfs->uMagic == RTVFS_MAGIC, VERR_INVALID_HANDLE); 1146 } 1147 1148 /* 1149 * Allocate the handle + instance data. 1150 */ 1151 size_t const cbThis = RT_ALIGN_Z(sizeof(RTVFSFSSTREAMINTERNAL), RTVFS_INST_ALIGNMENT) 1152 + RT_ALIGN_Z(cbInstance, RTVFS_INST_ALIGNMENT); 1153 RTVFSFSSTREAMINTERNAL *pThis = (RTVFSFSSTREAMINTERNAL *)RTMemAllocZ(cbThis); 1154 if (!pThis) 1155 return VERR_NO_MEMORY; 1156 1157 pThis->uMagic = RTVFSFSSTREAM_MAGIC; 1158 pThis->fFlags = RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE; 1159 pThis->pOps = pFsStreamOps; 1160 pThis->Base.uMagic = RTVFSOBJ_MAGIC; 1161 pThis->Base.pvThis = (char *)pThis + RT_ALIGN_Z(sizeof(*pThis), RTVFS_INST_ALIGNMENT); 1162 pThis->Base.pOps = &pFsStreamOps->Obj; 1163 pThis->Base.hSemRW = hSemRW != NIL_RTSEMRW ? hSemRW : pVfs ? pVfs->Base.hSemRW : NIL_RTSEMRW; 1164 pThis->Base.hVfs = hVfs; 1165 pThis->Base.cRefs = 1; 1166 if (hVfs != NIL_RTVFS) 1167 rtVfsObjRetainVoid(&pVfs->Base); 1168 1169 *phVfsFss = pThis; 1170 *ppvInstance = pThis->Base.pvThis; 1171 return VINF_SUCCESS; 1098 1172 } 1099 1173 … … 1233 1307 AssertReturn(pIoStreamOps->uEndMarker == RTVFSIOSTREAMOPS_VERSION, VERR_VERSION_MISMATCH); 1234 1308 Assert(!pIoStreamOps->fReserved); 1309 RTVFSIOSTREAM_ASSERT_OPS(pIoStreamOps, RTVFSOBJTYPE_IO_STREAM); 1235 1310 Assert(cbInstance > 0); 1236 1311 Assert(fOpen & RTFILE_O_ACCESS_MASK); … … 1539 1614 AssertReturn(pFileOps->uEndMarker == RTVFSFILEOPS_VERSION, VERR_VERSION_MISMATCH); 1540 1615 Assert(!pFileOps->fReserved); 1616 RTVFSIOSTREAM_ASSERT_OPS(&pFileOps->Stream, RTVFSOBJTYPE_FILE); 1541 1617 Assert(cbInstance > 0); 1542 1618 Assert(fOpen & RTFILE_O_ACCESS_MASK);
Note:
See TracChangeset
for help on using the changeset viewer.