📄 openclos.c
字号:
/*++
Copyright (c) 1989 - 1999 Microsoft Corporation
Module Name:
openclos.c
Abstract:
This module implements the mini redirector call down routines pertaining to opening/
closing of file/directories.
--*/
#include "precomp.h"
#pragma hdrstop
//
// The debug trace level
//
#define Dbg (DEBUG_TRACE_CREATE)
//
// forwards & pragmas
//
NTSTATUS
NulMRxProcessCreate(
IN PNULMRX_FCB_EXTENSION pFcbExtension,
IN PVOID EaBuffer,
IN ULONG EaLength,
OUT PLONGLONG pEndOfFile,
OUT PLONGLONG pAllocationSize
);
NTSTATUS
NulMRxCreateFileSuccessTail (
PRX_CONTEXT RxContext,
PBOOLEAN MustRegainExclusiveResource,
RX_FILE_TYPE StorageType,
ULONG CreateAction,
FILE_BASIC_INFORMATION* pFileBasicInfo,
FILE_STANDARD_INFORMATION* pFileStandardInfo
);
VOID
NulMRxSetSrvOpenFlags (
PRX_CONTEXT RxContext,
RX_FILE_TYPE StorageType,
PMRX_SRV_OPEN SrvOpen
);
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, NulMRxCreate)
#pragma alloc_text(PAGE, NulMRxShouldTryToCollapseThisOpen)
#pragma alloc_text(PAGE, NulMRxProcessCreate)
#pragma alloc_text(PAGE, NulMRxCreateFileSuccessTail)
#pragma alloc_text(PAGE, NulMRxSetSrvOpenFlags)
#endif
NTSTATUS
NulMRxShouldTryToCollapseThisOpen (
IN PRX_CONTEXT RxContext
)
/*++
Routine Description:
This routine determines if the mini knows of a good reason not
to try collapsing on this open. Presently, the only reason would
be if this were a copychunk open.
Arguments:
RxContext - the RDBSS context
Return Value:
NTSTATUS - The return status for the operation
SUCCESS --> okay to try collapse
other (MORE_PROCESSING_REQUIRED) --> dont collapse
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
RxCaptureFcb;
PAGED_CODE();
return Status;
}
NTSTATUS
NulMRxCreate(
IN OUT PRX_CONTEXT RxContext
)
/*++
Routine Description:
This routine opens a file across the network
Arguments:
RxContext - the RDBSS context
Return Value:
RXSTATUS - The return status for the operation
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
BOOLEAN fMustRegainExclusiveResource = FALSE;
RX_FILE_TYPE StorageType = FileTypeFile;
ULONG CreateAction = FILE_CREATED;
LARGE_INTEGER liSystemTime;
LONGLONG EndOfFile = 0, AllocationSize = 0;
FILE_BASIC_INFORMATION FileBasicInfo;
FILE_STANDARD_INFORMATION FileStandardInfo;
RxCaptureFcb;
NulMRxGetFcbExtension(capFcb,pFcbExtension);
RX_BLOCK_CONDITION FinalSrvOpenCondition;
PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
PMRX_SRV_CALL SrvCall = RxContext->Create.pSrvCall;
PMRX_NET_ROOT NetRoot = capFcb->pNetRoot;
PUNICODE_STRING RemainingName = SrvOpen->pAlreadyPrefixedName;
PVOID EaBuffer = RxContext->Create.EaBuffer;
ULONG EaLength = RxContext->Create.EaLength;
ACCESS_MASK DesiredAccess = RxContext->Create.NtCreateParameters.DesiredAccess;
NulMRxGetNetRootExtension(NetRoot,pNetRootExtension);
RxTraceEnter("NulMRxCreate");
PAGED_CODE();
RxDbgTrace(0, Dbg, (" Attempt to open %wZ Len is %d\n", RemainingName, RemainingName->Length ));
if( NetRoot->Type == NET_ROOT_DISK && NT_SUCCESS(Status) ) {
RxDbgTrace(0, Dbg, ("NulMRxCreate: Type supported \n"));
//
// Squirrel away the scatter list in the FCB extension.
// This is done only for data files.
//
Status = NulMRxProcessCreate(
pFcbExtension,
EaBuffer,
EaLength,
&EndOfFile,
&AllocationSize
);
if( Status != STATUS_SUCCESS ) {
//
// error..
//
RxDbgTrace(0, Dbg, ("Failed to initialize scatter list\n"));
goto Exit;
}
//
// Complete CreateFile contract
//
RxDbgTrace(0,Dbg,("EOF is %d AllocSize is %d\n",(ULONG)EndOfFile,(ULONG)AllocationSize));
FileBasicInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
KeQuerySystemTime(&liSystemTime);
FileBasicInfo.CreationTime = liSystemTime;
FileBasicInfo.LastAccessTime = liSystemTime;
FileBasicInfo.LastWriteTime = liSystemTime;
FileBasicInfo.ChangeTime = liSystemTime;
FileStandardInfo.AllocationSize.QuadPart = AllocationSize;
FileStandardInfo.EndOfFile.QuadPart = EndOfFile;
FileStandardInfo.NumberOfLinks = 0;
Status = NulMRxCreateFileSuccessTail (
RxContext,
&fMustRegainExclusiveResource,
StorageType,
CreateAction,
&FileBasicInfo,
&FileStandardInfo
);
if( Status != STATUS_SUCCESS ) {
//
// alloc error..
//
RxDbgTrace(0, Dbg, ("Failed to allocate Fobx \n"));
goto Exit;
}
if (!RxIsFcbAcquiredExclusive(capFcb)) {
ASSERT(!RxIsFcbAcquiredShared(capFcb));
RxAcquireExclusiveFcbResourceInMRx( capFcb );
}
} else {
RxDbgTrace(0, Dbg, ("NulMRxCreate: Type not supported or invalid open\n"));
Status = STATUS_NOT_IMPLEMENTED;
}
ASSERT(Status != (STATUS_PENDING));
ASSERT(RxIsFcbAcquiredExclusive( capFcb ));
RxDbgTrace(0, Dbg, ("NetRoot is 0x%x Fcb is 0x%x SrvOpen is 0x%x Fobx is 0x%x\n",
NetRoot,capFcb, SrvOpen,RxContext->pFobx));
RxDbgTrace(0, Dbg, ("NulMRxCreate exit with status=%08lx\n", Status ));
Exit:
RxTraceLeave(Status);
return(Status);
}
NTSTATUS
NulMRxProcessCreate(
IN PNULMRX_FCB_EXTENSION pFcbExtension,
IN PVOID EaBuffer,
IN ULONG EaLength,
OUT PLONGLONG pEndOfFile,
OUT PLONGLONG pAllocationSize
)
/*++
Routine Description:
This routine processes a create calldown.
Arguments:
pFcbExtension - ptr to the FCB extension
EaBuffer - ptr to the EA param buffer
EaLength - len of EaBuffer
pEndOfFile - return end of file value
pAllocationSize - return allocation size (which maybe > EOF)
Notes:
It is possible to create a file with no EAs
Return Value:
None
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
RxDbgTrace(0, Dbg, ("NulMRxInitializeFcbExtension\n"));
*pAllocationSize = *pEndOfFile = 0;
return Status;
}
VOID
NulMRxSetSrvOpenFlags (
PRX_CONTEXT RxContext,
RX_FILE_TYPE StorageType,
PMRX_SRV_OPEN SrvOpen
)
{
PMRX_SRV_CALL SrvCall = (PMRX_SRV_CALL)RxContext->Create.pSrvCall;
//
// set this only if cache manager will be used for mini-rdr handles !
//
SrvOpen->BufferingFlags |= (FCB_STATE_WRITECACHING_ENABLED |
FCB_STATE_FILESIZECACHEING_ENABLED |
FCB_STATE_FILETIMECACHEING_ENABLED |
FCB_STATE_WRITEBUFFERING_ENABLED |
FCB_STATE_LOCK_BUFFERING_ENABLED |
FCB_STATE_READBUFFERING_ENABLED |
FCB_STATE_READCACHING_ENABLED);
}
NTSTATUS
NulMRxCreateFileSuccessTail (
PRX_CONTEXT RxContext,
PBOOLEAN MustRegainExclusiveResource,
RX_FILE_TYPE StorageType,
ULONG CreateAction,
FILE_BASIC_INFORMATION* pFileBasicInfo,
FILE_STANDARD_INFORMATION* pFileStandardInfo
)
/*++
Routine Description:
This routine finishes the initialization of the fcb and srvopen for a
successful open.
Arguments:
Return Value:
RXSTATUS - The return status for the operation
--*/
{
NTSTATUS Status = STATUS_SUCCESS;
RxCaptureFcb;
PMRX_SRV_OPEN SrvOpen = RxContext->pRelevantSrvOpen;
FCB_INIT_PACKET InitPacket;
RxDbgTrace(0, Dbg, ("MRxExCreateFileSuccessTail\n"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -