/*
- * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Kernel Drivers, LLC.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* - 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.
+ * 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
Context = ExceptPtrs->ContextRecord;
- AFSDbgLogMsg( 0,
+ AFSDbgTrace(( 0,
0,
"AFSExceptionFilter (Framework) - EXR %p CXR %p Function %s Code %08lX Address %p Routine %p\n",
ExceptRec,
FunctionString,
ExceptRec->ExceptionCode,
ExceptRec->ExceptionAddress,
- (void *)AFSExceptionFilter);
+ (void *)AFSExceptionFilter));
DbgPrint("**** Exception Caught in AFS Redirector ****\n");
if( Resource != &AFSDbgLogLock)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSReleaseResource Releasing lock %08lX Thread %08lX\n",
+ "AFSReleaseResource Releasing lock %p Thread %08lX\n",
Resource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
}
ExReleaseResourceLite( Resource);
AFSConvertToShared( IN PERESOURCE Resource)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSConvertToShared Converting lock %08lX Thread %08lX\n",
+ "AFSConvertToShared Converting lock %p Thread %08lX\n",
Resource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
ExConvertExclusiveToSharedLite( Resource);
// Let's limit things a bit ...
//
- if( AFSDbgBufferLength > 10240)
+ if( AFSDbgBufferLength > AFS_DBG_LOG_MAXLENGTH)
{
- AFSDbgBufferLength = 1024;
+ AFSDbgBufferLength = AFS_DBG_LOG_MAXLENGTH;
}
}
else
pDeviceExt->Specific.Control.AuthGroupTree.TreeLock = &pDeviceExt->Specific.Control.AuthGroupTreeLock;
pDeviceExt->Specific.Control.AuthGroupTree.TreeHead = NULL;
+
+ //
+ // Increase the StackSize to support the extra stack frame required
+ // for use of IoCompletion routines.
+ //
+
+ AFSDeviceObject->StackSize++;
+
}
return ntStatus;
// Process the request
//
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetSysNameInformation Acquiring SysName lock %08lX EXCL %08lX\n",
+ "AFSSetSysNameInformation Acquiring SysName lock %p EXCL %08lX\n",
pSysNameLock,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
AFSAcquireExcl( pSysNameLock,
TRUE);
// Set the completion routine.
//
+ AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "Setting AFSIrpComplete as IoCompletion Routine Irp %p\n",
+ pIrp));
+
IoSetCompletionRoutine( pIrp,
AFSIrpComplete,
&kEvent,
if ( bTimeout || pControlDevExt == NULL)
{
- AFSDbgLogMsg( 0,
+ AFSDbgTrace(( 0,
0,
"AFSExAllocatePoolWithTag failure Type %08lX Size %08lX Tag %08lX %08lX\n",
PoolType,
NumberOfBytes,
Tag,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
switch ( Tag ) {
__Enter
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"%s Shutting down redirector Extent count %08lX Request count %08lX\n",
__FUNCTION__,
pControlDevExt->Specific.Control.ExtentCount,
- pControlDevExt->Specific.Control.OutstandingServiceRequestCount);
+ pControlDevExt->Specific.Control.OutstandingServiceRequestCount));
//
// Set the shutdown flag so the worker is more agressive in tearing down extents
if( ntStatus == STATUS_TIMEOUT)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSShutdownRedirector Failed to complete all service requests Remaining count %08lX\n",
- pControlDevExt->Specific.Control.OutstandingServiceRequestCount);
+ pControlDevExt->Specific.Control.OutstandingServiceRequestCount));
try_return( ntStatus = STATUS_UNSUCCESSFUL);
}
if( ntStatus == STATUS_TIMEOUT)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_WARNING,
"AFSShutdownRedirector Failed to purge all extents Remaining count %08lX\n",
- pControlDevExt->Specific.Control.ExtentCount);
+ pControlDevExt->Specific.Control.ExtentCount));
try_return( ntStatus = STATUS_UNSUCCESSFUL);
}
try_exit:
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
"%s Completed shut down of redirector Extent count %08lX Request count %08lX Status %08lX\n",
__FUNCTION__,
pControlDevExt->Specific.Control.ExtentCount,
pControlDevExt->Specific.Control.OutstandingServiceRequestCount,
- ntStatus);
+ ntStatus));
}
return ntStatus;
// Try and acquire the Fcb resource
//
- AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForLazyWrite Acquiring Fcb %08lX\n",
- Fcb);
+ "AFSAcquireFcbForLazyWrite Acquiring Fcb %p\n",
+ Fcb));
//
// Try and grab the paging
//
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForLazyWrite Attempt to acquire Fcb PagingIo lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForLazyWrite Attempt to acquire Fcb PagingIo lock %p SHARED %08lX\n",
&pFcb->NPFcb->PagingResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
if( AFSAcquireShared( &pFcb->NPFcb->PagingResource,
Wait))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForLazyWrite Acquired Fcb PagingIo lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForLazyWrite Acquired Fcb PagingIo lock %p SHARED %08lX\n",
&pFcb->NPFcb->PagingResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
bReleasePaging = TRUE;
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForLazyWrite Attempt to acquire Fcb SectionObject lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForLazyWrite Attempt to acquire Fcb SectionObject lock %p SHARED %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
if( AFSAcquireShared( &pFcb->NPFcb->SectionObjectResource,
Wait))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForLazyWrite Acquired Fcb SectionObject lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForLazyWrite Acquired Fcb SectionObject lock %p SHARED %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
bReleaseSectionObject = TRUE;
AFSFcb *pFcb = (AFSFcb *)Fcb;
- AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSReleaseFcbFromLazyWrite Releasing Fcb %08lX\n",
- Fcb);
+ "AFSReleaseFcbFromLazyWrite Releasing Fcb %p\n",
+ Fcb));
IoSetTopLevelIrp( NULL);
BOOLEAN bStatus = FALSE;
AFSFcb *pFcb = (AFSFcb *)Fcb;
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForReadAhead Attempt to acquire Fcb SectionObject lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForReadAhead Attempt to acquire Fcb SectionObject lock %p SHARED %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
if( AFSAcquireShared( &pFcb->NPFcb->SectionObjectResource,
Wait))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSAcquireFcbForReadAhead Acquired Fcb SectionObject lock %08lX SHARED %08lX\n",
+ "AFSAcquireFcbForReadAhead Acquired Fcb SectionObject lock %p SHARED %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
- PsGetCurrentThread());
+ PsGetCurrentThread()));
bStatus = TRUE;
if( hToken == NULL)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetCallerSID Failed to retrieve impersonation or primary token\n");
+ "AFSGetCallerSID Failed to retrieve impersonation or primary token\n"));
try_return( ntStatus);
}
if( !NT_SUCCESS( ntStatus))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetCallerSID Failed to retrieve information Status %08lX\n", ntStatus);
+ "AFSGetCallerSID Failed to retrieve information Status %08lX\n",
+ ntStatus));
try_return( ntStatus);
}
if( !NT_SUCCESS( ntStatus))
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetCallerSID Failed to convert sid to string Status %08lX\n", ntStatus);
+ "AFSGetCallerSID Failed to convert sid to string Status %08lX\n",
+ ntStatus));
try_return( ntStatus);
}
*SIDString = uniSIDString;
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSGetCallerSID Successfully retrieved SID %wZ\n",
- SIDString);
+ SIDString));
if ( bPrimaryToken == FALSE &&
pbImpersonation)
if( hToken == NULL)
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSGetSessionId Failed to retrieve impersonation or primary token\n");
+ "AFSGetSessionId Failed to retrieve impersonation or primary token\n"));
try_return( ntStatus);
}
{
ulSessionId = (ULONG)-1;
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSGetSessionId Failed to retrieve session id Status %08lX\n",
- ntStatus);
+ ntStatus));
try_return( ntStatus);
}
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
+ AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_AUTHGROUP_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE_2,
"AFSGetSessionId found %08lX\n",
- ulSessionId);
+ ulSessionId));
if ( bPrimaryToken == FALSE &&
pbImpersonation)
return ntStatus;
}
+NTSTATUS
+AFSSetReparsePointPolicy( IN AFSSetReparsePointPolicyCB *PolicyCB)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ AFSDeviceExt* pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
+ ULONG ulPolicy = 0;
+
+ __Enter
+ {
+
+ ulPolicy = (PolicyCB->Policy & AFS_REPARSE_POINT_VALID_POLICY_FLAGS);
+
+ if ( PolicyCB->Scope == AFS_REPARSE_POINT_POLICY_GLOBAL)
+ {
+
+ pDeviceExt->Specific.RDR.ReparsePointPolicy = ulPolicy;
+ }
+ else if ( PolicyCB->Scope == AFS_REPARSE_POINT_POLICY_AUTHGROUP)
+ {
+
+ ntStatus = STATUS_NOT_SUPPORTED;
+ }
+ }
+
+ return ntStatus;
+}
+
+
+NTSTATUS
+AFSGetReparsePointPolicy( OUT AFSGetReparsePointPolicyCB *PolicyCB)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ AFSDeviceExt* pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
+
+ __Enter
+ {
+
+ PolicyCB->GlobalPolicy = pDeviceExt->Specific.RDR.ReparsePointPolicy;
+
+ //
+ // When per-AuthGroup or per-Process policies are permitted
+ // this function will need to query the policies when determining
+ // the active policy.
+ //
+
+ {
+ PolicyCB->ActivePolicy = PolicyCB->GlobalPolicy;
+ }
+ }
+
+ return ntStatus;
+}