Windows: AFSRedirLib.sys file system library driver

This patchset implements the AFS Redirector Library driver.
This driver contains all of the AFS specific implementation
details for service communication, network provider support,
directory management, extent management, metadata management,
callback invaldation, volume management, file locking, etc.

Rod Widdowson <rdw@steadingsoftware.com> and Jeffrey Altman
<jaltman@your-file-system.com> contributed to the development
of this driver.

Change-Id: Icc18c26b81b96a92096c20e01360007815ca1acb
Reviewed-on: http://gerrit.openafs.org/5438
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Peter Scott 2011-09-15 01:48:59 -04:00 committed by Jeffrey Altman
parent 9399093a76
commit 3c69a113aa
38 changed files with 46672 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,688 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSClose.cpp
//
#include "AFSCommon.h"
//
// Function: AFSClose
//
// Description:
//
// This function is the IRP_MJ_CLOSE dispatch handler
//
// Return:
//
// A status is returned for the handling of this request
//
NTSTATUS
AFSClose( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
ULONG ulRequestType = 0;
IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
AFSFcb *pFcb = NULL;
AFSDeviceExt *pDeviceExt = NULL;
AFSCcb *pCcb = NULL;
AFSObjectInfoCB *pObjectInfo = NULL;
AFSDirectoryCB *pDirCB = NULL;
__try
{
if( AFSRDRDeviceObject == NULL)
{
//
// Let this through, it's an close on the library control device
//
try_return( ntStatus);
}
pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
if( pFcb == NULL)
{
try_return( ntStatus);
}
pObjectInfo = pFcb->ObjectInformation;
//
// Perform the close functionality depending on the type of node it is
//
switch( pFcb->Header.NodeTypeCode)
{
case AFS_IOCTL_FCB:
{
AFSPIOCtlOpenCloseRequestCB stPIOCtlClose;
AFSFileID stParentFileId;
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Acquiring GlobalRoot lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSAcquireExcl( &pFcb->NPFcb->Resource,
TRUE);
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
//
// Send the close to the CM
//
RtlZeroMemory( &stPIOCtlClose,
sizeof( AFSPIOCtlOpenCloseRequestCB));
stPIOCtlClose.RequestId = pCcb->RequestID;
stPIOCtlClose.RootId = pObjectInfo->VolumeCB->ObjectInformation.FileId;
RtlZeroMemory( &stParentFileId,
sizeof( AFSFileID));
stParentFileId = pObjectInfo->ParentObjectInformation->FileId;
//
// Issue the close request to the service
//
AFSProcessRequest( AFS_REQUEST_TYPE_PIOCTL_CLOSE,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
NULL,
&stParentFileId,
(void *)&stPIOCtlClose,
sizeof( AFSPIOCtlOpenCloseRequestCB),
NULL,
NULL);
pDirCB = pCcb->DirectoryCB;
//
// Remove the Ccb and de-allocate it
//
ntStatus = AFSRemoveCcb( pCcb);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSClose Failed to remove Ccb from Fcb Status %08lX\n", ntStatus);
//
// We can't actually fail a close operation so reset the status
//
ntStatus = STATUS_SUCCESS;
}
ASSERT( pDirCB->OpenReferenceCount > 0);
InterlockedDecrement( &pDirCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (IOCtl) Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirCB->NameInformation.FileName,
pDirCB,
pCcb,
pDirCB->OpenReferenceCount);
//
// If this is not the root then decrement the open child reference count
//
if( pObjectInfo->ParentObjectInformation != NULL &&
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount > 0)
{
InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (IOCtl) Decrement child open ref count on Parent object %08lX Cnt %d\n",
pObjectInfo->ParentObjectInformation,
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
}
AFSReleaseResource( &pFcb->NPFcb->Resource);
ASSERT( pFcb->OpenReferenceCount != 0);
InterlockedDecrement( &pFcb->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (IOCtl) Decrement count on Fcb %08lX Cnt %d\n",
pFcb,
pFcb->OpenReferenceCount);
break;
}
case AFS_ROOT_ALL:
{
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Acquiring Special Root ALL lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSAcquireExcl( &pFcb->NPFcb->Resource,
TRUE);
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
pDirCB = pCcb->DirectoryCB;
//
// Remove the Ccb and de-allocate it
//
ntStatus = AFSRemoveCcb( pCcb);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSClose Failed to remove Ccb from Fcb Status %08lX\n", ntStatus);
//
// We can't actually fail a close operation so reset the status
//
ntStatus = STATUS_SUCCESS;
}
ASSERT( pDirCB->OpenReferenceCount > 0);
InterlockedDecrement( &pDirCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Decrement (Root ALL) count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirCB->NameInformation.FileName,
pDirCB,
pCcb,
pDirCB->OpenReferenceCount);
AFSReleaseResource( &pFcb->NPFcb->Resource);
ASSERT( pFcb->OpenReferenceCount > 0);
InterlockedDecrement( &pFcb->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (RootAll) Decrement count on Fcb %08lX Cnt %d\n",
pFcb,
pFcb->OpenReferenceCount);
break;
}
//
// Root, file or directory node
//
case AFS_FILE_FCB:
case AFS_ROOT_FCB:
case AFS_DIRECTORY_FCB:
case AFS_SYMBOLIC_LINK_FCB:
case AFS_MOUNT_POINT_FCB:
case AFS_DFS_LINK_FCB:
{
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
//
// We may be performing some cleanup on the Fcb so grab it exclusive to ensure no collisions
//
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Acquiring Dcb lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSAcquireExcl( &pFcb->NPFcb->Resource,
TRUE);
KeQueryTickCount( &pFcb->ObjectInformation->LastAccessCount);
pDirCB = pCcb->DirectoryCB;
//
// Remove the Ccb and de-allocate it
//
ntStatus = AFSRemoveCcb( pCcb);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSClose Failed to remove Ccb from Fcb Status %08lX\n",
ntStatus);
//
// We can't actually fail a close operation so reset the status
//
ntStatus = STATUS_SUCCESS;
}
//
// If this entry is deleted then remove the object from the volume tree
//
if( BooleanFlagOn( pDirCB->Flags, AFS_DIR_ENTRY_DELETED))
{
if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
{
//
// Stop anything possibly in process
//
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Acquiring Fcb extents lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Specific.File.ExtentsResource,
PsGetCurrentThread());
AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource,
TRUE);
pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsRequestStatus = STATUS_FILE_DELETED;
KeSetEvent( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsRequestComplete,
0,
FALSE);
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Releasing Fcb extents lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Specific.File.ExtentsResource,
PsGetCurrentThread());
AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->Specific.File.ExtentsResource);
}
AFSAcquireExcl( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
AFSAcquireExcl( pObjectInfo->VolumeCB->ObjectInfoTree.TreeLock,
TRUE);
if ( pDirCB->OpenReferenceCount == 0)
{
AFSDbgLogMsg( 0,
0,
"AFSClose (Other) OpenReferenceCount is Zero on DE %08lX Ccb %08lX FileName %wZ\n",
pDirCB,
pCcb,
&pDirCB->NameInformation.FileName);
}
ASSERT( pDirCB->OpenReferenceCount > 0);
InterlockedDecrement( &pDirCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (Other) Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirCB->NameInformation.FileName,
pDirCB,
pCcb,
pDirCB->OpenReferenceCount);
if( pDirCB->OpenReferenceCount == 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_CLEANUP_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Deleting dir etry %08lX (%08lX) for %wZ\n",
pDirCB,
pObjectInfo,
&pDirCB->NameInformation.FileName);
//
// Remove and delete the directory entry from the parent list
//
AFSDeleteDirEntry( pObjectInfo->ParentObjectInformation,
pDirCB);
if( pObjectInfo->ObjectReferenceCount == 0)
{
if( BooleanFlagOn( pObjectInfo->Flags, AFS_OBJECT_INSERTED_HASH_TREE))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_CLEANUP_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Removing object %08lX from volume tree\n",
pObjectInfo);
AFSRemoveHashEntry( &pObjectInfo->VolumeCB->ObjectInfoTree.TreeHead,
&pObjectInfo->TreeEntry);
ClearFlag( pObjectInfo->Flags, AFS_OBJECT_INSERTED_HASH_TREE);
}
SetFlag( pObjectInfo->Flags, AFS_OBJECT_FLAGS_DELETED);
}
}
AFSReleaseResource( pObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
AFSReleaseResource( pObjectInfo->VolumeCB->ObjectInfoTree.TreeLock);
}
else
{
ASSERT( pDirCB->OpenReferenceCount > 0);
InterlockedDecrement( &pDirCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (Other2) Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirCB->NameInformation.FileName,
pDirCB,
pCcb,
pDirCB->OpenReferenceCount);
}
//
// If this is not the root then decrement the open child reference count
//
if( pObjectInfo != NULL &&
pObjectInfo->ParentObjectInformation != NULL &&
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount > 0)
{
InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Decrement child open ref count on Parent object %08lX Cnt %d\n",
pObjectInfo->ParentObjectInformation,
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
}
if( pFcb->OpenReferenceCount == 1 &&
pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
{
SetFlag( pFcb->Flags, AFS_FCB_FILE_CLOSED);
//
// Attempt to tear down our extent list for the file
// If there are remaining dirty extents then attempt to
// flush them as well
//
if( pFcb->Specific.File.ExtentsDirtyCount)
{
AFSFlushExtents( pFcb);
}
//
// Wait for any outstanding queued flushes to complete
//
AFSWaitOnQueuedFlushes( pFcb);
ASSERT( pFcb->Specific.File.ExtentsDirtyCount == 0 &&
pFcb->Specific.File.QueuedFlushCount == 0);
AFSReleaseResource( &pFcb->NPFcb->Resource);
//
// Tear 'em down, we'll not be needing them again
//
if( AFSTearDownFcbExtents( pFcb))
{
//
// Indicate to the service that the file required complete flushing to the
// server.
//
AFSProcessRequest( AFS_REQUEST_TYPE_FLUSH_FILE,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
NULL,
&pFcb->ObjectInformation->FileId,
NULL,
0,
NULL,
NULL);
}
}
else
{
if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
{
if( pFcb->Specific.File.ExtentsDirtyCount)
{
AFSFlushExtents( pFcb);
}
}
AFSReleaseResource( &pFcb->NPFcb->Resource);
}
//
// Decrement the reference count on the Fcb. this is protecting it from teardown.
//
ASSERT( pFcb->OpenReferenceCount != 0);
InterlockedDecrement( &pFcb->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Decrement count on Fcb %08lX Cnt %d\n",
pFcb,
pFcb->OpenReferenceCount);
break;
}
case AFS_SPECIAL_SHARE_FCB:
{
AFSPipeOpenCloseRequestCB stPipeClose;
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose Acquiring Special Share lock %08lX EXCL %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSAcquireExcl( &pFcb->NPFcb->Resource,
TRUE);
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
pDirCB = pCcb->DirectoryCB;
RtlZeroMemory( &stPipeClose,
sizeof( AFSPipeOpenCloseRequestCB));
stPipeClose.RequestId = pCcb->RequestID;
stPipeClose.RootId = pObjectInfo->VolumeCB->ObjectInformation.FileId;
//
// Issue the open request to the service
//
/*
AFSProcessRequest( AFS_REQUEST_TYPE_PIPE_CLOSE,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
&pDirCB->NameInformation.FileName,
NULL,
(void *)&stPipeClose,
sizeof( AFSPipeOpenCloseRequestCB),
NULL,
NULL);
*/
//
// Remove the Ccb and de-allocate it
//
ntStatus = AFSRemoveCcb( pCcb);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSClose Failed to remove Ccb from Fcb Status %08lX\n", ntStatus);
//
// We can't actually fail a close operation so reset the status
//
ntStatus = STATUS_SUCCESS;
}
ASSERT( pDirCB->OpenReferenceCount > 0);
InterlockedDecrement( &pDirCB->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (Share) Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
&pDirCB->NameInformation.FileName,
pDirCB,
pCcb,
pDirCB->OpenReferenceCount);
//
// If this is not the root then decrement the open child reference count
//
if( pObjectInfo->ParentObjectInformation != NULL &&
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount > 0)
{
InterlockedDecrement( &pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (Share) Decrement child open ref count on Parent object %08lX Cnt %d\n",
pObjectInfo->ParentObjectInformation,
pObjectInfo->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
}
AFSReleaseResource( &pFcb->NPFcb->Resource);
ASSERT( pFcb->OpenReferenceCount != 0);
InterlockedDecrement( &pFcb->OpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FCB_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSClose (Share) Decrement count on Fcb %08lX Cnt %d\n",
pFcb,
pFcb->OpenReferenceCount);
break;
}
default:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSClose Processing unknown node type %d\n",
pFcb->Header.NodeTypeCode);
break;
}
try_exit:
//
// Complete the request
//
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSClose\n");
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSData.cpp
//
#define NO_EXTERN
#include "AFSCommon.h"
extern "C" {
PDRIVER_OBJECT AFSLibraryDriverObject = NULL;
PDEVICE_OBJECT AFSLibraryDeviceObject = NULL;
PDEVICE_OBJECT AFSControlDeviceObject = NULL;
PDEVICE_OBJECT AFSRDRDeviceObject = NULL;
unsigned long AFSCRCTable[ 256];
UNICODE_STRING AFSRegistryPath;
HANDLE AFSSysProcess = NULL;
UNICODE_STRING AFSServerName;
AFSVolumeCB *AFSGlobalRoot = NULL;
AFSVolumeCB *AFSRedirectorRoot = NULL;
UNICODE_STRING AFSPIOCtlName;
UNICODE_STRING AFSGlobalRootName;
ULONG AFSDebugFlags = 0;
CACHE_MANAGER_CALLBACKS *AFSLibCacheManagerCallbacks = NULL;
ULONG AFSLibControlFlags = 0;
void *AFSLibCacheBaseAddress = NULL;
LARGE_INTEGER AFSLibCacheLength = {0,0};
//
// List of 'special' share names we need to handle
//
AFSDirectoryCB *AFSSpecialShareNames = NULL;
//
// Global relative entries for enumerations
//
AFSDirectoryCB *AFSGlobalDotDirEntry = NULL;
AFSDirectoryCB *AFSGlobalDotDotDirEntry = NULL;
//
// Callbacks in the framework
//
PAFSProcessRequest AFSProcessRequest = NULL;
PAFSDbgLogMsg AFSDbgLogMsg = AFSDefaultLogMsg;
PAFSAddConnectionEx AFSAddConnectionEx = NULL;
PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag = NULL;
PAFSExFreePool AFSExFreePool = NULL;
PAFSDumpTraceFiles AFSDumpTraceFilesFnc = AFSDumpTraceFiles_Default;
PAFSRetrieveAuthGroup AFSRetrieveAuthGroupFnc = NULL;
//
// Security descriptor routine
//
PAFSRtlSetSaclSecurityDescriptor AFSRtlSetSaclSecurityDescriptor = NULL;
SECURITY_DESCRIPTOR *AFSDefaultSD = NULL;
}

View File

@ -0,0 +1,442 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSDevControl.cpp
//
#include "AFSCommon.h"
//
// Function: AFSDevControl
//
// Description:
//
// This is the dipatch handler for the IRP_MJ_DEVICE_CONTROL requests.
//
// Return:
//
// A status is returned for the function
//
NTSTATUS
AFSDevControl( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
ULONG ulIoControlCode;
__try
{
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
ulIoControlCode = pIrpSp->Parameters.DeviceIoControl.IoControlCode;
switch( ulIoControlCode)
{
case IOCTL_AFS_INITIALIZE_LIBRARY_DEVICE:
{
AFSLibraryInitCB *pLibInitCB = (AFSLibraryInitCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSLibraryInitCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSInitializeLibrary( pLibInitCB);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_LOAD_LIBRARY | AFS_SUBSYSTEM_INIT_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSDevControl AFSInitializeLibrary failure %08lX\n",
ntStatus);
break;
}
//
// Initialize our global entries
//
ntStatus = AFSInitializeGlobalDirectoryEntries();
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_LOAD_LIBRARY | AFS_SUBSYSTEM_INIT_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSDevControl AFSInitializeGlobalDirectoryEntries failure %08lX\n",
ntStatus);
break;
}
ntStatus = AFSInitializeSpecialShareNameList();
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_LOAD_LIBRARY | AFS_SUBSYSTEM_INIT_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSDevControl AFSInitializeSpecialShareNameList failure %08lX\n",
ntStatus);
break;
}
break;
}
case IOCTL_AFS_ADD_CONNECTION:
{
AFSNetworkProviderConnectionCB *pConnectCB = (AFSNetworkProviderConnectionCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSNetworkProviderConnectionCB) ||
pIrpSp->Parameters.DeviceIoControl.InputBufferLength < (ULONG)FIELD_OFFSET( AFSNetworkProviderConnectionCB, RemoteName) +
pConnectCB->RemoteNameLength ||
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( ULONG))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSAddConnection( pConnectCB,
(PULONG)Irp->AssociatedIrp.SystemBuffer,
&Irp->IoStatus.Information);
break;
}
case IOCTL_AFS_CANCEL_CONNECTION:
{
AFSNetworkProviderConnectionCB *pConnectCB = (AFSNetworkProviderConnectionCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSNetworkProviderConnectionCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSCancelConnection( pConnectCB,
(AFSCancelConnectionResultCB *)Irp->AssociatedIrp.SystemBuffer,
&Irp->IoStatus.Information);
break;
}
case IOCTL_AFS_GET_CONNECTION:
{
AFSNetworkProviderConnectionCB *pConnectCB = (AFSNetworkProviderConnectionCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSNetworkProviderConnectionCB) ||
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength == 0)
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSGetConnection( pConnectCB,
(WCHAR *)Irp->AssociatedIrp.SystemBuffer,
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength,
&Irp->IoStatus.Information);
break;
}
case IOCTL_AFS_LIST_CONNECTIONS:
{
if( pIrpSp->Parameters.DeviceIoControl.OutputBufferLength == 0)
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSListConnections( (AFSNetworkProviderConnectionCB *)Irp->AssociatedIrp.SystemBuffer,
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength,
&Irp->IoStatus.Information);
break;
}
case IOCTL_AFS_GET_CONNECTION_INFORMATION:
{
AFSNetworkProviderConnectionCB *pConnectCB = (AFSNetworkProviderConnectionCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSNetworkProviderConnectionCB) ||
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength == 0)
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSGetConnectionInfo( pConnectCB,
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength,
&Irp->IoStatus.Information);
break;
}
case IOCTL_AFS_SET_FILE_EXTENTS:
{
AFSSetFileExtentsCB *pExtents = (AFSSetFileExtentsCB*) Irp->AssociatedIrp.SystemBuffer;
//
// Check lengths twice so that if the buffer makes the
// count invalid we will not Accvio
//
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength <
( FIELD_OFFSET( AFSSetFileExtentsCB, ExtentCount) + sizeof(ULONG)) ||
pIrpSp->Parameters.DeviceIoControl.InputBufferLength <
( FIELD_OFFSET( AFSSetFileExtentsCB, ExtentCount) + sizeof(ULONG) +
sizeof (AFSFileExtentCB) * pExtents->ExtentCount))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSProcessSetFileExtents( pExtents );
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = ntStatus;
break;
}
case IOCTL_AFS_RELEASE_FILE_EXTENTS:
{
ntStatus = AFSProcessReleaseFileExtents( Irp);
break;
}
case IOCTL_AFS_SET_FILE_EXTENT_FAILURE:
{
ntStatus = AFSProcessExtentFailure( Irp);
break;
}
case IOCTL_AFS_INVALIDATE_CACHE:
{
AFSInvalidateCacheCB *pInvalidate = (AFSInvalidateCacheCB*)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSInvalidateCacheCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSInvalidateCache( pInvalidate);
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = ntStatus;
break;
}
case IOCTL_AFS_NETWORK_STATUS:
{
AFSNetworkStatusCB *pNetworkStatus = (AFSNetworkStatusCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSNetworkStatusCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
//
// Set the network status
//
ntStatus = AFSSetNetworkState( pNetworkStatus);
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = ntStatus;
break;
}
case IOCTL_AFS_VOLUME_STATUS:
{
AFSVolumeStatusCB *pVolumeStatus = (AFSVolumeStatusCB *)Irp->AssociatedIrp.SystemBuffer;
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSVolumeStatusCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSSetVolumeState( pVolumeStatus);
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = ntStatus;
break;
}
case IOCTL_AFS_STATUS_REQUEST:
{
if( pIrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( AFSDriverStatusRespCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSGetDriverStatus( (AFSDriverStatusRespCB *)Irp->AssociatedIrp.SystemBuffer);
Irp->IoStatus.Information = sizeof( AFSDriverStatusRespCB);
break;
}
case IOCTL_AFS_GET_OBJECT_INFORMATION:
{
if( pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSGetStatusInfoCB) ||
pIrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof( AFSStatusInfoCB))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
ntStatus = AFSGetObjectStatus( (AFSGetStatusInfoCB *)Irp->AssociatedIrp.SystemBuffer,
pIrpSp->Parameters.DeviceIoControl.InputBufferLength,
(AFSStatusInfoCB *)Irp->AssociatedIrp.SystemBuffer,
(ULONG *)&Irp->IoStatus.Information);
break;
}
case 0x140390: // IOCTL_LMR_DISABLE_LOCAL_BUFFERING
{
//
// See http://msdn.microsoft.com/en-us/library/ee210753%28v=vs.85%29.aspx
//
// The IOCTL_LMR_DISABLE_LOCAL_BUFFERING control code is defined internally by
// the system as 0x140390 and not in a public header file. It is used by
// special-purpose applications to disable local client-side in-memory
// caching of data when reading data from or writing data to a remote file.
// After local buffering is disabled, the setting remains in effect until all
// open handles to the file are closed and the redirector cleans up its internal
// data structures.
//
// General-purpose applications should not use IOCTL_LMR_DISABLE_LOCAL_BUFFERING,
// because it can result in excessive network traffic and associated loss of
// performance. The IOCTL_LMR_DISABLE_LOCAL_BUFFERING control code should be used
// only in specialized applications moving large amounts of data over the network
// while attempting to maximize use of network bandwidth. For example, the CopyFile
// and CopyFileEx functions use IOCTL_LMR_DISABLE_LOCAL_BUFFERING to improve large
// file copy performance.
//
// IOCTL_LMR_DISABLE_LOCAL_BUFFERING is not implemented by local file systems and
// will fail with the error ERROR_INVALID_FUNCTION. Issuing the
// IOCTL_LMR_DISABLE_LOCAL_BUFFERING control code on remote directory handles will
// fail with the error ERROR_NOT_SUPPORTED.
//
ntStatus = STATUS_NOT_SUPPORTED;
break;
}
default:
{
ntStatus = STATUS_NOT_IMPLEMENTED;
break;
}
}
//try_exit:
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()))
{
ntStatus = STATUS_UNSUCCESSFUL;
}
Irp->IoStatus.Status = ntStatus;
AFSCompleteRequest( Irp,
ntStatus);
return ntStatus;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSEa.cpp
//
#include "AFSCommon.h"
//
// Function: AFSQueryEA
//
// Description:
//
// This function is the dipatch handler for the IRP_MJ_QUERY_EA request
//
// Return:
//
// A status is returned for the function
//
NTSTATUS
AFSQueryEA( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_EAS_NOT_SUPPORTED;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQueryEa Entry for FO %08lX\n", pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSQueryEA\n");
}
return ntStatus;
}
//
// Function: AFSSetEA
//
// Description:
//
// This function is the dipatch handler for the IRP_MJ_SET_EA request
//
// Return:
//
// A status is returned for the function
//
NTSTATUS
AFSSetEA( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_EAS_NOT_SUPPORTED;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSSetEa Entry for FO %08lX\n", pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSetEA\n");
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,739 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSFSControl.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSFSControl( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
switch( pIrpSp->MinorFunction)
{
case IRP_MN_USER_FS_REQUEST:
ntStatus = AFSProcessUserFsRequest( Irp);
break;
case IRP_MN_MOUNT_VOLUME:
break;
case IRP_MN_VERIFY_VOLUME:
break;
default:
break;
}
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSFSControl\n");
}
return ntStatus;
}
static BOOLEAN
AFSParseMountPointTarget( IN UNICODE_STRING *Target,
OUT USHORT *Type,
OUT UNICODE_STRING *Volume,
OUT UNICODE_STRING *Cell)
{
// Targets are of the form <type>[<cell>:]<volume>
*Type = Target->Buffer[ 0];
// Extract the cell name (if any)
Cell->Buffer = &Target->Buffer[ 1];
// Search for colon separator or end of counted string
for ( Cell->Length = 0; Cell->Length < Target->Length - sizeof( WCHAR); Cell->Length += sizeof( WCHAR))
{
if ( Cell->Buffer[ Cell->Length / sizeof( WCHAR)] == L':')
{
break;
}
}
// If a colon is not found, it means there is no cell
if ( Cell->Buffer[ Cell->Length / sizeof( WCHAR)] == L':')
{
Cell->MaximumLength = Cell->Length;
if ( Cell->Length > Target->Length - 2 * sizeof( WCHAR))
{
// Invalid target string if there is no room for
// the volume name.
return FALSE;
}
Volume->Length = Volume->MaximumLength = (Target->Length - Cell->Length - 2 * sizeof( WCHAR));
Volume->Buffer = &Target->Buffer[ Cell->Length / sizeof( WCHAR) + 2];
}
else
{
// There is no cell
Volume->Length = Volume->MaximumLength = Cell->Length;
Volume->Buffer = Cell->Buffer;
Cell->Length = Cell->MaximumLength = 0;
Cell->Buffer = NULL;
}
return TRUE;
}
NTSTATUS
AFSProcessUserFsRequest( IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
ULONG ulFsControlCode;
AFSFcb *pFcb = NULL;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp );
AFSCcb *pCcb = NULL;
ULONG ulOutputBufferLen, ulInputBufferLen;
__Enter
{
ulFsControlCode = pIrpSp->Parameters.FileSystemControl.FsControlCode;
pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
if( pFcb == NULL ||
pCcb->DirectoryCB == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Invalid Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
if( pFcb->Header.NodeTypeCode == AFS_SPECIAL_SHARE_FCB)
{
ntStatus = AFSProcessShareFsCtrl( Irp,
pFcb,
pCcb);
try_return( ntStatus);
}
ulOutputBufferLen = pIrpSp->Parameters.FileSystemControl.OutputBufferLength;
ulInputBufferLen = pIrpSp->Parameters.FileSystemControl.InputBufferLength;
//
// Process the request
//
switch( ulFsControlCode )
{
case FSCTL_REQUEST_OPLOCK_LEVEL_1:
case FSCTL_REQUEST_OPLOCK_LEVEL_2:
case FSCTL_REQUEST_BATCH_OPLOCK:
case FSCTL_OPLOCK_BREAK_ACKNOWLEDGE:
case FSCTL_OPBATCH_ACK_CLOSE_PENDING:
case FSCTL_OPLOCK_BREAK_NOTIFY:
case FSCTL_OPLOCK_BREAK_ACK_NO_2:
case FSCTL_REQUEST_FILTER_OPLOCK :
//
// Note that implementing this call will probably need us
// to call the server as well as adding code in read and
// write and caching. Also that it is unlikely that
// anyone will ever call us at this point - RDR doesn't
// allow it
//
ntStatus = STATUS_NOT_IMPLEMENTED;
break;
case FSCTL_LOCK_VOLUME:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_LOCK_VOLUME request\n");
break;
case FSCTL_UNLOCK_VOLUME:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_UNLOCK_VOLUME request\n");
break;
case FSCTL_DISMOUNT_VOLUME:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_DISMOUNT_VOLUME request\n");
break;
case FSCTL_MARK_VOLUME_DIRTY:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_MARK_VOLUME_DIRTY request\n");
break;
case FSCTL_IS_VOLUME_DIRTY:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_IS_VOLUME_DIRTY request\n");
break;
case FSCTL_IS_VOLUME_MOUNTED:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_IS_VOLUME_MOUNTED request\n");
break;
case FSCTL_IS_PATHNAME_VALID:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_IS_PATHNAME_VALID request\n");
break;
case FSCTL_GET_REPARSE_POINT:
{
REPARSE_GUID_DATA_BUFFER *pReparseBuffer = (REPARSE_GUID_DATA_BUFFER *)Irp->AssociatedIrp.SystemBuffer;
ULONG ulRemainingLen = ulOutputBufferLen;
AFSReparseTagInfo *pReparseInfo = NULL;
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_GET_REPARSE_POINT request\n");
if( ulOutputBufferLen < FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer))
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Information = FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer);
break;
}
ulRemainingLen -= FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer);
//
// Check if we have the reparse entry set on the entry
//
if( !BooleanFlagOn( pCcb->DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_REPARSE_POINT))
{
ntStatus = STATUS_NOT_A_REPARSE_POINT;
break;
}
//
// Populate the data in the reparse buffer
//
pReparseBuffer->ReparseDataLength = 0;
AFSAcquireExcl( &pCcb->DirectoryCB->NonPaged->Lock,
TRUE);
if( pCcb->DirectoryCB->NameInformation.TargetName.Length == 0)
{
//
// We'll reset the DV to ensure we validate the metadata content
//
pCcb->DirectoryCB->ObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
SetFlag( pCcb->DirectoryCB->ObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSProcessUserFsRequest Verifying symlink %wZ FID %08lX-%08lX-%08lX-%08lX\n",
&pCcb->DirectoryCB->NameInformation.FileName,
pCcb->DirectoryCB->ObjectInformation->FileId.Cell,
pCcb->DirectoryCB->ObjectInformation->FileId.Volume,
pCcb->DirectoryCB->ObjectInformation->FileId.Vnode,
pCcb->DirectoryCB->ObjectInformation->FileId.Unique);
ntStatus = AFSVerifyEntry( &pFcb->AuthGroup,
pCcb->DirectoryCB);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSProcessUserFsRequest Failed to verify symlink %wZ FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
&pCcb->DirectoryCB->NameInformation.FileName,
pCcb->DirectoryCB->ObjectInformation->FileId.Cell,
pCcb->DirectoryCB->ObjectInformation->FileId.Volume,
pCcb->DirectoryCB->ObjectInformation->FileId.Vnode,
pCcb->DirectoryCB->ObjectInformation->FileId.Unique,
ntStatus);
AFSReleaseResource( &pCcb->DirectoryCB->NonPaged->Lock);
break;
}
}
pReparseInfo = (AFSReparseTagInfo *)&pReparseBuffer->GenericReparseBuffer.DataBuffer[ 0];
switch( pCcb->DirectoryCB->ObjectInformation->FileType)
{
case AFS_FILE_TYPE_SYMLINK:
{
if( pCcb->DirectoryCB->NameInformation.TargetName.Length == 0)
{
ntStatus = STATUS_ACCESS_DENIED;
break;
}
if( ulRemainingLen < (ULONG) FIELD_OFFSET( AFSReparseTagInfo, AFSSymLink.Buffer) + pCcb->DirectoryCB->NameInformation.TargetName.Length)
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Information = FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer) +
FIELD_OFFSET( AFSReparseTagInfo, AFSSymLink.Buffer) +
pCcb->DirectoryCB->NameInformation.TargetName.Length;
break;
}
pReparseInfo->SubTag = OPENAFS_SUBTAG_SYMLINK;
pReparseInfo->AFSSymLink.RelativeLink = AFSIsRelativeName( &pCcb->DirectoryCB->NameInformation.TargetName);
pReparseInfo->AFSSymLink.SymLinkTargetLength = pCcb->DirectoryCB->NameInformation.TargetName.Length;
RtlCopyMemory( pReparseInfo->AFSSymLink.Buffer,
pCcb->DirectoryCB->NameInformation.TargetName.Buffer,
pCcb->DirectoryCB->NameInformation.TargetName.Length);
pReparseBuffer->ReparseDataLength = (FIELD_OFFSET( AFSReparseTagInfo, AFSSymLink.Buffer) + pCcb->DirectoryCB->NameInformation.TargetName.Length);
break;
}
case AFS_FILE_TYPE_MOUNTPOINT:
{
UNICODE_STRING Cell, Volume;
USHORT Type;
if( pCcb->DirectoryCB->NameInformation.TargetName.Length == 0)
{
ntStatus = STATUS_ACCESS_DENIED;
break;
}
if ( !AFSParseMountPointTarget( &pCcb->DirectoryCB->NameInformation.TargetName,
&Type,
&Volume,
&Cell))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
if( ulRemainingLen < (ULONG) FIELD_OFFSET( AFSReparseTagInfo, AFSMountPoint.Buffer) + Volume.Length + Cell.Length)
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Information = FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer) +
FIELD_OFFSET( AFSReparseTagInfo, AFSMountPoint.Buffer) +
Volume.Length + Cell.Length;
break;
}
pReparseInfo->SubTag = OPENAFS_SUBTAG_MOUNTPOINT;
pReparseInfo->AFSMountPoint.Type = Type;
pReparseInfo->AFSMountPoint.MountPointCellLength = Cell.Length;
pReparseInfo->AFSMountPoint.MountPointVolumeLength = Volume.Length;
RtlCopyMemory( pReparseInfo->AFSMountPoint.Buffer,
Cell.Buffer,
Cell.Length);
RtlCopyMemory( &pReparseInfo->AFSMountPoint.Buffer[ Cell.Length / sizeof( WCHAR)],
Volume.Buffer,
Volume.Length);
pReparseBuffer->ReparseDataLength = (FIELD_OFFSET( AFSReparseTagInfo, AFSMountPoint.Buffer) + Volume.Length + Cell.Length);
break;
}
case AFS_FILE_TYPE_DFSLINK:
{
if( pCcb->DirectoryCB->NameInformation.TargetName.Length == 0)
{
ntStatus = STATUS_ACCESS_DENIED;
break;
}
if( ulRemainingLen < (ULONG) FIELD_OFFSET( AFSReparseTagInfo, UNCReferral.Buffer) + pCcb->DirectoryCB->NameInformation.TargetName.Length)
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
Irp->IoStatus.Information = FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer) +
FIELD_OFFSET( AFSReparseTagInfo, UNCReferral.Buffer) +
pCcb->DirectoryCB->NameInformation.TargetName.Length;
break;
}
pReparseInfo->SubTag = OPENAFS_SUBTAG_UNC;
pReparseInfo->UNCReferral.UNCTargetLength = pCcb->DirectoryCB->NameInformation.TargetName.Length;
RtlCopyMemory( pReparseInfo->UNCReferral.Buffer,
pCcb->DirectoryCB->NameInformation.TargetName.Buffer,
pCcb->DirectoryCB->NameInformation.TargetName.Length);
pReparseBuffer->ReparseDataLength = (FIELD_OFFSET( AFSReparseTagInfo, UNCReferral.Buffer) + pCcb->DirectoryCB->NameInformation.TargetName.Length);
break;
}
default:
ntStatus = STATUS_NOT_A_REPARSE_POINT;
break;
}
if ( ntStatus == STATUS_SUCCESS)
{
ulRemainingLen -= pReparseBuffer->ReparseDataLength;
pReparseBuffer->ReparseTag = IO_REPARSE_TAG_OPENAFS_DFS;
RtlCopyMemory( &pReparseBuffer->ReparseGuid,
&GUID_AFS_REPARSE_GUID,
sizeof( GUID));
Irp->IoStatus.Information = FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer) +
pReparseBuffer->ReparseDataLength;
}
AFSReleaseResource( &pCcb->DirectoryCB->NonPaged->Lock);
break;
}
case FSCTL_SET_REPARSE_POINT:
{
REPARSE_GUID_DATA_BUFFER *pReparseBuffer = (REPARSE_GUID_DATA_BUFFER *)Irp->AssociatedIrp.SystemBuffer;
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_SET_REPARSE_POINT request\n");
if( ulInputBufferLen < FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
//
// Check if we have the reparse entry set on the entry
//
if( !BooleanFlagOn( pCcb->DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_REPARSE_POINT))
{
ntStatus = STATUS_NOT_A_REPARSE_POINT;
break;
}
if( pReparseBuffer->ReparseTag != IO_REPARSE_TAG_OPENAFS_DFS)
{
ntStatus = STATUS_IO_REPARSE_TAG_MISMATCH;
break;
}
if( RtlCompareMemory( &pReparseBuffer->ReparseGuid,
&GUID_AFS_REPARSE_GUID,
sizeof( GUID)) != sizeof( GUID))
{
ntStatus = STATUS_REPARSE_ATTRIBUTE_CONFLICT;
break;
}
//
// For now deny access on this call
//
break;
}
case FSCTL_DELETE_REPARSE_POINT:
{
REPARSE_GUID_DATA_BUFFER *pReparseBuffer = (REPARSE_GUID_DATA_BUFFER *)Irp->AssociatedIrp.SystemBuffer;
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing FSCTL_DELETE_REPARSE_POINT request\n");
if( ulInputBufferLen < FIELD_OFFSET( REPARSE_GUID_DATA_BUFFER, GenericReparseBuffer.DataBuffer))
{
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
//
// Check if we have the reparse entry set on the entry
//
if( !BooleanFlagOn( pCcb->DirectoryCB->ObjectInformation->FileAttributes, FILE_ATTRIBUTE_REPARSE_POINT))
{
ntStatus = STATUS_NOT_A_REPARSE_POINT;
break;
}
if( pReparseBuffer->ReparseTag != IO_REPARSE_TAG_OPENAFS_DFS)
{
ntStatus = STATUS_IO_REPARSE_TAG_MISMATCH;
break;
}
if( RtlCompareMemory( &pReparseBuffer->ReparseGuid,
&GUID_AFS_REPARSE_GUID,
sizeof( GUID)) != sizeof( GUID))
{
ntStatus = STATUS_REPARSE_ATTRIBUTE_CONFLICT;
break;
}
//
// For now deny access on this call
//
ntStatus = STATUS_ACCESS_DENIED;
break;
}
default :
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSProcessUserFsRequest Processing default (%08lX) request\n", ulFsControlCode);
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
try_exit:
NOTHING;
}
return ntStatus;
}
NTSTATUS
AFSProcessShareFsCtrl( IN IRP *Irp,
IN AFSFcb *Fcb,
IN AFSCcb *Ccb)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION pIrpSp = IoGetCurrentIrpStackLocation( Irp);
ULONG ulOutputBufferLen = 0, ulInputBufferLen;
ULONG ulFsControlCode;
__Enter
{
ulFsControlCode = pIrpSp->Parameters.FileSystemControl.FsControlCode;
ulOutputBufferLen = pIrpSp->Parameters.FileSystemControl.OutputBufferLength;
ulInputBufferLen = pIrpSp->Parameters.FileSystemControl.InputBufferLength;
switch( ulFsControlCode)
{
case FSCTL_PIPE_TRANSCEIVE:
{
AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSProcessShareFsCtrl On pipe %wZ Class FSCTL_PIPE_TRANSCEIVE\n",
&Ccb->DirectoryCB->NameInformation.FileName);
ntStatus = AFSNotifyPipeTransceive( Ccb,
ulInputBufferLen,
ulOutputBufferLen,
pIrpSp->Parameters.FileSystemControl.Type3InputBuffer,
Irp->UserBuffer,
(ULONG *)&Irp->IoStatus.Information);
if( !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_PIPE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSProcessShareFsCtrl Failure on pipe %wZ Class FSCTL_PIPE_TRANSCEIVE Status %08lX\n",
&Ccb->DirectoryCB->NameInformation.FileName,
ntStatus);
}
break;
}
default:
{
if( BooleanFlagOn( Ccb->DirectoryCB->Flags, AFS_DIR_ENTRY_SERVER_SERVICE))
{
//AFSPrint("AFSProcessShareFsCtrl (%08lX) For srvsvc input %08lX output %08lX\n",
// ulFsControlCode,
// ulInputBufferLen,
// ulOutputBufferLen);
}
else if( BooleanFlagOn( Ccb->DirectoryCB->Flags, AFS_DIR_ENTRY_WORKSTATION_SERVICE))
{
//AFSPrint("AFSProcessShareFsCtrl (%08lX) For wkssvc input %08lX output %08lX\n",
// ulFsControlCode,
// ulInputBufferLen,
// ulOutputBufferLen);
}
else
{
//AFSPrint("AFSProcessShareFsCtrl (%08lX) For IPC$ input %08lX output %08lX\n",
// ulFsControlCode,
// ulInputBufferLen,
// ulOutputBufferLen);
}
break;
}
}
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,138 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSFlushBuffers.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSFlushBuffers( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
PFILE_OBJECT pFileObject = pIrpSp->FileObject;
AFSFcb *pFcb = (AFSFcb *)pFileObject->FsContext;
AFSCcb *pCcb = (AFSCcb *)pFileObject->FsContext2;
IO_STATUS_BLOCK iosb = {0};
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__Enter
{
if( pFcb == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSFlushBuffers Attempted access (%08lX) when pFcb == NULL\n",
Irp);
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
if( pFcb->Header.NodeTypeCode == AFS_ROOT_FCB ||
pFcb->Header.NodeTypeCode == AFS_ROOT_ALL )
{
//
// Once we support ADS's on directories we need to perform a flush ehre
//
try_return( ntStatus = STATUS_SUCCESS);
}
else if (pFcb->Header.NodeTypeCode != AFS_FILE_FCB)
{
//
// Nothing to flush Everything but files are write through
//
try_return( ntStatus = STATUS_INVALID_PARAMETER);
}
//
// The flush consists of two parts. We firstly flush our
// cache (if we have one), then we tell the service to write
// to the remote server
//
__try
{
CcFlushCache( &pFcb->NPFcb->SectionObjectPointers, NULL, 0, &iosb);
if (!NT_SUCCESS( iosb.Status ))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSFlushBuffers CcFlushCache [1] failure FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX Bytes 0x%08lX\n",
pFcb->ObjectInformation->FileId.Cell,
pFcb->ObjectInformation->FileId.Volume,
pFcb->ObjectInformation->FileId.Vnode,
pFcb->ObjectInformation->FileId.Unique,
iosb.Status,
iosb.Information);
try_return( ntStatus = iosb.Status );
}
}
__except( EXCEPTION_EXECUTE_HANDLER)
{
try_return( ntStatus = GetExceptionCode());
}
//
// Now, flush to the server - if there is stuff to do
//
ntStatus = AFSFlushExtents( pFcb);
if( !NT_SUCCESS( ntStatus))
{
AFSReleaseExtentsWithFlush( pFcb);
ntStatus = STATUS_SUCCESS;
}
try_exit:
AFSCompleteRequest( Irp, ntStatus);
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,334 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSInit.cpp
//
#include "AFSCommon.h"
//
// DriverEntry
//
// This is the initial entry point for the driver.
//
// Inputs:
// DriverObject Pointer to Driver Object created by I/O manager
// RegistryPath Pointer to registry path representing this Driver
//
// Returns:
// Success To indicate Driver's inituaialization processing
// was successful
// NT ERROR STATUS Otherwise -- Driver does not remain loaded
//
NTSTATUS
DriverEntry( PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
AFSDeviceExt *pDeviceExt;
ULONG ulTimeIncrement = 0;
UNICODE_STRING uniDeviceName;
ULONG ulIndex = 0;
UNICODE_STRING uniRoutine;
RTL_OSVERSIONINFOW sysVersion;
BOOLEAN bExit = FALSE;
__try
{
AFSPrint("AFSLibrary DriverEntry Initialization build %s:%s\n", __DATE__, __TIME__);
//
// Our backdoor to not let the driver load
//
if( bExit)
{
//
// Return a failure so we can update the binary and manually start it without
// having to do a reboot
//
try_return( ntStatus = STATUS_UNSUCCESSFUL);
}
//
// Perform some initialization
//
AFSLibraryDriverObject = DriverObject;
//
// Setup the registry string
//
AFSRegistryPath.MaximumLength = RegistryPath->MaximumLength;
AFSRegistryPath.Length = RegistryPath->Length;
AFSRegistryPath.Buffer = (PWSTR)AFSLibExAllocatePoolWithTag( PagedPool,
AFSRegistryPath.Length,
AFS_GENERIC_MEMORY_13_TAG);
if( AFSRegistryPath.Buffer == NULL)
{
AFSPrint("AFS DriverEntry Failed to allocate registry path buffer\n");
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
RtlCopyMemory( AFSRegistryPath.Buffer,
RegistryPath->Buffer,
RegistryPath->Length);
RtlZeroMemory( &sysVersion,
sizeof( RTL_OSVERSIONINFOW));
sysVersion.dwOSVersionInfoSize = sizeof( RTL_OSVERSIONINFOW);
RtlGetVersion( &sysVersion);
#if 0
//
// By not fetching the RtlSetSaclSecurityDescriptor function
// pointer it disables the additional of a mandatory label
// to the default acl which is returned by AFSRedir for all
// security information queries. The addition of the
// mandatory label appears to have a negative consequence
// for roaming profiles and redirected folders. All links
// become untrusted and IE9 is unable to open a new instance
// to a non-default home page.
//
//
// Only retrieve this function for Vista and above since
// Mandatory Labels only exist on those operating systems.
//
if( sysVersion.dwMajorVersion >= 6)
{
RtlInitUnicodeString( &uniRoutine,
L"RtlSetSaclSecurityDescriptor");
AFSRtlSetSaclSecurityDescriptor = (PAFSRtlSetSaclSecurityDescriptor)MmGetSystemRoutineAddress( &uniRoutine);
}
ntStatus = AFSCreateDefaultSecurityDescriptor();
if( !NT_SUCCESS( ntStatus))
{
AFSPrint("AFS DriverEntry AFSCreateDefaultSecurityDescriptor failed Status %08lX\n", ntStatus);
ntStatus = STATUS_SUCCESS;
}
#endif
//
// Initilize the control device
//
RtlInitUnicodeString( &uniDeviceName,
AFS_LIBRARY_CONTROL_DEVICE_NAME);
ntStatus = IoCreateDevice( DriverObject,
sizeof( AFSDeviceExt),
&uniDeviceName,
FILE_DEVICE_DISK_FILE_SYSTEM,
0,
FALSE,
&AFSLibraryDeviceObject);
if( !NT_SUCCESS( ntStatus))
{
AFSPrint("AFS DriverEntry - Failed to allocate device control object Status %08lX\n", ntStatus);
try_return( ntStatus);
}
//
// Setup the device extension
//
pDeviceExt = (AFSDeviceExt *)AFSLibraryDeviceObject->DeviceExtension;
//
// Now initialize the control device
//
ntStatus = AFSInitializeLibraryDevice();
if( !NT_SUCCESS( ntStatus))
{
try_return( ntStatus);
}
//
// Initialize the worker thread pool
//
ntStatus = AFSInitializeWorkerPool();
if( !NT_SUCCESS( ntStatus))
{
AFSPrint("AFS DriverEntry Failed to initialize worker pool Status %08lX\n", ntStatus);
try_return( ntStatus);
}
//
// Fill in the dispatch table
//
for( ulIndex = 0; ulIndex <= IRP_MJ_MAXIMUM_FUNCTION; ulIndex++)
{
DriverObject->MajorFunction[ ulIndex] = AFSDefaultDispatch;
}
DriverObject->MajorFunction[IRP_MJ_CREATE] = AFSCreate;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = AFSClose;
DriverObject->MajorFunction[IRP_MJ_READ] = AFSRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = AFSWrite;
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = AFSQueryFileInfo;
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = AFSSetFileInfo;
DriverObject->MajorFunction[IRP_MJ_QUERY_EA] = AFSQueryEA;
DriverObject->MajorFunction[IRP_MJ_SET_EA] = AFSSetEA;
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = AFSFlushBuffers;
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = AFSQueryVolumeInfo;
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = AFSSetVolumeInfo;
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = AFSDirControl;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = AFSFSControl;
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = AFSDevControl;
DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = AFSInternalDevControl;
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = AFSShutdown;
DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = AFSLockControl;
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = AFSCleanup;
DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] = AFSQuerySecurity;
DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] = AFSSetSecurity;
DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = AFSSystemControl;
//DriverObject->MajorFunction[IRP_MJ_QUERY_QUOTA] = AFSQueryQuota;
//DriverObject->MajorFunction[IRP_MJ_SET_QUOTA] = AFSSetQuota;
DriverObject->DriverUnload = AFSUnload;
AFSSysProcess = PsGetCurrentProcessId();
try_exit:
if( !NT_SUCCESS( ntStatus))
{
AFSPrint("AFSLibrary DriverEntry failed to initialize %08lX\n", ntStatus);
if( AFSLibraryDeviceObject != NULL)
{
AFSRemoveWorkerPool();
}
if( AFSRegistryPath.Buffer != NULL)
{
ExFreePool( AFSRegistryPath.Buffer);
}
if( AFSLibraryDeviceObject != NULL)
{
AFSRemoveLibraryDevice();
IoDeleteDevice( AFSLibraryDeviceObject);
}
}
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSPrint( "EXCEPTION - AFS DriverEntry\n");
}
return ntStatus;
}
void
AFSUnload( IN PDRIVER_OBJECT DriverObject)
{
if( AFSGlobalRoot != NULL)
{
AFSInvalidateVolume( AFSGlobalRoot,
AFS_INVALIDATE_CALLBACK);
ClearFlag( AFSGlobalRoot->Flags, AFS_VOLUME_ACTIVE_GLOBAL_ROOT);
AFSShutdownVolumeWorker( AFSGlobalRoot);
}
if( AFSLibraryDeviceObject != NULL)
{
AFSRemoveWorkerPool();
}
if( AFSRegistryPath.Buffer != NULL)
{
ExFreePool( AFSRegistryPath.Buffer);
}
AFSCloseLibrary();
if( AFSDefaultSD != NULL)
{
ExFreePool( AFSDefaultSD);
}
if( AFSLibraryDeviceObject != NULL)
{
AFSRemoveLibraryDevice();
IoDeleteDevice( AFSLibraryDeviceObject);
}
return;
}

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSInternalDevControl.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSInternalDevControl( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_NOT_IMPLEMENTED;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSInternalDevControl\n");
}
return ntStatus;
}

View File

@ -0,0 +1,527 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSIoSupport.cpp
//
#include "AFSCommon.h"
static AFSExtent *NextExtent(AFSExtent *Extent);
//
// Called in the paging or non cached read and write paths to get the
// first and last extent in a span. We also the count of how many
// discontiguous extents the are in the cache file.
//
NTSTATUS
AFSGetExtents( IN AFSFcb *Fcb,
IN PLARGE_INTEGER Offset,
IN ULONG Length,
OUT AFSExtent *From,
OUT ULONG *ExtentCount,
OUT ULONG *RunCount)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
ULONG extentsCount = 0, runCount = 0;
AFSExtent *pEndExtent = NULL;
LARGE_INTEGER liLastCacheOffset;
*ExtentCount = 0;
__Enter
{
ASSERT(AFSExtentContains(From, Offset));
pEndExtent = From;
extentsCount = 1;
runCount = 1;
liLastCacheOffset.QuadPart = pEndExtent->CacheOffset.QuadPart + pEndExtent->Size;
while ((Offset->QuadPart + Length) >
pEndExtent->FileOffset.QuadPart + pEndExtent->Size) {
pEndExtent = NextExtent(pEndExtent);
if (liLastCacheOffset.QuadPart != pEndExtent->CacheOffset.QuadPart) {
//
// Discontiguous (in the cache)
//
runCount += 1;
}
extentsCount+= 1;
liLastCacheOffset.QuadPart = pEndExtent->CacheOffset.QuadPart + pEndExtent->Size;
}
*ExtentCount = extentsCount;
*RunCount = runCount;
ntStatus = STATUS_SUCCESS;
}
return ntStatus;
}
NTSTATUS
AFSSetupIoRun( IN PDEVICE_OBJECT CacheDevice,
IN PIRP MasterIrp,
IN PVOID SystemBuffer,
IN OUT AFSIoRun *IoRuns,
IN PLARGE_INTEGER Start,
IN ULONG Length,
IN AFSExtent *From,
IN OUT ULONG *RunCount)
{
//
// Do all the work which we can prior to firing off the IRP
// (allocate them, calculate offsets and so on)
//
LARGE_INTEGER liCacheOffset;
LARGE_INTEGER liFileOffset = *Start;
ULONG ulCurrLength;
ULONG ulReadOffset;
ULONG ulCurrRun = 0;
AFSExtent *pExtent = From;
AFSExtent *pNextExtent;
PMDL *pMDL;
BOOLEAN done = FALSE;
NTSTATUS ntStatus = STATUS_SUCCESS;
__Enter
{
while( !done)
{
ASSERT( liFileOffset.QuadPart >= pExtent->FileOffset.QuadPart );
liCacheOffset = pExtent->CacheOffset;
liCacheOffset.QuadPart += (liFileOffset.QuadPart -
pExtent->FileOffset.QuadPart);
ulCurrLength = 0;
//
// While there is still data to process, loop
//
while ( (pExtent->FileOffset.QuadPart + pExtent->Size) <
(Start->QuadPart + Length) )
{
//
// Collapse the read if we can
//
pNextExtent = NextExtent( pExtent );
if (pNextExtent->CacheOffset.QuadPart !=
(pExtent->CacheOffset.QuadPart + pExtent->Size))
{
//
// This extent and the next extent are not contiguous
//
break;
}
pExtent = pNextExtent;
}
//
// So, this run goes from liCacheOffset to the end of pExtent
//
if ((pExtent->FileOffset.QuadPart + pExtent->Size) >= (Start->QuadPart + Length))
{
//
// The last extent overruns the area we care
// about, so trim it back.
//
ulCurrLength = (ULONG) (Start->QuadPart + Length -
liFileOffset.QuadPart);
//
// But we are done
//
done = TRUE;
}
else
{
//
// Length is from the LiFileOffset to the end of this
// extent.
//
ulCurrLength = (ULONG) (pExtent->FileOffset.QuadPart + pExtent->Size -
liFileOffset.QuadPart);
done = FALSE;
}
//
// Calculate the offset into the buffer
//
ulReadOffset = (ULONG) (liFileOffset.QuadPart - Start->QuadPart);
IoRuns[ulCurrRun].CacheOffset = liCacheOffset;
IoRuns[ulCurrRun].ByteCount = ulCurrLength;
IoRuns[ulCurrRun].ChildIrp = IoAllocateIrp( CacheDevice->StackSize + 1,
FALSE);
if (NULL == IoRuns[ulCurrRun].ChildIrp)
{
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES );
}
IoRuns[ulCurrRun].ChildIrp->UserBuffer = ((PCHAR) SystemBuffer) + ulReadOffset;
IoRuns[ulCurrRun].ChildIrp->Tail.Overlay.Thread = PsGetCurrentThread();
IoRuns[ulCurrRun].ChildIrp->RequestorMode = KernelMode;
IoRuns[ulCurrRun].ChildIrp->MdlAddress = NULL;
ulCurrRun ++;
if (!done)
{
ASSERT(pNextExtent != NULL && pNextExtent != pExtent);
//
// Move cursors forward
//
pExtent = pNextExtent;
liFileOffset = pExtent->FileOffset;
}
}
ASSERT(ulCurrRun <= *RunCount);
try_exit:
if (!NT_SUCCESS(ntStatus))
{
for (ulCurrRun = 0 ; ulCurrRun < *RunCount; ulCurrRun++)
{
if (IoRuns[ulCurrRun].ChildIrp) {
IoFreeIrp( IoRuns[ulCurrRun].ChildIrp );
IoRuns[ulCurrRun].ChildIrp = NULL;
}
}
}
else
{
*RunCount = ulCurrRun;
}
}
return ntStatus;
}
//
// We manage our own scatter / gather. This completion
// function calls into our generic function.
//
static
NTSTATUS
CompletionFunction(IN PDEVICE_OBJECT DeviceObject,
PIRP Irp,
PVOID Context)
{
AFSGatherIo *pGather = (AFSGatherIo *) Context;
AFSCompleteIo( pGather, Irp->IoStatus.Status);
if (Irp->MdlAddress) {
if (Irp->MdlAddress->MdlFlags & MDL_PAGES_LOCKED) {
MmUnlockPages(Irp->MdlAddress);
}
IoFreeMdl(Irp->MdlAddress);
Irp->MdlAddress = NULL;
}
IoFreeIrp(Irp);
//
// Tell io manager that we own the Irp
//
return STATUS_MORE_PROCESSING_REQUIRED;
}
NTSTATUS
AFSStartIos( IN PFILE_OBJECT CacheFileObject,
IN UCHAR FunctionCode,
IN ULONG IrpFlags,
IN AFSIoRun *IoRun,
IN ULONG Count,
IN OUT AFSGatherIo *Gather)
{
AFSDeviceExt *pRdrDevExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
PIO_STACK_LOCATION pIoStackLocation = NULL;
PIRP pIrp;
NTSTATUS ntStatus = STATUS_SUCCESS;
PDEVICE_OBJECT pDeviceObject = NULL;
__Enter
{
pDeviceObject = IoGetRelatedDeviceObject( CacheFileObject);
for (ULONG i = 0; i < Count; i++)
{
pIrp = IoRun[i].ChildIrp;
pIoStackLocation = IoGetNextIrpStackLocation( pIrp);
pIrp->Flags = IrpFlags;
pIoStackLocation->MajorFunction = FunctionCode;
pIoStackLocation->DeviceObject = pDeviceObject;
pIoStackLocation->FileObject = CacheFileObject;
pIoStackLocation->Parameters.Write.Length = IoRun[i].ByteCount;
pIoStackLocation->Parameters.Write.ByteOffset = IoRun[i].CacheOffset;
//
// Bump the count *before* we start the IO, that way if it
// completes real fast it will still not set the event
//
InterlockedIncrement(&Gather->Count);
//
// Set the completion routine.
//
IoSetCompletionRoutine( pIrp,
CompletionFunction,
Gather,
TRUE,
TRUE,
TRUE);
//
// Send it to the Cache
//
ntStatus = IoCallDriver( pDeviceObject,
pIrp);
if( !NT_SUCCESS( ntStatus))
{
break;
}
}
}
return ntStatus;
}
VOID
AFSCompleteIo( IN AFSGatherIo *Gather,
IN NTSTATUS Status)
{
if (!NT_SUCCESS(Status)) {
Gather->Status = Status;
}
if (0 == InterlockedDecrement( &Gather->Count )) {
//
// Last outstanding IO. Complete the parent and
// do whatever it takes to clean up
//
if (!NT_SUCCESS(Gather->Status))
{
Gather->MasterIrp->IoStatus.Status = Gather->Status;
Gather->MasterIrp->IoStatus.Information = 0;
}
if( Gather->CompleteMasterIrp)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSCompleteIo Completing Irp %08lX Status %08lX\n",
Gather->MasterIrp,
Gather->Status);
AFSCompleteRequest(Gather->MasterIrp, Gather->Status);
}
if (Gather->Synchronous)
{
//
// Someone was waiting for us tell them. They also own
// the data structure so we don't free it
//
KeSetEvent( &Gather->Event,
0,
FALSE);
}
else
{
AFSExFreePool( Gather);
}
}
}
static AFSExtent *ExtentFor(PLIST_ENTRY le)
{
return CONTAINING_RECORD( le, AFSExtent, Lists[AFS_EXTENTS_LIST] );
}
static AFSExtent *NextExtent(AFSExtent *Extent)
{
return ExtentFor(Extent->Lists[AFS_EXTENTS_LIST].Flink);
}
NTSTATUS
AFSProcessExtentRun( IN PVOID SystemBuffer,
IN PLARGE_INTEGER Start,
IN ULONG Length,
IN AFSExtent *From,
IN BOOLEAN WriteRequest)
{
LARGE_INTEGER liCacheOffset;
LARGE_INTEGER liFileOffset = *Start;
ULONG ulCurrLength;
ULONG ulOffset = 0;
ULONG ulCurrRun = 0;
AFSExtent *pExtent = From;
AFSExtent *pNextExtent;
PMDL *pMDL;
BOOLEAN done = FALSE;
NTSTATUS ntStatus = STATUS_SUCCESS;
__Enter
{
while( !done)
{
ASSERT( liFileOffset.QuadPart >= pExtent->FileOffset.QuadPart );
liCacheOffset = pExtent->CacheOffset;
liCacheOffset.QuadPart += (liFileOffset.QuadPart -
pExtent->FileOffset.QuadPart);
ulCurrLength = 0;
//
// While there is still data to process, loop
//
while ( (pExtent->FileOffset.QuadPart + pExtent->Size) <
(Start->QuadPart + Length) )
{
//
// Collapse the read if we can
//
pNextExtent = NextExtent( pExtent );
if (pNextExtent->CacheOffset.QuadPart !=
(pExtent->CacheOffset.QuadPart + pExtent->Size))
{
//
// This extent and the next extent are not contiguous
//
break;
}
pExtent = pNextExtent;
}
//
// So, this run goes from liCacheOffset to the end of pExtent
//
if ((pExtent->FileOffset.QuadPart + pExtent->Size) >= (Start->QuadPart + Length))
{
//
// The last extent overruns the area we care
// about, so trim it back.
//
ulCurrLength = (ULONG) (Start->QuadPart + Length -
liFileOffset.QuadPart);
//
// But we are done
//
done = TRUE;
}
else
{
//
// Length is from the LiFileOffset to the end of this
// extent.
//
ulCurrLength = (ULONG) (pExtent->FileOffset.QuadPart + pExtent->Size -
liFileOffset.QuadPart);
done = FALSE;
}
//
// Calculate the offset into the buffer
//
ulOffset = (ULONG) (liFileOffset.QuadPart - Start->QuadPart);
if( WriteRequest)
{
#ifdef AMD64
RtlCopyMemory( ((char *)AFSLibCacheBaseAddress + liCacheOffset.QuadPart),
((char *)SystemBuffer + ulOffset),
ulCurrLength);
#else
ASSERT( liCacheOffset.HighPart == 0);
RtlCopyMemory( ((char *)AFSLibCacheBaseAddress + liCacheOffset.LowPart),
((char *)SystemBuffer + ulOffset),
ulCurrLength);
#endif
}
else
{
#ifdef AMD64
RtlCopyMemory( ((char *)SystemBuffer + ulOffset),
((char *)AFSLibCacheBaseAddress + liCacheOffset.QuadPart),
ulCurrLength);
#else
ASSERT( liCacheOffset.HighPart == 0);
RtlCopyMemory( ((char *)SystemBuffer + ulOffset),
((char *)AFSLibCacheBaseAddress + liCacheOffset.LowPart),
ulCurrLength);
#endif
}
ulCurrRun ++;
if (!done)
{
ASSERT(pNextExtent != NULL && pNextExtent != pExtent);
//
// Move cursors forward
//
pExtent = pNextExtent;
liFileOffset = pExtent->FileOffset;
}
}
}
return ntStatus;
}

View File

@ -0,0 +1,311 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSLockControl.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSLockControl( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
ULONG ulRequestType = 0;
IO_STACK_LOCATION *pIrpSp = IoGetCurrentIrpStackLocation( Irp);
AFSFcb *pFcb = NULL;
AFSCcb *pCcb = NULL;
BOOLEAN bCompleteRequest = TRUE;
AFSByteRangeLockRequestCB stLockRequestCB;
AFSByteRangeLockResultCB stLockResultCB;
AFSByteRangeUnlockRequestCB stUnlockRequestCB;
AFSByteRangeUnlockResultCB stUnlockResultCB;
ULONG ulResultLen = 0;
BOOLEAN bReleaseResource = FALSE;
IO_STATUS_BLOCK stIoStatus;
__try
{
pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
pCcb = (AFSCcb *)pIrpSp->FileObject->FsContext2;
if( pFcb == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSLockControl Attempted access (%08lX) when pFcb == NULL\n",
Irp);
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
//
// Acquire the main shared for adding the lock control to the list
//
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSLockControl Acquiring Fcb lock %08lX SHARED %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSAcquireShared( &pFcb->NPFcb->Resource,
TRUE);
bReleaseResource = TRUE;
if( pFcb->Header.NodeTypeCode == AFS_IOCTL_FCB)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSLockControl Failing request against PIOCtl Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
else if( pFcb->Header.NodeTypeCode == AFS_SPECIAL_SHARE_FCB)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSLockControl Failing request against SpecialShare Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
//
// Post the request to the service for checks
//
switch( pIrpSp->MinorFunction)
{
case IRP_MN_LOCK:
{
stLockRequestCB.Count = 1;
stLockRequestCB.ProcessId = (ULONGLONG)PsGetCurrentProcessId();
stLockRequestCB.Request[ 0].LockType = AFS_BYTE_RANGE_LOCK_TYPE_EXCL;
stLockRequestCB.Request[ 0].Offset = pIrpSp->Parameters.LockControl.ByteOffset;
stLockRequestCB.Request[ 0].Length.QuadPart = pIrpSp->Parameters.LockControl.Length->QuadPart;
ulResultLen = sizeof( AFSByteRangeLockResultCB);
ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_BYTE_RANGE_LOCK,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
&pCcb->DirectoryCB->NameInformation.FileName,
&pFcb->ObjectInformation->FileId,
&stLockRequestCB,
sizeof( AFSByteRangeLockRequestCB),
&stLockResultCB,
&ulResultLen);
if( !NT_SUCCESS( ntStatus))
{
try_return( ntStatus);
}
break;
}
case IRP_MN_UNLOCK_ALL:
case IRP_MN_UNLOCK_ALL_BY_KEY:
{
RtlZeroMemory( &stUnlockRequestCB,
sizeof( AFSByteRangeUnlockRequestCB));
stUnlockRequestCB.ProcessId = (ULONGLONG)PsGetCurrentProcessId();
ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_BYTE_RANGE_UNLOCK_ALL,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
&pCcb->DirectoryCB->NameInformation.FileName,
&pFcb->ObjectInformation->FileId,
(void *)&stUnlockRequestCB,
sizeof( AFSByteRangeUnlockRequestCB),
NULL,
NULL);
if( NT_SUCCESS( ntStatus))
{
CcFlushCache( &pFcb->NPFcb->SectionObjectPointers,
NULL,
0,
&stIoStatus);
if( !NT_SUCCESS( stIoStatus.Status))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSLockControl CcFlushCache [1] failure FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX Bytes 0x%08lX\n",
pFcb->ObjectInformation->FileId.Cell,
pFcb->ObjectInformation->FileId.Volume,
pFcb->ObjectInformation->FileId.Vnode,
pFcb->ObjectInformation->FileId.Unique,
stIoStatus.Status,
stIoStatus.Information);
ntStatus = stIoStatus.Status;
}
}
//
// Even on a failure we need to notify the rtl package of the unlock
//
break;
}
case IRP_MN_UNLOCK_SINGLE:
{
stUnlockRequestCB.Count = 1;
stUnlockRequestCB.ProcessId = (ULONGLONG)PsGetCurrentProcessId();
stUnlockRequestCB.Request[ 0].LockType = AFS_BYTE_RANGE_LOCK_TYPE_EXCL;
stUnlockRequestCB.Request[ 0].Offset = pIrpSp->Parameters.LockControl.ByteOffset;
stUnlockRequestCB.Request[ 0].Length.QuadPart = pIrpSp->Parameters.LockControl.Length->QuadPart;
ulResultLen = sizeof( AFSByteRangeUnlockResultCB);
ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_BYTE_RANGE_UNLOCK,
AFS_REQUEST_FLAG_SYNCHRONOUS,
&pFcb->AuthGroup,
&pCcb->DirectoryCB->NameInformation.FileName,
&pFcb->ObjectInformation->FileId,
(void *)&stUnlockRequestCB,
sizeof( AFSByteRangeUnlockRequestCB),
(void *)&stUnlockResultCB,
&ulResultLen);
if( NT_SUCCESS( ntStatus))
{
CcFlushCache( &pFcb->NPFcb->SectionObjectPointers,
&pIrpSp->Parameters.LockControl.ByteOffset,
pIrpSp->Parameters.LockControl.Length->LowPart,
&stIoStatus);
if( !NT_SUCCESS( stIoStatus.Status))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSLockControl CcFlushCache [2] failure FID %08lX-%08lX-%08lX-%08lX Status 0x%08lX Bytes 0x%08lX\n",
pFcb->ObjectInformation->FileId.Cell,
pFcb->ObjectInformation->FileId.Volume,
pFcb->ObjectInformation->FileId.Vnode,
pFcb->ObjectInformation->FileId.Unique,
stIoStatus.Status,
stIoStatus.Information);
ntStatus = stIoStatus.Status;
}
}
break;
}
default:
break;
}
//
// Below here we won't complete the request, it is handled by the lock package
//
bCompleteRequest = FALSE;
//
// Now call the system package for actually processing the lock request
//
ntStatus = FsRtlProcessFileLock( &pFcb->Specific.File.FileLock,
Irp,
NULL);
try_exit:
if( bReleaseResource)
{
//
// And drop it
//
AFSReleaseResource( &pFcb->NPFcb->Resource);
}
if( bCompleteRequest)
{
AFSCompleteRequest( Irp,
ntStatus);
}
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()))
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSLockControl\n");
//
// Again, there is little point in failing this request but pass back some type of failure status
//
ntStatus = STATUS_UNSUCCESSFUL;
AFSCompleteRequest( Irp,
ntStatus);
}
return ntStatus;
}

View File

@ -0,0 +1,440 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSMD5Support.cpp
//
#include "AFSCommon.h"
//
// BEGIN Aladdin Enterprises MD5 SOURCES
//
/*
Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321, whose
text is available at
http://www.ietf.org/rfc/rfc1321.txt
The code is derived from the text of the RFC, including the test suite
(section A.5) but excluding the rest of Appendix A. It does not include
any code or documentation that is identified in the RFC as being
copyrighted.
The original and principal author of md5.h is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
2002-04-13 lpd Removed support for non-ANSI compilers; removed
references to Ghostscript; clarified derivation from RFC 1321;
now handles byte order either statically or dynamically.
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
added conditionalization for C++ compilation from Martin
Purschke <purschke@bnl.gov>.
1999-05-03 lpd Original version.
*/
typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
md5_word_t count[2]; /* message length in bits, lsw first */
md5_word_t abcd[4]; /* digest buffer */
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
extern "C"
{
/* Initialize the algorithm. */
void md5_init(md5_state_t *pms);
/* Append a string to the message. */
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
/* Finish the message and return the digest. */
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
} /* end extern "C" */
#define T_MASK ((md5_word_t)~0)
#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
#define T3 0x242070db
#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
#define T6 0x4787c62a
#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
#define T9 0x698098d8
#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
#define T13 0x6b901122
#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
#define T16 0x49b40821
#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
#define T19 0x265e5a51
#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
#define T22 0x02441453
#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
#define T25 0x21e1cde6
#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
#define T28 0x455a14ed
#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
#define T31 0x676f02d9
#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
#define T35 0x6d9d6122
#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
#define T38 0x4bdecfa9
#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
#define T41 0x289b7ec6
#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
#define T44 0x04881d05
#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
#define T47 0x1fa27cf8
#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
#define T50 0x432aff97
#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
#define T53 0x655b59c3
#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
#define T57 0x6fa87e4f
#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
#define T60 0x4e0811a1
#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
#define T63 0x2ad7d2bb
#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
static void
md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
c = pms->abcd[2], d = pms->abcd[3];
md5_word_t t;
/* Define storage for little-endian or both types of CPUs. */
md5_word_t xbuf[16];
const md5_word_t *X;
/*
* On little-endian machines, we can process properly aligned
* data without copying it.
*/
if (!((data - (const md5_byte_t *)0) & 3))
{
/* data are properly aligned */
X = (const md5_word_t *)data;
}
else
{
/* not aligned */
RtlCopyMemory( xbuf,
data,
64);
X = xbuf;
}
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/* Round 1. */
/* Let [abcd k s i] denote the operation
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + F(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 7, T1);
SET(d, a, b, c, 1, 12, T2);
SET(c, d, a, b, 2, 17, T3);
SET(b, c, d, a, 3, 22, T4);
SET(a, b, c, d, 4, 7, T5);
SET(d, a, b, c, 5, 12, T6);
SET(c, d, a, b, 6, 17, T7);
SET(b, c, d, a, 7, 22, T8);
SET(a, b, c, d, 8, 7, T9);
SET(d, a, b, c, 9, 12, T10);
SET(c, d, a, b, 10, 17, T11);
SET(b, c, d, a, 11, 22, T12);
SET(a, b, c, d, 12, 7, T13);
SET(d, a, b, c, 13, 12, T14);
SET(c, d, a, b, 14, 17, T15);
SET(b, c, d, a, 15, 22, T16);
#undef SET
/* Round 2. */
/* Let [abcd k s i] denote the operation
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + G(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 1, 5, T17);
SET(d, a, b, c, 6, 9, T18);
SET(c, d, a, b, 11, 14, T19);
SET(b, c, d, a, 0, 20, T20);
SET(a, b, c, d, 5, 5, T21);
SET(d, a, b, c, 10, 9, T22);
SET(c, d, a, b, 15, 14, T23);
SET(b, c, d, a, 4, 20, T24);
SET(a, b, c, d, 9, 5, T25);
SET(d, a, b, c, 14, 9, T26);
SET(c, d, a, b, 3, 14, T27);
SET(b, c, d, a, 8, 20, T28);
SET(a, b, c, d, 13, 5, T29);
SET(d, a, b, c, 2, 9, T30);
SET(c, d, a, b, 7, 14, T31);
SET(b, c, d, a, 12, 20, T32);
#undef SET
/* Round 3. */
/* Let [abcd k s t] denote the operation
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
t = a + H(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 5, 4, T33);
SET(d, a, b, c, 8, 11, T34);
SET(c, d, a, b, 11, 16, T35);
SET(b, c, d, a, 14, 23, T36);
SET(a, b, c, d, 1, 4, T37);
SET(d, a, b, c, 4, 11, T38);
SET(c, d, a, b, 7, 16, T39);
SET(b, c, d, a, 10, 23, T40);
SET(a, b, c, d, 13, 4, T41);
SET(d, a, b, c, 0, 11, T42);
SET(c, d, a, b, 3, 16, T43);
SET(b, c, d, a, 6, 23, T44);
SET(a, b, c, d, 9, 4, T45);
SET(d, a, b, c, 12, 11, T46);
SET(c, d, a, b, 15, 16, T47);
SET(b, c, d, a, 2, 23, T48);
#undef SET
/* Round 4. */
/* Let [abcd k s t] denote the operation
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + I(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 6, T49);
SET(d, a, b, c, 7, 10, T50);
SET(c, d, a, b, 14, 15, T51);
SET(b, c, d, a, 5, 21, T52);
SET(a, b, c, d, 12, 6, T53);
SET(d, a, b, c, 3, 10, T54);
SET(c, d, a, b, 10, 15, T55);
SET(b, c, d, a, 1, 21, T56);
SET(a, b, c, d, 8, 6, T57);
SET(d, a, b, c, 15, 10, T58);
SET(c, d, a, b, 6, 15, T59);
SET(b, c, d, a, 13, 21, T60);
SET(a, b, c, d, 4, 6, T61);
SET(d, a, b, c, 11, 10, T62);
SET(c, d, a, b, 2, 15, T63);
SET(b, c, d, a, 9, 21, T64);
#undef SET
/* Then perform the following additions. (That is increment each
of the four registers by the value it had before this block
was started.) */
pms->abcd[0] += a;
pms->abcd[1] += b;
pms->abcd[2] += c;
pms->abcd[3] += d;
}
void
md5_init(md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
pms->abcd[3] = 0x10325476;
}
void
md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
{
const md5_byte_t *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
if (nbytes <= 0)
return;
/* Update the message length. */
pms->count[1] += nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
pms->count[1]++;
/* Process an initial partial block. */
if (offset)
{
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
RtlCopyMemory( pms->buf + offset,
p,
copy);
if (offset + copy < 64)
return;
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
md5_process(pms, p);
/* Process a final partial block. */
if (left)
RtlCopyMemory( pms->buf, p, left);
}
void
md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
return;
}
//
// END Aladdin Enterprises MD5 SOURCES
//
void
AFSGenerateMD5( IN char *DataBuffer,
IN ULONG Length,
OUT UCHAR *MD5Digest)
{
md5_state_t stMD5State;
__Enter
{
//
// Initialize the md5 context
//
md5_init( &stMD5State);
md5_append( &stMD5State,
(const md5_byte_t *)DataBuffer,
Length);
md5_finish( &stMD5State,
(md5_byte_t *)MD5Digest);
}
return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,104 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSQuota.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSQueryQuota( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQueryQuota Entry for FO %08lX\n",
pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSQueryQuota\n");
}
return ntStatus;
}
NTSTATUS
AFSSetQuota( IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSSetQuota Entry for FO %08lX\n",
pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSetQuota\n");
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,68 @@
;;;
;;; AFS Redirector Installation file
;;;
[Version]
signature = "$Windows NT$"
Class = "AFSRedirector"
ClassGuid = {63EA509E-71F9-42ec-9C5E-1ECC95E3A1A0}
Provider = %AFS%
DriverVer = 04/20/2006,1.0.0.0
[DestinationDirs]
DefaultDestDir = 12
AFS.DriverFiles = 12
;;
;; Default install sections
;;
[DefaultInstall]
CopyFiles = AFS.DriverFiles
[SourceDisksNames]
1 = %Disk1%
[SourceDisksFiles]
AFSRedirLib.sys = 1
[DefaultInstall.Services]
AddService = %AFSServiceName%,,AFS.Service
;;
;; Default uninstall sections
;;
[DefaultUninstall]
DelFiles = AFS.DriverFiles
;
; Services Section
;
[AFS.Service]
DisplayName = %AFSServiceName%
Description = %AFSServiceDesc%
ServiceBinary = %12%\AFSRedirLib.sys
ServiceType = 2
StartType = 3
ErrorControl = 1
LoadOrderGroup = "Filesystem"
;
; Copy Files
;
[AFS.DriverFiles]
AFSRedirLib.sys
;;
;; String Section
;;
[Strings]
AFS = "OpenAFS"
AFSServiceDesc = "OpenAFS Redirector"
AFSServiceName = "AFSLibrary"
AFSRegistry = "system\currentcontrolset\services\AFSLibrary\Parameters"
Disk1 = "OpenAFS Media"

View File

@ -0,0 +1,159 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSSecurity.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSSetSecurity( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSSetSecurity Entry for FO %08lX\n",
pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSetSecurity\n");
}
return ntStatus;
}
NTSTATUS
AFSQuerySecurity( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PIO_STACK_LOCATION pIrpSp;
PMDL pUserBufferMdl = NULL;
void *pLockedUserBuffer = NULL;
ULONG ulSDLength = 0;
__try
{
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSQuerySecurity Entry for FO %08lX\n",
pIrpSp->FileObject);
if( AFSDefaultSD == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQuerySecurity No default SD allocated\n");
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
ulSDLength = RtlLengthSecurityDescriptor( AFSDefaultSD);
if( pIrpSp->Parameters.QuerySecurity.Length < ulSDLength ||
Irp->UserBuffer == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSQuerySecurity Buffer too small\n");
Irp->IoStatus.Information = (ULONG_PTR)ulSDLength;
try_return( ntStatus = STATUS_BUFFER_OVERFLOW);
}
pLockedUserBuffer = AFSLockUserBuffer( Irp->UserBuffer,
pIrpSp->Parameters.QuerySecurity.Length,
&pUserBufferMdl);
if( pLockedUserBuffer == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQuerySecurity Failed to lock user buffer\n");
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
RtlCopyMemory( pLockedUserBuffer,
AFSDefaultSD,
ulSDLength);
Irp->IoStatus.Information = (ULONG_PTR)ulSDLength;
try_exit:
if( pUserBufferMdl != NULL)
{
MmUnlockPages( pUserBufferMdl);
IoFreeMdl( pUserBufferMdl);
}
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSQuerySecurity\n");
}
AFSCompleteRequest( Irp,
ntStatus);
return ntStatus;
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSShutdown.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSShutdown( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
ntStatus = AFSShutdownFilesystem();
if( !NT_SUCCESS( ntStatus))
{
ntStatus = STATUS_SUCCESS;
}
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSShutdown\n");
}
return ntStatus;
}
NTSTATUS
AFSShutdownFilesystem()
{
NTSTATUS ntStatus = STATUS_SUCCESS;
return ntStatus;
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSSystemControl.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSSystemControl( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSSystemControl Entry for FO %08lX\n",
pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSystemControl\n");
}
return ntStatus;
}

View File

@ -0,0 +1,436 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// File: AFSVolumeInfo.cpp
//
#include "AFSCommon.h"
NTSTATUS
AFSQueryVolumeInfo( IN PDEVICE_OBJECT LibDeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
IO_STACK_LOCATION *pIrpSp;
FS_INFORMATION_CLASS FsInformationClass;
void *pBuffer = NULL;
ULONG ulLength = 0;
BOOLEAN bReleaseResource = FALSE;
AFSFcb *pFcb = NULL;
AFSVolumeCB *pVolumeCB = NULL;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
pFcb = (AFSFcb *)pIrpSp->FileObject->FsContext;
if( pFcb == NULL)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQueryVolumeInfo Failing request with NULL Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
pVolumeCB = pFcb->ObjectInformation->VolumeCB;
ASSERT( pVolumeCB->ObjectInformation.FileType == AFS_FILE_TYPE_DIRECTORY &&
pVolumeCB->ObjectInformation.FileId.Vnode == 1);
ulLength = pIrpSp->Parameters.QueryVolume.Length;
FsInformationClass = pIrpSp->Parameters.QueryVolume.FsInformationClass;
pBuffer = Irp->AssociatedIrp.SystemBuffer;
AFSAcquireExcl( pVolumeCB->VolumeLock,
TRUE);
bReleaseResource = TRUE;
//
// Don't allow requests against IOCtl nodes
//
if( pFcb->Header.NodeTypeCode == AFS_IOCTL_FCB)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQueryVolumeInfo Failing request against PIOCtl Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
else if( pFcb->Header.NodeTypeCode == AFS_SPECIAL_SHARE_FCB)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSQueryVolumeInfo Failing request against SpecialShare Fcb\n");
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
}
//
// Process the request
//
switch( FsInformationClass)
{
case FileFsVolumeInformation:
{
ntStatus = AFSQueryFsVolumeInfo( &pVolumeCB->VolumeInformation,
(PFILE_FS_VOLUME_INFORMATION)pBuffer,
&ulLength);
break;
}
case FileFsSizeInformation:
{
ntStatus = AFSQueryFsSizeInfo( &pVolumeCB->VolumeInformation,
(PFILE_FS_SIZE_INFORMATION)pBuffer,
&ulLength);
break;
}
case FileFsDeviceInformation:
{
ntStatus = AFSQueryFsDeviceInfo( &pVolumeCB->VolumeInformation,
(PFILE_FS_DEVICE_INFORMATION)pBuffer,
&ulLength);
break;
}
case FileFsAttributeInformation:
{
ntStatus = AFSQueryFsAttributeInfo( &pVolumeCB->VolumeInformation,
(PFILE_FS_ATTRIBUTE_INFORMATION)pBuffer,
&ulLength);
break;
}
case FileFsFullSizeInformation:
{
ntStatus = AFSQueryFsFullSizeInfo( &pVolumeCB->VolumeInformation,
(PFILE_FS_FULL_SIZE_INFORMATION)pBuffer,
&ulLength);
break;
}
default:
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSQueryVolumeInfo Invalid class %d\n",
FsInformationClass);
ntStatus = STATUS_INVALID_PARAMETER;
break;
}
try_exit:
//
// Setup the Irp's information field to what we actually copied in.
//
Irp->IoStatus.Information = pIrpSp->Parameters.QueryVolume.Length - ulLength;
if( bReleaseResource)
{
AFSReleaseResource( pVolumeCB->VolumeLock);
}
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSQueryVolumeInfo\n");
}
return ntStatus;
}
NTSTATUS
AFSSetVolumeInfo( IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
IO_STACK_LOCATION *pIrpSp;
pIrpSp = IoGetCurrentIrpStackLocation( Irp);
__try
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSSetVolumeInfo Entry for FO %08lX\n", pIrpSp->FileObject);
AFSCompleteRequest( Irp,
ntStatus);
}
__except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
{
AFSDbgLogMsg( 0,
0,
"EXCEPTION - AFSSetVolumeInfo\n");
}
return ntStatus;
}
NTSTATUS
AFSQueryFsVolumeInfo( IN AFSVolumeInfoCB *VolumeInfo,
IN PFILE_FS_VOLUME_INFORMATION Buffer,
IN OUT PULONG Length)
{
NTSTATUS ntStatus = STATUS_BUFFER_TOO_SMALL;
ULONG ulCopyLength;
RtlZeroMemory( Buffer,
*Length);
if( *Length >= (ULONG)sizeof( FILE_FS_VOLUME_INFORMATION))
{
if( *Length >= (ULONG)(FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel) + (LONG)VolumeInfo->VolumeLabelLength))
{
ulCopyLength = (LONG)VolumeInfo->VolumeLabelLength;
ntStatus = STATUS_SUCCESS;
}
else
{
ulCopyLength = *Length - FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel);
ntStatus = STATUS_BUFFER_OVERFLOW;
}
Buffer->VolumeCreationTime.QuadPart = VolumeInfo->VolumeCreationTime.QuadPart;
Buffer->VolumeSerialNumber = VolumeInfo->VolumeID;
Buffer->VolumeLabelLength = VolumeInfo->VolumeLabelLength;
Buffer->SupportsObjects = FALSE;
*Length -= FIELD_OFFSET( FILE_FS_VOLUME_INFORMATION, VolumeLabel);
if( ulCopyLength > 0)
{
RtlCopyMemory( Buffer->VolumeLabel,
VolumeInfo->VolumeLabel,
ulCopyLength);
*Length -= ulCopyLength;
}
}
return ntStatus;
}
NTSTATUS
AFSQueryFsSizeInfo( IN AFSVolumeInfoCB *VolumeInfo,
IN PFILE_FS_SIZE_INFORMATION Buffer,
IN OUT PULONG Length)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
RtlZeroMemory( Buffer,
*Length);
if( *Length >= sizeof( FILE_FS_SIZE_INFORMATION))
{
Buffer->TotalAllocationUnits.QuadPart = VolumeInfo->TotalAllocationUnits.QuadPart;
Buffer->AvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits.QuadPart;
Buffer->SectorsPerAllocationUnit = VolumeInfo->SectorsPerAllocationUnit;
Buffer->BytesPerSector = VolumeInfo->BytesPerSector;
*Length -= sizeof( FILE_FS_SIZE_INFORMATION);
}
else
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
return ntStatus;
}
NTSTATUS
AFSQueryFsDeviceInfo( IN AFSVolumeInfoCB *VolumeInfo,
IN PFILE_FS_DEVICE_INFORMATION Buffer,
IN OUT PULONG Length)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
RtlZeroMemory( Buffer,
*Length);
if( *Length >= (LONG)sizeof( FILE_FS_DEVICE_INFORMATION))
{
Buffer->DeviceType = FILE_DEVICE_DISK;
Buffer->Characteristics = VolumeInfo->Characteristics;
*Length -= sizeof( FILE_FS_DEVICE_INFORMATION);
}
else
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
return ntStatus;
}
NTSTATUS
AFSQueryFsAttributeInfo( IN AFSVolumeInfoCB *VolumeInfo,
IN PFILE_FS_ATTRIBUTE_INFORMATION Buffer,
IN OUT PULONG Length)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
RtlZeroMemory( Buffer,
*Length);
if( *Length >= (LONG)(sizeof( FILE_FS_ATTRIBUTE_INFORMATION)))
{
Buffer->FileSystemAttributes = (FILE_CASE_PRESERVED_NAMES |
FILE_UNICODE_ON_DISK |
FILE_SUPPORTS_REPARSE_POINTS);
Buffer->MaximumComponentNameLength = 255;
Buffer->FileSystemNameLength = 18;
*Length -= FIELD_OFFSET( FILE_FS_ATTRIBUTE_INFORMATION, FileSystemName);
if( *Length >= 18)
{
RtlCopyMemory( Buffer->FileSystemName,
L"AFSRDRFsd",
18);
*Length -= 18;
}
else
{
ntStatus = STATUS_BUFFER_OVERFLOW;
}
}
else
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
return ntStatus;
}
NTSTATUS
AFSQueryFsFullSizeInfo( IN AFSVolumeInfoCB *VolumeInfo,
IN PFILE_FS_FULL_SIZE_INFORMATION Buffer,
IN OUT PULONG Length)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
RtlZeroMemory( Buffer,
*Length);
if( *Length >= sizeof( FILE_FS_FULL_SIZE_INFORMATION))
{
Buffer->TotalAllocationUnits.QuadPart = VolumeInfo->TotalAllocationUnits.QuadPart;
Buffer->CallerAvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits.QuadPart;
Buffer->ActualAvailableAllocationUnits.QuadPart = VolumeInfo->AvailableAllocationUnits.QuadPart;
Buffer->SectorsPerAllocationUnit = VolumeInfo->SectorsPerAllocationUnit;
Buffer->BytesPerSector = VolumeInfo->BytesPerSector;
*Length -= sizeof( FILE_FS_FULL_SIZE_INFORMATION);
}
else
{
ntStatus = STATUS_BUFFER_TOO_SMALL;
}
return ntStatus;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
/*
* Copyright 2010, Secure Endpoints Inc.
* All Rights Reserved.
*
* This software has been released under the terms of the MIT License.
*/
/* Define VERSIONINFO resource */
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Redirector Kernel Library"
#define AFS_VERINFO_NAME "AFSRedirLib"
#define AFS_VERINFO_FILENAME "AFSRedirLib.sys"
#include "..\..\..\AFS_component_version_number.h"
#include "..\..\..\..\..\config\NTVersioninfo.rc"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,446 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _AFS_DEFINES_H
#define _AFS_DEFINES_H
//
// File: AFSDefines.h
//
//
// Conditional compiled code
//
//#define AFS_FLUSH_PAGES_SYNCHRONOUSLY 1 // Flush pages as we mark them dirty
//
// Debug information
//
#if DBG
//#define AFS_VALIDATE_EXTENTS 0
#define GEN_MD5 0
#else
#endif
//
// For 2K support
//
#ifndef FsRtlSetupAdvancedHeader
#define FSRTL_FLAG_ADVANCED_HEADER (0x40)
#define FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS (0x02)
#define FsRtlSetupAdvancedHeader( _advhdr, _fmutx ) \
{ \
SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER ); \
SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS ); \
InitializeListHead( &(_advhdr)->FilterContexts ); \
if ((_fmutx) != NULL) { \
(_advhdr)->FastMutex = (_fmutx); \
} \
}
#endif
typedef
NTSTATUS
(*PAFSRtlSetSaclSecurityDescriptor)( PSECURITY_DESCRIPTOR SecurityDescriptor,
BOOLEAN SaclPresent,
PACL Sacl,
BOOLEAN SaclDefaulted);
//
// Worker thread count
//
#define AFS_WORKER_COUNT 5
#define AFS_IO_WORKER_COUNT 5
//
// Worker thread states
//
#define AFS_WORKER_INITIALIZED 0x0001
#define AFS_WORKER_PROCESS_REQUESTS 0x0002
//
// Worker Thread codes
//
#define AFS_WORK_UNUSED_1 0x0001
#define AFS_WORK_FLUSH_FCB 0x0002
#define AFS_WORK_ASYNCH_READ 0x0003
#define AFS_WORK_ASYNCH_WRITE 0x0004
#define AFS_WORK_UNUSED_5 0x0005
#define AFS_WORK_ENUMERATE_GLOBAL_ROOT 0x0006
#define AFS_WORK_UNUSED_7 0x0007
#define AFS_WORK_START_IOS 0x0008
//
// Worker request flags
//
#define AFS_SYNCHRONOUS_REQUEST 0x00000001
//
// Fcb flags
//
#define AFS_FCB_FLAG_FILE_MODIFIED 0x00000001
#define AFS_FCB_FILE_CLOSED 0x00000002
#define AFS_FCB_FLAG_UPDATE_WRITE_TIME 0x00000004
#define AFS_FCB_FLAG_UPDATE_CHANGE_TIME 0x00000008
#define AFS_FCB_FLAG_UPDATE_ACCESS_TIME 0x00000010
#define AFS_FCB_FLAG_UPDATE_CREATE_TIME 0x00000020
#define AFS_FCB_FLAG_UPDATE_LAST_WRITE_TIME 0x00000040
//
// Object information flags
//
#define AFS_OBJECT_FLAGS_OBJECT_INVALID 0x00000001
#define AFS_OBJECT_FLAGS_VERIFY 0x00000002
#define AFS_OBJECT_FLAGS_NOT_EVALUATED 0x00000004
#define AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED 0x00000008
#define AFS_OBJECT_FLAGS_DELETED 0x00000010
#define AFS_OBJECT_INSERTED_HASH_TREE 0x00000020
#define AFS_OBJECT_INSERTED_VOLUME_LIST 0x00000040
#define AFS_OBJECT_HELD_IN_SERVICE 0x00000080
#define AFS_OBJECT_ROOT_VOLUME 0x00000100
#define AFS_OBJECT_FLAGS_VERIFY_DATA 0x00000200
//
// Fcb lifetime in seconds
//
#define AFS_OBJECT_LIFETIME 300000000
#define AFS_EXTENT_REQUEST_TIME 100000000
//
// How big to make the runs
//
#define AFS_MAX_STACK_IO_RUNS 5
#ifndef FlagOn
#define FlagOn(_F,_SF) ((_F) & (_SF))
#endif
#ifndef BooleanFlagOn
#define BooleanFlagOn(F,SF) ((BOOLEAN)(((F) & (SF)) != 0))
#endif
#ifndef SetFlag
#define SetFlag(_F,_SF) ((_F) |= (_SF))
#endif
#ifndef ClearFlag
#define ClearFlag(_F,_SF) ((_F) &= ~(_SF))
#endif
#define QuadAlign(Ptr) ( \
((((ULONG)(Ptr)) + 7) & 0xfffffff8) \
)
#define CRC32_POLYNOMIAL 0xEDB88320L;
//
// Define one second in terms of 100 nS units
//
#define AFS_ONE_SECOND 10000000
#define AFS_SERVER_FLUSH_DELAY 30
#define AFS_SERVER_PURGE_DELAY 60
//
// PURGE_SLEEP is the number of PURGE_DELAYS we wait before we will unilaterally
// give back extents.
//
// If the Service asks us, we will start at PURGE_SLEEP of delays and then work back
//
#define AFS_SERVER_PURGE_SLEEP 6
//
// Read ahead granularity
//
#define READ_AHEAD_GRANULARITY 0x10000 // 64KB
#define AFS_DIR_ENUM_BUFFER_LEN (16 * 1024)
//
// IS_BYTE_OFFSET_WRITE_TO_EOF
// liOffset - should be from Irp.StackLocation.Parameters.Write.ByteOffset
// this macro checks to see if the Offset Large_Integer points to the
// special constant value which denotes to start the write at EndOfFile
//
#define IS_BYTE_OFFSET_WRITE_TO_EOF(liOffset) \
(((liOffset).LowPart == FILE_WRITE_TO_END_OF_FILE) \
&& ((liOffset).HighPart == 0xFFFFFFFF))
//
// Ccb Directory enum flags
//
#define CCB_FLAG_DIR_OF_DIRS_ONLY 0x00000001
#define CCB_FLAG_FULL_DIRECTORY_QUERY 0x00000002
#define CCB_FLAG_MASK_CONTAINS_WILD_CARDS 0x00000004
#define CCB_FLAG_FREE_FULL_PATHNAME 0x00000008
#define CCB_FLAG_RETURN_RELATIVE_ENTRIES 0x00000010
#define CCB_FLAGS_DIRECTORY_QUERY_MAPPED 0x00000020
#define CCB_FLAG_MASK_PIOCTL_QUERY 0x00000040
//
// DirEntry flags
//
#define AFS_DIR_RELEASE_NAME_BUFFER 0x00000001
#define AFS_DIR_ENTRY_CASE_INSENSTIVE_LIST_HEAD 0x00000004
#define AFS_DIR_ENTRY_NOT_IN_PARENT_TREE 0x00000008
#define AFS_DIR_ENTRY_INSERTED_ENUM_LIST 0x00000010
#define AFS_DIR_ENTRY_FAKE 0x00000020
#define AFS_DIR_RELEASE_TARGET_NAME_BUFFER 0x00000040
#define AFS_DIR_ENTRY_VALID 0x00000080
#define AFS_DIR_ENTRY_PENDING_DELETE 0x00000100
#define AFS_DIR_ENTRY_DELETED 0x00000200
#define AFS_DIR_ENTRY_SERVER_SERVICE 0x00000400
#define AFS_DIR_ENTRY_WORKSTATION_SERVICE 0x00000800
#define AFS_DIR_ENTRY_IPC 0x00001000
//
// Network provider errors
//
#define WN_SUCCESS 0L
#define WN_ALREADY_CONNECTED 85L
#define WN_OUT_OF_MEMORY 8L
#define WN_NOT_CONNECTED 2250L
#define WN_BAD_NETNAME 67L
#define RESOURCE_CONNECTED 0x00000001
#define RESOURCE_GLOBALNET 0x00000002
#define RESOURCE_REMEMBERED 0x00000003
#define RESOURCE_RECENT 0x00000004
#define RESOURCE_CONTEXT 0x00000005
#define RESOURCETYPE_ANY 0x00000000
#define RESOURCETYPE_DISK 0x00000001
#define RESOURCETYPE_PRINT 0x00000002
#define RESOURCETYPE_RESERVED 0x00000008
#define RESOURCETYPE_UNKNOWN 0xFFFFFFFF
#define RESOURCEUSAGE_CONNECTABLE 0x00000001
#define RESOURCEUSAGE_CONTAINER 0x00000002
#define RESOURCEUSAGE_NOLOCALDEVICE 0x00000004
#define RESOURCEUSAGE_SIBLING 0x00000008
#define RESOURCEUSAGE_ATTACHED 0x00000010
#define RESOURCEUSAGE_ALL (RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER | RESOURCEUSAGE_ATTACHED)
#define RESOURCEUSAGE_RESERVED 0x80000000
#define RESOURCEDISPLAYTYPE_GENERIC 0x00000000
#define RESOURCEDISPLAYTYPE_DOMAIN 0x00000001
#define RESOURCEDISPLAYTYPE_SERVER 0x00000002
#define RESOURCEDISPLAYTYPE_SHARE 0x00000003
#define RESOURCEDISPLAYTYPE_FILE 0x00000004
#define RESOURCEDISPLAYTYPE_GROUP 0x00000005
#define RESOURCEDISPLAYTYPE_NETWORK 0x00000006
#define RESOURCEDISPLAYTYPE_ROOT 0x00000007
#define RESOURCEDISPLAYTYPE_SHAREADMIN 0x00000008
#define RESOURCEDISPLAYTYPE_DIRECTORY 0x00000009
#define RESOURCEDISPLAYTYPE_TREE 0x0000000A
#define RESOURCEDISPLAYTYPE_NDSCONTAINER 0x0000000B
//
// Method for determining the different control device open requests
//
#define AFS_CONTROL_INSTANCE 0x00000001
#define AFS_REDIRECTOR_INSTANCE 0x00000002
//
// Extent flags
//
#define AFS_EXTENT_DIRTY 0x00000001
//
// Extent skip list sizes
//
#define AFS_NUM_EXTENT_LISTS 3
//
// Extents skip lists
//
// We use constant sizes.
//
#define AFS_EXTENT_SIZE (4*1024)
#define AFS_EXTENTS_LIST 0
//
// A max of 64 extents in ther first skip list
#define AFS_EXTENT_SKIP1_BITS 6
//
// Then 128 bits in the second skip list
#define AFS_EXTENT_SKIP2_BITS 7
//
// This means that the top list skips in steps of 2^25 (=12+6+7) which
// is 32 Mb. It is to be expected that files which are massively
// larger that this will not be fully mapped.
//
#define AFS_EXTENT_SKIP1_SIZE (AFS_EXTENT_SIZE << AFS_EXTENT_SKIP1_BITS)
#define AFS_EXTENT_SKIP2_SIZE (AFS_EXTENT_SKIP1_SIZE << AFS_EXTENT_SKIP2_BITS)
#define AFS_EXTENTS_MASKS { (AFS_EXTENT_SIZE-1), \
(AFS_EXTENT_SKIP1_SIZE-1), \
(AFS_EXTENT_SKIP2_SIZE-1) }
//
// Maximum count to release at a time
//
#define AFS_MAXIMUM_EXTENT_RELEASE_COUNT 100
// {41966169-3FD7-4392-AFE4-E6A9D0A92C72} - generated using guidgen.exe
DEFINE_GUID (GUID_SD_AFS_REDIRECTOR_CONTROL_OBJECT,
0x41966169, 0x3fd7, 0x4392, 0xaf, 0xe4, 0xe6, 0xa9, 0xd0, 0xa9, 0x2c, 0x72);
//
// Debug log length
//
#define AFS_DBG_LOG_LENGTH 256
//
// Debug log flags
//
#define AFS_DBG_LOG_WRAPPED 0x00000001
//
// Connection flags
//
#define AFS_CONNECTION_FLAG_GLOBAL_SHARE 0x00000001
//
// Process CB flags
//
#define AFS_PROCESS_FLAG_IS_64BIT 0x00000001
//
// Maximum number of special share names
//
#define AFS_SPECIAL_SHARE_NAME_COUNT_MAX 10
//
// Device flags
//
#define AFS_DEVICE_FLAG_HIDE_DOT_NAMES 0x00000001
#define AFS_DEVICE_FLAG_REDIRECTOR_SHUTDOWN 0x00000002
//
// Name Array flags
//
#define AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT 0x00000001
#define AFS_NAME_ARRAY_FLAG_REDIRECTION_ELEMENT 0x00000002
//
// Maximum recursion depth
//
#define AFS_MAX_RECURSION_COUNT 20
//
// LocateNameEntry flags
//
#define AFS_LOCATE_FLAGS_SUBSTITUTE_NAME 0x00000001
#define AFS_LOCATE_FLAGS_NO_MP_TARGET_EVAL 0x00000002
#define AFS_LOCATE_FLAGS_NO_SL_TARGET_EVAL 0x00000004
#define AFS_LOCATE_FLAGS_NO_DFS_LINK_EVAL 0x00000008
//
// Parse flags
//
#define AFS_PARSE_FLAG_FREE_FILE_BUFFER 0x00000001
#define AFS_PARSE_FLAG_ROOT_ACCESS 0x00000002
//
// Reparse tag information
//
//
// Tag allocated to OpenAFS for DFS by Microsoft
// GUID: EF21A155-5C92-4470-AB3B-370403D96369
//
#ifndef IO_REPARSE_TAG_OPENAFS_DFS
#define IO_REPARSE_TAG_OPENAFS_DFS 0x00000037L
#endif
// {EF21A155-5C92-4470-AB3B-370403D96369}
DEFINE_GUID (GUID_AFS_REPARSE_GUID,
0xEF21A155, 0x5C92, 0x4470, 0xAB, 0x3B, 0x37, 0x04, 0x03, 0xD9, 0x63, 0x69);
//
// Enumeration constants
//
#define AFS_DIR_ENTRY_INITIAL_DIR_INDEX (ULONG)-3
#define AFS_DIR_ENTRY_INITIAL_ROOT_INDEX (ULONG)-1
#define AFS_DIR_ENTRY_PIOCTL_INDEX (ULONG)-3
#define AFS_DIR_ENTRY_DOT_INDEX (ULONG)-2
#define AFS_DIR_ENTRY_DOT_DOT_INDEX (ULONG)-1
//
// Library state flags
//
#define AFS_REDIR_LIB_FLAGS_NONPERSISTENT_CACHE 0x00000001
#endif /* _AFS_DEFINES_H */

View File

@ -0,0 +1,104 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _AFS_EXTERN_H
#define _AFS_EXTERN_H
//
// File: AFSExtern.h
//
//
extern "C" {
extern PDRIVER_OBJECT AFSLibraryDriverObject;
extern PDEVICE_OBJECT AFSLibraryDeviceObject;
extern PDEVICE_OBJECT AFSControlDeviceObject;
extern PDEVICE_OBJECT AFSRDRDeviceObject;
extern FAST_IO_DISPATCH AFSFastIoDispatch;
extern unsigned long AFSCRCTable[];
extern UNICODE_STRING AFSRegistryPath;
extern ULONG AFSDebugFlags;
extern CACHE_MANAGER_CALLBACKS *AFSLibCacheManagerCallbacks;
extern HANDLE AFSSysProcess;
extern UNICODE_STRING AFSServerName;
extern AFSVolumeCB *AFSGlobalRoot;
extern AFSVolumeCB *AFSRedirectorRoot;
extern UNICODE_STRING AFSPIOCtlName;
extern UNICODE_STRING AFSGlobalRootName;
extern AFSDirectoryCB *AFSSpecialShareNames;
extern AFSDirectoryCB *AFSGlobalDotDirEntry;
extern AFSDirectoryCB *AFSGlobalDotDotDirEntry;
extern PAFSProcessRequest AFSProcessRequest;
extern PAFSDbgLogMsg AFSDbgLogMsg;
extern PAFSAddConnectionEx AFSAddConnectionEx;
extern PAFSExAllocatePoolWithTag AFSExAllocatePoolWithTag;
extern PAFSExFreePool AFSExFreePool;
extern PAFSRetrieveAuthGroup AFSRetrieveAuthGroupFnc;
extern ULONG AFSLibControlFlags;
extern void *AFSLibCacheBaseAddress;
extern LARGE_INTEGER AFSLibCacheLength;
extern PAFSRtlSetSaclSecurityDescriptor AFSRtlSetSaclSecurityDescriptor;
extern SECURITY_DESCRIPTOR *AFSDefaultSD;
}
#endif /* _AFS_EXTERN_H */

View File

@ -0,0 +1,649 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
* Copyright (c) 2009, 2010, 2011 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice,
* this list of conditions and the following disclaimer in the
* documentation
* and/or other materials provided with the distribution.
* - Neither the names of Kernel Drivers, LLC and Your File System, Inc.
* nor the names of their contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission from Kernel Drivers, LLC and Your File System, Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _AFS_STRUCTS_H
#define _AFS_STRUCTS_H
//
// File: AFSStructs.h
//
typedef struct _AFS_DIR_HDR
{
struct _AFS_DIRECTORY_CB *CaseSensitiveTreeHead;
struct _AFS_DIRECTORY_CB *CaseInsensitiveTreeHead;
ERESOURCE *TreeLock;
LONG ContentIndex;
} AFSDirHdr;
//
// Worker pool header
//
typedef struct _AFS_WORKER_QUEUE_HDR
{
struct _AFS_WORKER_QUEUE_HDR *fLink;
KEVENT WorkerThreadReady;
void *WorkerThreadObject;
ULONG State;
} AFSWorkQueueContext, *PAFSWorkQueueContext;
//
// These are the context control blocks for the open instance
//
typedef struct _AFS_CCB
{
USHORT Size;
USHORT Type;
ULONG Flags;
//
// Directory enumeration informaiton
//
UNICODE_STRING MaskName;
struct _AFS_DIRECTORY_SS_HDR *DirectorySnapshot;
ULONG CurrentDirIndex;
//
// PIOCtl and share interface request id
//
ULONG RequestID;
//
// Full path of how the instance was opened
//
UNICODE_STRING FullFileName;
//
// Name array for this open
//
struct _AFS_NAME_ARRAY_HEADER *NameArray;
//
// Pointer to this entries meta data
//
struct _AFS_DIRECTORY_CB *DirectoryCB;
//
// Notification name
//
UNICODE_STRING NotifyMask;
//
// File unwind info
//
struct
{
ULONG FileAttributes;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
} FileUnwindInfo;
} AFSCcb;
//
// Object information block
//
typedef struct _AFS_NONPAGED_OBJECT_INFO_CB
{
ERESOURCE DirectoryNodeHdrLock;
} AFSNonPagedObjectInfoCB;
typedef struct _AFS_OBJECT_INFORMATION_CB
{
AFSBTreeEntry TreeEntry;
AFSListEntry ListEntry;
ULONG Flags;
LONG ObjectReferenceCount;
AFSNonPagedObjectInfoCB *NonPagedInfo;
//
// The VolumeCB where this entry resides
//
struct _AFS_VOLUME_CB *VolumeCB;
//
// Parent object information
//
struct _AFS_OBJECT_INFORMATION_CB *ParentObjectInformation;
//
// Pointer to the current Fcb, if available
//
AFSFcb *Fcb;
//
// Last access time.
//
LARGE_INTEGER LastAccessCount;
//
// Per file metadata information
//
AFSFileID FileId;
AFSFileID TargetFileId;
LARGE_INTEGER Expiration; /* FILETIME */
LARGE_INTEGER DataVersion;
ULONG FileType; /* File, Dir, MountPoint, Symlink */
LARGE_INTEGER CreationTime; /* FILETIME */
LARGE_INTEGER LastAccessTime; /* FILETIME */
LARGE_INTEGER LastWriteTime; /* FILETIME */
LARGE_INTEGER ChangeTime; /* FILETIME */
ULONG FileAttributes; /* NTFS FILE_ATTRIBUTE_xxxx see below */
LARGE_INTEGER EndOfFile;
LARGE_INTEGER AllocationSize;
ULONG EaSize;
ULONG Links;
//
// Directory and file specific information
//
union
{
struct
{
//
// The directory search and listing information for the node
//
AFSDirHdr DirectoryNodeHdr;
struct _AFS_DIRECTORY_CB *DirectoryNodeListHead;
struct _AFS_DIRECTORY_CB *DirectoryNodeListTail;
LONG DirectoryNodeCount;
struct _AFS_DIRECTORY_CB *ShortNameTree;
//
// PIOCtl directory cb entry
//
struct _AFS_DIRECTORY_CB *PIOCtlDirectoryCB;
//
// Open handle and reference count for this object
//
LONG ChildOpenHandleCount;
LONG ChildOpenReferenceCount;
//
// Index for the PIOCtl and share open count
//
LONG OpenRequestIndex;
} Directory;
struct
{
ULONG Reserved;
} File;
} Specific;
} AFSObjectInfoCB;
//
// Volume control block structure
//
typedef struct _AFS_NON_PAGED_VOLUME_CB
{
ERESOURCE VolumeLock;
ERESOURCE ObjectInfoTreeLock;
ERESOURCE DirectoryNodeHdrLock;
}AFSNonPagedVolumeCB;
typedef struct _AFS_VOLUME_CB
{
//
// Our tree entry.
//
AFSBTreeEntry TreeEntry;
//
// This is the linked list of nodes processed asynchronously by the respective worker thread
//
AFSListEntry ListEntry;
ULONG Flags;
AFSNonPagedVolumeCB *NonPagedVcb;
ERESOURCE *VolumeLock;
//
// Reference count on the object
//
LONG VolumeReferenceCount;
//
// Object information tree
//
AFSTreeHdr ObjectInfoTree;
AFSObjectInfoCB *ObjectInfoListHead;
AFSObjectInfoCB *ObjectInfoListTail;
//
// Object information for the volume
//
AFSObjectInfoCB ObjectInformation;
//
// Root directory cb for this volume
//
struct _AFS_DIRECTORY_CB *DirectoryCB;
//
// The Fcb for this volume
//
AFSFcb *RootFcb;
//
// Volume worker thread
//
AFSWorkQueueContext VolumeWorkerContext;
//
// Volume information
//
AFSVolumeInfoCB VolumeInformation;
} AFSVolumeCB;
typedef struct _AFS_NAME_INFORMATION_CB
{
CCHAR ShortNameLength;
WCHAR ShortName[12];
UNICODE_STRING FileName;
UNICODE_STRING TargetName;
} AFSNameInfoCB;
typedef struct _AFS_NON_PAGED_DIRECTORY_CB
{
ERESOURCE Lock;
} AFSNonPagedDirectoryCB;
typedef struct _AFS_DIRECTORY_CB
{
AFSBTreeEntry CaseSensitiveTreeEntry; // For entries in the NameEntry tree, the
// Index is a CRC on the name. For Volume,
// MP and SL nodes, the Index is the Cell, Volume
// For all others it is the vnode, uniqueid
AFSBTreeEntry CaseInsensitiveTreeEntry;
AFSListEntry CaseInsensitiveList;
ULONG Flags;
//
// Current open reference count on the directory entry. This count is used
// for tear down
//
LONG OpenReferenceCount;
//
// File index used in directory enumerations
//
ULONG FileIndex;
//
// Name information for this entry
//
AFSNameInfoCB NameInformation;
//
// List entry for the directory enumeration list in a parent node
//
AFSListEntry ListEntry;
//
// Back pointer to the ObjectInfo block for this entry
//
AFSObjectInfoCB *ObjectInformation;
//
// Non paged pointer
//
AFSNonPagedDirectoryCB *NonPaged;
//
// Type specific information
//
union
{
struct
{
AFSBTreeEntry ShortNameTreeEntry;
} Data;
struct
{
ULONG Reserved;
} MountPoint;
struct
{
ULONG Reserved;
} SymLink;
} Type;
} AFSDirectoryCB;
// Read and writes can fan out and so they are syncrhonized via one of
// these structures
//
typedef struct _AFS_GATHER_READWRITE
{
KEVENT Event;
LONG Count;
NTSTATUS Status;
PIRP MasterIrp;
BOOLEAN Synchronous;
BOOLEAN CompleteMasterIrp;
AFSFcb *Fcb;
} AFSGatherIo;
typedef struct _AFS_IO_RUNS {
LARGE_INTEGER CacheOffset;
PIRP ChildIrp;
ULONG ByteCount;
} AFSIoRun;
//
// Name array element and header
//
typedef struct _AFS_NAME_ARRAY_ELEMENT
{
UNICODE_STRING Component;
AFSFileID FileId;
AFSDirectoryCB *DirectoryCB;
ULONG Flags;
} AFSNameArrayCB;
typedef struct _AFS_NAME_ARRAY_HEADER
{
AFSNameArrayCB *CurrentEntry;
LONG Count;
LONG LinkCount;
ULONG Flags;
ULONG MaxElementCount;
AFSNameArrayCB ElementArray[ 1];
} AFSNameArrayHdr;
typedef struct _AFS_FILE_INFO_CB
{
ULONG FileAttributes;
LARGE_INTEGER AllocationSize;
LARGE_INTEGER EndOfFile;
LARGE_INTEGER CreationTime;
LARGE_INTEGER LastAccessTime;
LARGE_INTEGER LastWriteTime;
LARGE_INTEGER ChangeTime;
} AFSFileInfoCB;
//
// Work item
//
typedef struct _AFS_WORK_ITEM
{
struct _AFS_WORK_ITEM *next;
ULONG RequestType;
ULONG RequestFlags;
NTSTATUS Status;
KEVENT Event;
ULONG Size;
ULONGLONG ProcessID;
union
{
struct
{
PIRP Irp;
} ReleaseExtents;
struct
{
AFSFcb *Fcb;
AFSFcb **TargetFcb;
AFSFileInfoCB FileInfo;
struct _AFS_NAME_ARRAY_HEADER *NameArray;
} Fcb;
struct
{
PIRP Irp;
PDEVICE_OBJECT Device;
HANDLE CallingProcess;
} AsynchIo;
struct
{
UCHAR FunctionCode;
ULONG RequestFlags;
struct _AFS_IO_RUNS *IoRuns;
ULONG RunCount;
struct _AFS_GATHER_READWRITE *GatherIo;
FILE_OBJECT *CacheFileObject;
} CacheAccess;
struct
{
char Context[ 1];
} Other;
} Specific;
} AFSWorkItem, *PAFSWorkItem;
//
// Directory snapshot structures
//
typedef struct _AFS_DIRECTORY_SS_ENTRY
{
ULONG NameHash;
} AFSSnapshotEntry;
typedef struct _AFS_DIRECTORY_SS_HDR
{
ULONG EntryCount;
AFSSnapshotEntry *TopEntry;
} AFSSnapshotHdr;
#endif /* _AFS_STRUCTS_H */

View File

@ -0,0 +1,6 @@
#
# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
# file to this component. This file merely indirects to the real make file
# that is shared by all the components of NT OS/2
#
!INCLUDE $(NTMAKEENV)\makefile.def

View File

@ -0,0 +1,43 @@
TARGETNAME=AFSRedirLib
TARGETPATH=..\..\Build
TARGETTYPE=DRIVER
DRIVERTYPE=FS
INCLUDES=Include;..\..\Common;
TARGETLIBS=$(DDK_LIB_PATH)\ntstrsafe.lib \
$(DDK_LIB_PATH)\wdmsec.lib
SOURCES= AFSInit.cpp \
AFSBTreeSupport.cpp \
AFSCleanup.cpp \
AFSClose.cpp \
AFSCommSupport.cpp \
AFSCreate.cpp \
AFSData.cpp \
AFSDevControl.cpp \
AFSDirControl.cpp \
AFSEa.cpp \
AFSExtentsSupport.cpp \
AFSFcbSupport.cpp \
AFSFileInfo.cpp \
AFSFlushBuffers.cpp \
AFSFSControl.cpp \
AFSGeneric.cpp \
AFSInternalDevControl.cpp \
AFSIoSupport.cpp \
AFSLockControl.cpp \
AFSMD5Support.cpp \
AFSNameSupport.cpp \
AFSNetworkProviderSupport.cpp \
AFSQuota.cpp \
AFSRead.cpp \
AFSSecurity.cpp \
AFSShutdown.cpp \
AFSSystemControl.cpp \
AFSVolumeInfo.cpp \
AFSWorker.cpp \
AFSWrite.cpp \
FileSystem.rc