static NTSTATUS SrvTree2AddFile_inlock( PLWIO_SRV_TREE_2 pTree, PLWIO_SRV_FILE_2 pFile ) { NTSTATUS ntStatus = 0; ntStatus = LwRtlRBTreeAdd( pTree->pFileCollection, &pFile->fid, pFile); BAIL_ON_NT_STATUS(ntStatus); // Reference from parent SrvFile2Acquire(pFile); SrvFile2SetInParent(pFile); pTree->lruFile[pFile->fid.ullVolatileId % SRV_LRU_CAPACITY] = pFile; pTree->ulNumOpenFiles++; cleanup: return ntStatus; error: goto cleanup; }
static NTSTATUS SrvBuildGetInfoState_SMB_V2( PSMB2_GET_INFO_REQUEST_HEADER pRequestHeader, PLWIO_SRV_FILE_2 pFile, PBYTE pInputBuffer, ULONG ulInputBufferLength, PSRV_GET_INFO_STATE_SMB_V2* ppGetInfoState ) { NTSTATUS ntStatus = STATUS_SUCCESS; PSRV_GET_INFO_STATE_SMB_V2 pGetInfoState = NULL; ntStatus = SrvAllocateMemory( sizeof(SRV_GET_INFO_STATE_SMB_V2), (PVOID*)&pGetInfoState); BAIL_ON_NT_STATUS(ntStatus); pGetInfoState->refCount = 1; pthread_mutex_init(&pGetInfoState->mutex, NULL); pGetInfoState->pMutex = &pGetInfoState->mutex; pGetInfoState->stage = SRV_GET_INFO_STAGE_SMB_V2_INITIAL; pGetInfoState->pRequestHeader = pRequestHeader; pGetInfoState->pFile = SrvFile2Acquire(pFile); pGetInfoState->pInputBuffer = pInputBuffer; pGetInfoState->ulInputBufferLength = ulInputBufferLength; *ppGetInfoState = pGetInfoState; cleanup: return ntStatus; error: *ppGetInfoState = NULL; if (pGetInfoState) { SrvFreeGetInfoState_SMB_V2(pGetInfoState); } goto cleanup; }
static BOOLEAN SrvTree2GatherRundownFileListCallback( PLWIO_SRV_FILE_2 pFile, PVOID pContext ) { PLWIO_SRV_FILE_2* ppRundownList = (PLWIO_SRV_FILE_2*) pContext; LWIO_ASSERT(!pFile->pRundownNext); pFile->pRundownNext = *ppRundownList; *ppRundownList = SrvFile2Acquire(pFile); return TRUE; }
static NTSTATUS SrvBuildFlushState_SMB_V2( PSMB2_FID pFid, PLWIO_SRV_FILE_2 pFile, PSRV_FLUSH_STATE_SMB_V2* ppFlushState ) { NTSTATUS ntStatus = STATUS_SUCCESS; PSRV_FLUSH_STATE_SMB_V2 pFlushState = NULL; ntStatus = SrvAllocateMemory( sizeof(SRV_FLUSH_STATE_SMB_V2), (PVOID*)&pFlushState); BAIL_ON_NT_STATUS(ntStatus); pFlushState->refCount = 1; pthread_mutex_init(&pFlushState->mutex, NULL); pFlushState->pMutex = &pFlushState->mutex; pFlushState->stage = SRV_FLUSH_STAGE_SMB_V2_INITIAL; pFlushState->pFid = pFid; pFlushState->pFile = SrvFile2Acquire(pFile); *ppFlushState = pFlushState; cleanup: return ntStatus; error: *ppFlushState = NULL; if (pFlushState) { SrvFreeFlushState_SMB_V2(pFlushState); } goto cleanup; }