Lines Matching defs:pNode
176 * @param pNode The node.
179 static bool vboxfuseNodeDestroy(PVBOXFUSENODE pNode, bool fLocked)
181 Assert(pNode->cRefs == 0);
186 switch (pNode->enmType)
190 PVBOXFUSEDIR pDir = (PVBOXFUSEDIR)pNode;
199 PVBOXFUSEFLATIMAGE pFlatImage = (PVBOXFUSEFLATIMAGE)pNode;
214 AssertMsgFailed(("%d\n", pNode->enmType));
221 pNode->enmType = VBOXFUSETYPE_INVALID;
222 pNode->pszName = NULL;
228 RTCritSectLeave(&pNode->CritSect);
229 RTCritSectDelete(&pNode->CritSect);
231 RTMemFree(pNode);
240 * @param pNode The node.
242 static void vboxfuseNodeLock(PVBOXFUSENODE pNode)
244 int rc = RTCritSectEnter(&pNode->CritSect);
252 * @param pNode The node.
254 static void vboxfuseNodeUnlock(PVBOXFUSENODE pNode)
256 int rc = RTCritSectLeave(&pNode->CritSect);
264 * @param pNode The node.
266 static void vboxfuseNodeRetain(PVBOXFUSENODE pNode)
268 int32_t cNewRefs = ASMAtomicIncS32(&pNode->cRefs);
277 * @param pNode The node.
279 static bool vboxfuseNodeRelease(PVBOXFUSENODE pNode)
281 if (ASMAtomicDecS32(&pNode->cRefs) == 0)
282 return vboxfuseNodeDestroy(pNode, false /* fLocked */);
290 * @param pNode The node.
292 static void vboxfuseNodeLockAndRetain(PVBOXFUSENODE pNode)
294 vboxfuseNodeLock(pNode);
295 vboxfuseNodeRetain(pNode);
303 * @param pNode The node.
305 static bool vboxfuseNodeReleaseAndUnlock(PVBOXFUSENODE pNode)
307 if (ASMAtomicDecS32(&pNode->cRefs) == 0)
308 return vboxfuseNodeDestroy(pNode, true /* fLocked */);
309 vboxfuseNodeUnlock(pNode);
317 * @param pNode The node (locked).
319 static void vboxfuseNodeFillStat(PVBOXFUSENODE pNode, struct stat *pStat)
322 pStat->st_ino = pNode->Ino; /* maybe ignored */
323 pStat->st_mode = pNode->fMode;
324 pStat->st_nlink = pNode->cLinks;
325 pStat->st_uid = pNode->Uid;
326 pStat->st_gid = pNode->Gid;
335 pStat->st_size = pNode->cbPrimary;
336 pStat->st_blocks = (pNode->cbPrimary + DEV_BSIZE - 1) / DEV_BSIZE;
367 PVBOXFUSENODE pNode = (PVBOXFUSENODE)RTMemAlloc(cchName + 1 + RT_ALIGN_Z(cbNode, 8));
368 if (!pNode)
371 int rc = RTCritSectInit(&pNode->CritSect);
374 RTMemFree(pNode);
381 pNode->pszName = (char *)memcpy((uint8_t *)pNode + RT_ALIGN_Z(cbNode, 8), pszName, cchName + 1);
382 pNode->cchName = cchName;
383 pNode->enmType = enmType;
384 pNode->cRefs = 1;
385 pNode->pDir = pDir;
387 pNode->fMode = enmType == VBOXFUSETYPE_DIRECTORY ? S_IFDIR | 0755 : S_IFREG | 0644;
389 pNode->fMode = enmType == VBOXFUSETYPE_DIRECTORY ? S_IFDIR | 0777 : S_IFREG | 0666;
391 pNode->Uid = 0;
392 pNode->Gid = 0;
393 pNode->cLinks = 0;
394 pNode->Ino = g_NextIno++; /** @todo make this safe! */
395 pNode->cbPrimary = 0;
397 *ppNode = pNode;
413 * @param pNode The node to insert.
415 static int vboxfuseDirInsertChild(PVBOXFUSEDIR pDir, PVBOXFUSENODE pNode)
423 AssertReturn(pNode->enmType == VBOXFUSETYPE_DIRECTORY, VERR_INTERNAL_ERROR);
424 g_pTreeRoot = (PVBOXFUSEDIR)pNode;
438 pDir->paEntries[pDir->cEntries++] = pNode;
442 vboxfuseNodeRetain(pNode);
443 pNode->cLinks++;
646 PVBOXFUSENODE pNode = NULL;
655 pNode = pCur;
656 vboxfuseNodeLockAndRetain(pNode);
662 if (!pNode)
665 && pNode->enmType != VBOXFUSETYPE_DIRECTORY)
667 vboxfuseNodeReleaseAndUnlock(pNode);
676 *ppNode = pNode;
681 pDir = (PVBOXFUSEDIR)pNode;
768 PVBOXFUSENODE pNode = NULL;
777 pNode = pCur;
778 vboxfuseNodeLockAndRetain(pNode);
784 if (!pNode)
787 && pNode->enmType != VBOXFUSETYPE_DIRECTORY)
789 vboxfuseNodeReleaseAndUnlock(pNode);
794 pDir = (PVBOXFUSEDIR)pNode;
859 PVBOXFUSENODE pNode;
860 int rc = vboxfuseTreeLookupErrno(pszPath, &pNode);
863 vboxfuseNodeFillStat(pNode, pStat);
864 vboxfuseNodeReleaseAndUnlock(pNode);
874 PVBOXFUSENODE pNode;
875 int rc = vboxfuseTreeLookupErrno(pszPath, &pNode);
881 if (pNode->enmType != VBOXFUSETYPE_DIRECTORY)
892 pInfo->fh = (uintptr_t)pNode;
893 vboxfuseNodeUnlock(pNode);
898 vboxfuseNodeReleaseAndUnlock(pNode);
945 PVBOXFUSENODE pNode = pDir->paEntries[i];
946 vboxfuseNodeLock(pNode);
948 vboxfuseNodeFillStat(pNode, &st);
950 rc = pfnFiller(pvBuf, pNode->pszName, &st, offDir);
952 vboxfuseNodeUnlock(pNode);
1027 PVBOXFUSENODE pNode;
1028 int rc = vboxfuseTreeLookupErrno(pszPath, &pNode);
1034 switch (pNode->enmType)
1044 PVBOXFUSEFLATIMAGE pFlatImage = (PVBOXFUSEFLATIMAGE)pNode;
1089 pInfo->fh = (uintptr_t)pNode;
1090 vboxfuseNodeUnlock(pNode);
1095 vboxfuseNodeReleaseAndUnlock(pNode);
1106 PVBOXFUSENODE pNode = (PVBOXFUSENODE)(uintptr_t)pInfo->fh;
1107 AssertPtr(pNode);
1110 switch (pNode->enmType)
1114 vboxfuseNodeRelease(pNode);
1119 PVBOXFUSEFLATIMAGE pFlatImage = (PVBOXFUSEFLATIMAGE)pNode;
1142 vboxfuseNodeRelease(pNode);
1171 PVBOXFUSENODE pNode = (PVBOXFUSENODE)(uintptr_t)pInfo->fh;
1172 AssertPtr(pNode);
1173 switch (pNode->enmType)
1291 PVBOXFUSENODE pNode = (PVBOXFUSENODE)(uintptr_t)pInfo->fh;
1292 AssertPtr(pNode);
1293 switch (pNode->enmType)