ULONG ulRequestFlags = AFS_REQUEST_FLAG_SYNCHRONOUS;
ULONG ulCRC = 0;
UNICODE_STRING uniGUID;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
__Enter
{
// The ObjectReferenceCount will be freed by AFSPerformObjectInvalidate
//
- lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = AFSObjectInfoIncrement( pObjectInfo,
+ AFS_OBJECT_REFERENCE_INVALIDATION);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSEnumerateDirectory calling AFSPerformObjectInvalidate Increment count on object %p Cnt %d\n",
+ pObjectInfo,
+ lCount);
AFSPerformObjectInvalidate( pObjectInfo,
AFS_INVALIDATE_DATA_VERSION);
// Need to tear down this entry and rebuild it below
//
- if( pDirNode->OpenReferenceCount == 0)
+ if( pDirNode->DirOpenReferenceCount <= 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
// Init the short name if we have one
//
- if( pCurrentDirEntry->ShortNameLength > 0)
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pCurrentDirEntry->ShortNameLength > 0)
{
UNICODE_STRING uniShortName;
(12 * sizeof( WCHAR)));
}
}
+ else
+ {
+
+ //
+ // No short name or short names are disabled
+ //
+
+ pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
+ }
//
// Insert the node into the name tree
if( pBuffer != NULL)
{
- AFSExFreePool( pBuffer);
+ AFSExFreePoolWithTag( pBuffer, AFS_DIR_BUFFER_TAG);
}
//
ULONGLONG ullIndex = 0;
UNICODE_STRING uniGUID;
LONG lCount;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
__Enter
{
// lock hierarchy.
//
- lCount = InterlockedIncrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = AFSObjectInfoIncrement( pObjectInfo,
+ AFS_OBJECT_REFERENCE_INVALIDATION);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSVerifyDirectoryContent calling AFSQueueInvalidateObject Increment count on object %p Cnt %d\n",
+ pObjectInfo,
+ lCount);
if ( !NT_SUCCESS( AFSQueueInvalidateObject( pObjectInfo,
AFS_INVALIDATE_DATA_VERSION)))
{
- lCount = InterlockedDecrement( &pObjectInfo->ObjectReferenceCount);
+ lCount = AFSObjectInfoDecrement( pObjectInfo,
+ AFS_OBJECT_REFERENCE_INVALIDATION);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSVerifyDirectoryContent AFSQueueInvalidateObject failed Decrement count on object %p Cnt %d\n",
+ pObjectInfo,
+ lCount);
}
}
else
// Need to tear down this entry and rebuild it below
//
- if( pDirNode->OpenReferenceCount == 0)
+ if( pDirNode->DirOpenReferenceCount <= 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
// Init the short name if we have one
//
- if( pCurrentDirEntry->ShortNameLength > 0)
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pCurrentDirEntry->ShortNameLength > 0)
{
UNICODE_STRING uniShortName;
else
{
- AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSVerifyDirectoryContent NO short name for DE %p for %wZ FID %08lX-%08lX-%08lX-%08lX\n",
- pDirNode,
- &pDirNode->NameInformation.FileName,
- pCurrentDirEntry->FileId.Cell,
- pCurrentDirEntry->FileId.Volume,
- pCurrentDirEntry->FileId.Vnode,
- pCurrentDirEntry->FileId.Unique);
+ //
+ // No short name or short names have been disabled
+ //
+
+ pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
}
//
if( pBuffer != NULL)
{
- AFSExFreePool( pBuffer);
+ AFSExFreePoolWithTag( pBuffer, AFS_DIR_BUFFER_TAG);
}
}
UNICODE_STRING uniTargetName;
AFSDirectoryCB *pDirNode = NULL;
ULONG ulCRC = 0;
+ LONG lCount;
LARGE_INTEGER liOldDataVersion;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ BOOLEAN bReleaseParentTreeLock = FALSE;
__Enter
{
+ *DirNode = NULL;
+
//
// Init the control block for the request
//
AFSAcquireExcl( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
+ bReleaseParentTreeLock = TRUE;
+
if( ParentObjectInfo->DataVersion.QuadPart != pResultCB->ParentDataVersion.QuadPart - 1)
{
ParentObjectInfo->FileId.Volume,
ParentObjectInfo->FileId.Vnode,
ParentObjectInfo->FileId.Unique,
- ParentObjectInfo->DataVersion.QuadPart,
- pResultCB->ParentDataVersion.QuadPart);
+ ParentObjectInfo->DataVersion.HighPart,
+ ParentObjectInfo->DataVersion.LowPart,
+ pResultCB->ParentDataVersion.HighPart,
+ pResultCB->ParentDataVersion.LowPart);
//
// We raced so go and lookup the directory entry in the parent
&pResultCB->DirEnum.FileId))
{
- InterlockedIncrement( &pDirNode->OpenReferenceCount);
-
- AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
- AFS_TRACE_LEVEL_VERBOSE,
- "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n",
- &pDirNode->NameInformation.FileName,
- pDirNode,
- pDirNode->OpenReferenceCount);
-
*DirNode = pDirNode;
- AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
try_return( ntStatus = STATUS_REPARSE);
}
else
pResultCB->DirEnum.FileId.Vnode,
pResultCB->DirEnum.FileId.Unique);
- if( pDirNode->OpenReferenceCount == 0)
+ if( pDirNode->DirOpenReferenceCount <= 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
ParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
- AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
}
// Init the short name if we have one
//
- if( pResultCB->DirEnum.ShortNameLength > 0)
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pResultCB->DirEnum.ShortNameLength > 0)
{
UNICODE_STRING uniShortName;
pDirNode,
&pDirNode->NameInformation.FileName);
}
+ else
+ {
+ //
+ // No short name or short names are disabled
+ //
+
+ pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
+ }
if ( !BooleanFlagOn( ParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY))
{
ParentObjectInfo->DataVersion.QuadPart);
}
- AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
-
//
// Return the directory node
//
try_exit:
+ if ( *DirNode != NULL)
+ {
+
+ lCount = InterlockedIncrement( &(*DirNode)->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyFileCreate Increment count on %wZ DE %p Cnt %d\n",
+ &(*DirNode)->NameInformation.FileName,
+ *DirNode,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
+ if ( bReleaseParentTreeLock)
+ {
+
+ AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+
if( pResultCB != NULL)
{
- AFSExFreePool( pResultCB);
+ AFSExFreePoolWithTag( pResultCB, AFS_GENERIC_MEMORY_1_TAG);
}
}
{
NTSTATUS ntStatus = STATUS_SUCCESS;
- AFSDeviceExt *pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension;
AFSFileUpdateCB stUpdateCB;
ULONG ulResultLen = 0;
AFSFileUpdateResultCB *pUpdateResultCB = NULL;
if( pUpdateResultCB != NULL)
{
- AFSExFreePool( pUpdateResultCB);
+ AFSExFreePoolWithTag( pUpdateResultCB, AFS_UPDATE_RESULT_TAG);
}
}
AFSFileDeleteCB stDelete;
AFSFileDeleteResultCB stDeleteResult;
ULONG ulRequestFlags = AFS_REQUEST_FLAG_SYNCHRONOUS;
+ AFSObjectInfoCB *pObjectInfo = NULL;
+ AFSObjectInfoCB *pParentObjectInfo = NULL;
__Enter
{
- stDelete.ParentId = DirectoryCB->ObjectInformation->ParentObjectInformation->FileId;
+ pObjectInfo = DirectoryCB->ObjectInformation;
+
+ pParentObjectInfo = AFSFindObjectInfo( pObjectInfo->VolumeCB,
+ &pObjectInfo->ParentFileId);
+
+ stDelete.ParentId = pObjectInfo->ParentFileId;
stDelete.ProcessId = (ULONGLONG)PsGetCurrentProcessId();
ulRequestFlags,
AuthGroup,
&DirectoryCB->NameInformation.FileName,
- &DirectoryCB->ObjectInformation->FileId,
+ &pObjectInfo->FileId,
&stDelete,
sizeof( AFSFileDeleteCB),
&stDeleteResult,
stDelete.ParentId.Vnode,
stDelete.ParentId.Unique,
&DirectoryCB->NameInformation.FileName,
- DirectoryCB->ObjectInformation->FileId.Cell,
- DirectoryCB->ObjectInformation->FileId.Volume,
- DirectoryCB->ObjectInformation->FileId.Vnode,
- DirectoryCB->ObjectInformation->FileId.Unique,
+ pObjectInfo->FileId.Cell,
+ pObjectInfo->FileId.Volume,
+ pObjectInfo->FileId.Vnode,
+ pObjectInfo->FileId.Unique,
ntStatus);
try_return( ntStatus);
}
- AFSAcquireExcl( DirectoryCB->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ AFSAcquireExcl( pObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
if( CheckOnly)
// Validate the parent data version
//
- if( DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart != stDeleteResult.ParentDataVersion.QuadPart)
+ if( pParentObjectInfo->DataVersion.QuadPart != stDeleteResult.ParentDataVersion.QuadPart)
{
- SetFlag( DirectoryCB->ObjectInformation->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
- DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
}
}
else
// Update the parent data version
//
- if( DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart != stDeleteResult.ParentDataVersion.QuadPart - 1)
+ if( pParentObjectInfo->DataVersion.QuadPart != stDeleteResult.ParentDataVersion.QuadPart - 1)
{
- SetFlag( DirectoryCB->ObjectInformation->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
- DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
}
else
{
// Directory data version number can be updated. Until then we must force
// a verification.
//
- // DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart = stDeleteResult.ParentDataVersion.QuadPart;
+ // pParentObjectInfor->DataVersion.QuadPart = stDeleteResult.ParentDataVersion.QuadPart;
//
- SetFlag( DirectoryCB->ObjectInformation->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
- DirectoryCB->ObjectInformation->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
}
}
- AFSReleaseResource( DirectoryCB->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ AFSReleaseResource( pObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
try_exit:
- NOTHING;
+ if ( pParentObjectInfo)
+ {
+
+ AFSReleaseObjectInfo( &pParentObjectInfo);
+ }
}
return ntStatus;
}
+
+NTSTATUS
+AFSNotifyHardLink( IN AFSObjectInfoCB *ObjectInfo,
+ IN GUID *AuthGroup,
+ IN AFSObjectInfoCB *ParentObjectInfo,
+ IN AFSObjectInfoCB *TargetParentObjectInfo,
+ IN AFSDirectoryCB *SourceDirectoryCB,
+ IN UNICODE_STRING *TargetName,
+ IN BOOLEAN bReplaceIfExists,
+ OUT AFSDirectoryCB **TargetDirectoryCB)
+{
+
+ NTSTATUS ntStatus = STATUS_SUCCESS;
+ AFSFileHardLinkCB *pHardLinkCB = NULL;
+ AFSFileHardLinkResultCB *pResultCB = NULL;
+ ULONG ulResultLen = 0;
+ AFSDirectoryCB *pDirNode = NULL;
+ ULONG ulCRC = 0;
+ BOOLEAN bReleaseParentLock = FALSE, bReleaseTargetParentLock = FALSE;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
+ LONG lCount;
+
+ __Enter
+ {
+
+ //
+ // Init the control block for the request
+ //
+
+ pHardLinkCB = (AFSFileHardLinkCB *)AFSExAllocatePoolWithTag( PagedPool,
+ PAGE_SIZE,
+ AFS_HARDLINK_REQUEST_TAG);
+
+ if( pHardLinkCB == NULL)
+ {
+
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+ }
+
+ RtlZeroMemory( pHardLinkCB,
+ PAGE_SIZE);
+
+ pHardLinkCB->SourceParentId = ParentObjectInfo->FileId;
+
+ pHardLinkCB->TargetParentId = TargetParentObjectInfo->FileId;
+
+ pHardLinkCB->TargetNameLength = TargetName->Length;
+
+ RtlCopyMemory( pHardLinkCB->TargetName,
+ TargetName->Buffer,
+ TargetName->Length);
+
+ pHardLinkCB->bReplaceIfExists = bReplaceIfExists;
+
+ //
+ // Use the same buffer for the result control block
+ //
+
+ pResultCB = (AFSFileHardLinkResultCB *)pHardLinkCB;
+
+ ulResultLen = PAGE_SIZE;
+
+ ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_HARDLINK_FILE,
+ AFS_REQUEST_FLAG_SYNCHRONOUS,
+ AuthGroup,
+ &SourceDirectoryCB->NameInformation.FileName,
+ &ObjectInfo->FileId,
+ pHardLinkCB,
+ sizeof( AFSFileHardLinkCB) + TargetName->Length,
+ pResultCB,
+ &ulResultLen);
+
+ if( ntStatus != STATUS_SUCCESS)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSNotifyHardLink failed FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+ ObjectInfo->FileId.Cell,
+ ObjectInfo->FileId.Volume,
+ ObjectInfo->FileId.Vnode,
+ ObjectInfo->FileId.Unique,
+ ntStatus);
+
+ try_return( ntStatus);
+ }
+
+ //
+ // Update the information from the returned data
+ //
+
+ if ( ParentObjectInfo != TargetParentObjectInfo)
+ {
+
+ AFSAcquireExcl( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ bReleaseParentLock = TRUE;
+
+ if ( ParentObjectInfo->DataVersion.QuadPart == pResultCB->SourceParentDataVersion.QuadPart - 1)
+ {
+
+ ParentObjectInfo->DataVersion = pResultCB->SourceParentDataVersion;
+ }
+ else
+ {
+
+ SetFlag( ParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ ParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+ }
+
+ AFSAcquireExcl( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
+ bReleaseTargetParentLock = TRUE;
+
+ if ( TargetParentObjectInfo->DataVersion.QuadPart == pResultCB->TargetParentDataVersion.QuadPart - 1)
+ {
+
+ TargetParentObjectInfo->DataVersion = pResultCB->TargetParentDataVersion;
+ }
+ else
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_WARNING,
+ "AFSNotifyHardLink Raced with an invalidate call and a re-enumeration for entry %wZ ParentFID %08lX-%08lX-%08lX-%08lX Version (%08lX:%08lX != %08lX:%08lX - 1)\n",
+ TargetName,
+ TargetParentObjectInfo->FileId.Cell,
+ TargetParentObjectInfo->FileId.Volume,
+ TargetParentObjectInfo->FileId.Vnode,
+ TargetParentObjectInfo->FileId.Unique,
+ TargetParentObjectInfo->DataVersion.HighPart,
+ TargetParentObjectInfo->DataVersion.LowPart,
+ pResultCB->TargetParentDataVersion.HighPart,
+ pResultCB->TargetParentDataVersion.LowPart);
+
+ //
+ // We raced so go and lookup the directory entry in the parent
+ //
+
+ ulCRC = AFSGenerateCRC( TargetName,
+ FALSE);
+
+ AFSLocateCaseSensitiveDirEntry( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.CaseSensitiveTreeHead,
+ ulCRC,
+ &pDirNode);
+
+ if( pDirNode != NULL)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Located dir entry %p for file %wZ\n",
+ pDirNode,
+ TargetName);
+
+ if ( AFSIsEqualFID( &pDirNode->ObjectInformation->FileId,
+ &pResultCB->DirEnum.FileId))
+ {
+
+ try_return( ntStatus = STATUS_REPARSE);
+ }
+ else
+ {
+
+ //
+ // We found an entry that matches the desired name but it is not the
+ // same as the one that was created for us by the file server.
+ //
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_ERROR,
+ "AFSNotifyHardLink Found matching name entry %wZ DE %p FID %08lX-%08lX-%08lX-%08lX != FID %08lX-%08lX-%08lX-%08lX\n",
+ TargetName,
+ pDirNode,
+ pDirNode->ObjectInformation->FileId.Cell,
+ pDirNode->ObjectInformation->FileId.Volume,
+ pDirNode->ObjectInformation->FileId.Vnode,
+ pDirNode->ObjectInformation->FileId.Unique,
+ pResultCB->DirEnum.FileId.Cell,
+ pResultCB->DirEnum.FileId.Volume,
+ pResultCB->DirEnum.FileId.Vnode,
+ pResultCB->DirEnum.FileId.Unique);
+
+ if( pDirNode->DirOpenReferenceCount <= 0)
+ {
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Different FIDs - Deleting DE %p for %wZ Old FID %08lX-%08lX-%08lX-%08lX New FID %08lX-%08lX-%08lX-%08lX\n",
+ pDirNode,
+ &pDirNode->NameInformation.FileName,
+ pDirNode->ObjectInformation->FileId.Cell,
+ pDirNode->ObjectInformation->FileId.Volume,
+ pDirNode->ObjectInformation->FileId.Vnode,
+ pDirNode->ObjectInformation->FileId.Unique,
+ pResultCB->DirEnum.FileId.Cell,
+ pResultCB->DirEnum.FileId.Volume,
+ pResultCB->DirEnum.FileId.Vnode,
+ pResultCB->DirEnum.FileId.Unique);
+
+ AFSDeleteDirEntry( TargetParentObjectInfo,
+ pDirNode);
+ }
+ else
+ {
+
+ SetFlag( pDirNode->Flags, AFS_DIR_ENTRY_DELETED);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Different FIDs - Removing DE %p for %wZ Old FID %08lX-%08lX-%08lX-%08lX New FID %08lX-%08lX-%08lX-%08lX\n",
+ pDirNode,
+ &pDirNode->NameInformation.FileName,
+ pDirNode->ObjectInformation->FileId.Cell,
+ pDirNode->ObjectInformation->FileId.Volume,
+ pDirNode->ObjectInformation->FileId.Vnode,
+ pDirNode->ObjectInformation->FileId.Unique,
+ pResultCB->DirEnum.FileId.Cell,
+ pResultCB->DirEnum.FileId.Volume,
+ pResultCB->DirEnum.FileId.Vnode,
+ pResultCB->DirEnum.FileId.Unique);
+
+ AFSRemoveNameEntry( TargetParentObjectInfo,
+ pDirNode);
+ }
+
+ pDirNode = NULL;
+ }
+ }
+
+ //
+ // We are unsure of our current data so set the verify flag. It may already be set
+ // but no big deal to reset it
+ //
+
+ SetFlag( TargetParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ TargetParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
+ }
+
+ //
+ // Create the hard link entry
+ //
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Creating new entry %wZ\n",
+ TargetName);
+
+ //
+ // Initialize the directory entry
+ //
+
+ pDirNode = AFSInitDirEntry( TargetParentObjectInfo,
+ TargetName,
+ NULL,
+ &pResultCB->DirEnum,
+ (ULONG)InterlockedIncrement( &TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.ContentIndex));
+
+ if( pDirNode == NULL)
+ {
+
+ SetFlag( TargetParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
+
+ TargetParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
+
+ try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+ }
+
+ //
+ // Init the short name if we have one
+ //
+
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ pResultCB->DirEnum.ShortNameLength > 0)
+ {
+
+ UNICODE_STRING uniShortName;
+
+ pDirNode->NameInformation.ShortNameLength = pResultCB->DirEnum.ShortNameLength;
+
+ RtlCopyMemory( pDirNode->NameInformation.ShortName,
+ pResultCB->DirEnum.ShortName,
+ pDirNode->NameInformation.ShortNameLength);
+
+ //
+ // Generate the short name index
+ //
+
+ uniShortName.Length = pDirNode->NameInformation.ShortNameLength;
+ uniShortName.Buffer = pDirNode->NameInformation.ShortName;
+
+ pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = AFSGenerateCRC( &uniShortName,
+ TRUE);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Initialized short name %wZ for DE %p for %wZ\n",
+ &uniShortName,
+ pDirNode,
+ &pDirNode->NameInformation.FileName);
+ }
+ else
+ {
+ //
+ // No short name or short names are disabled
+ //
+
+ pDirNode->Type.Data.ShortNameTreeEntry.HashIndex = 0;
+ }
+
+ if ( !BooleanFlagOn( TargetParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY))
+ {
+
+ //
+ // Update the target parent data version
+ //
+
+ TargetParentObjectInfo->DataVersion = pResultCB->TargetParentDataVersion;
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink entry %wZ ParentFID %08lX-%08lX-%08lX-%08lX Version %08lX:%08lX\n",
+ TargetName,
+ TargetParentObjectInfo->FileId.Cell,
+ TargetParentObjectInfo->FileId.Volume,
+ TargetParentObjectInfo->FileId.Vnode,
+ TargetParentObjectInfo->FileId.Unique,
+ TargetParentObjectInfo->DataVersion.QuadPart);
+ }
+
+try_exit:
+
+ if ( TargetDirectoryCB != NULL)
+ {
+
+ lCount = InterlockedIncrement( &pDirNode->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSNotifyHardLink Increment count on %wZ DE %p Cnt %d\n",
+ &pDirNode->NameInformation.FileName,
+ pDirNode,
+ lCount);
+
+ ASSERT( lCount >= 0);
+
+ *TargetDirectoryCB = pDirNode;
+ }
+
+ if ( bReleaseTargetParentLock)
+ {
+
+ AFSReleaseResource( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+
+ if ( bReleaseParentLock)
+ {
+
+ AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+
+ if( pHardLinkCB != NULL)
+ {
+
+ AFSExFreePoolWithTag( pHardLinkCB, AFS_HARDLINK_REQUEST_TAG);
+ }
+ }
+
+ return ntStatus;
+}
+
+
+
NTSTATUS
AFSNotifyRename( IN AFSObjectInfoCB *ObjectInfo,
IN GUID *AuthGroup,
AFSFileRenameCB *pRenameCB = NULL;
AFSFileRenameResultCB *pRenameResultCB = NULL;
ULONG ulResultLen = 0;
+ AFSDeviceExt *pDevExt = (AFSDeviceExt *) AFSRDRDeviceObject->DeviceExtension;
__Enter
{
if ( ParentObjectInfo != TargetParentObjectInfo)
{
+ AFSAcquireExcl( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ TRUE);
+
if ( TargetParentObjectInfo->DataVersion.QuadPart == pRenameResultCB->TargetParentDataVersion.QuadPart - 1)
{
DirectoryCB->NameInformation.ShortNameLength = pRenameResultCB->DirEnum.ShortNameLength;
- if( DirectoryCB->NameInformation.ShortNameLength > 0)
+ if( !BooleanFlagOn( pDevExt->DeviceFlags, AFS_DEVICE_FLAG_DISABLE_SHORTNAMES) &&
+ DirectoryCB->NameInformation.ShortNameLength > 0)
{
UNICODE_STRING uniShortName;
DirectoryCB->Type.Data.ShortNameTreeEntry.HashIndex = 0;
}
+ if ( ParentObjectInfo != TargetParentObjectInfo)
+ {
+
+ AFSReleaseResource( TargetParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ }
+
AFSReleaseResource( ParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
if( UpdatedFID != NULL)
if( pRenameCB != NULL)
{
- AFSExFreePool( pRenameCB);
+ AFSExFreePoolWithTag( pRenameCB, AFS_RENAME_REQUEST_TAG);
}
}
AFSFileEvalResultCB *pEvalResultCB = NULL;
AFSDirEnumEntry *pDirEnumCB = NULL;
ULONG ulRequestFlags = AFS_REQUEST_FLAG_SYNCHRONOUS;
+ AFSObjectInfoCB *pParentObjectInfo = NULL;
__Enter
{
RtlZeroMemory( &stTargetID,
sizeof( AFSEvalTargetCB));
- if( ObjectInfo->ParentObjectInformation != NULL)
+ if ( BooleanFlagOn( ObjectInfo->Flags, AFS_OBJECT_FLAGS_PARENT_FID))
{
- stTargetID.ParentId = ObjectInfo->ParentObjectInformation->FileId;
+ pParentObjectInfo = AFSFindObjectInfo( ObjectInfo->VolumeCB,
+ &ObjectInfo->ParentFileId);
+
+ stTargetID.ParentId = ObjectInfo->ParentFileId;
}
//
if( ntStatus == STATUS_OBJECT_PATH_INVALID)
{
- if( ObjectInfo->ParentObjectInformation != NULL)
+ if( pParentObjectInfo != NULL)
{
- AFSAcquireExcl( ObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
- SetFlag( ObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
- ObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
- AFSReleaseResource( ObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
}
// Validate the parent data version
//
- if ( ObjectInfo->ParentObjectInformation != NULL)
+ if ( pParentObjectInfo != NULL)
{
- AFSAcquireExcl( ObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+ AFSAcquireExcl( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock,
TRUE);
- if ( ObjectInfo->ParentObjectInformation->DataVersion.QuadPart != pEvalResultCB->ParentDataVersion.QuadPart)
+ if ( pParentObjectInfo->DataVersion.QuadPart != pEvalResultCB->ParentDataVersion.QuadPart)
{
- SetFlag( ObjectInfo->ParentObjectInformation->Flags, AFS_OBJECT_FLAGS_VERIFY);
+ SetFlag( pParentObjectInfo->Flags, AFS_OBJECT_FLAGS_VERIFY);
- ObjectInfo->ParentObjectInformation->DataVersion.QuadPart = (ULONGLONG)-1;
+ pParentObjectInfo->DataVersion.QuadPart = (ULONGLONG)-1;
}
- AFSReleaseResource( ObjectInfo->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+ AFSReleaseResource( pParentObjectInfo->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
//
try_exit:
+ if ( pParentObjectInfo != NULL)
+ {
+
+ AFSReleaseObjectInfo( &pParentObjectInfo);
+ }
+
if( pEvalResultCB != NULL)
{
- AFSExFreePool( pEvalResultCB);
+ AFSExFreePoolWithTag( pEvalResultCB, AFS_GENERIC_MEMORY_30_TAG);
}
if( !NT_SUCCESS( ntStatus))
if( pDirEnumCB != NULL)
{
- AFSExFreePool( pDirEnumCB);
+ AFSExFreePoolWithTag( pDirEnumCB, AFS_GENERIC_MEMORY_2_TAG);
}
*DirEnumEntry = NULL;
if( pEvalResultCB != NULL)
{
- AFSExFreePool( pEvalResultCB);
+ AFSExFreePoolWithTag( pEvalResultCB, AFS_GENERIC_MEMORY_31_TAG);
}
if( !NT_SUCCESS( ntStatus))
if( pDirEnumCB != NULL)
{
- AFSExFreePool( pDirEnumCB);
+ AFSExFreePoolWithTag( pDirEnumCB, AFS_GENERIC_MEMORY_3_TAG);
}
*DirEnumEntry = NULL;
ULONG ulResultLen = 0;
MDL *pInputMdl = NULL, *pOutputMdl = NULL;
void *pInputSystemBuffer = NULL, *pOutputSystemBuffer = NULL;
- ULONG ulBufferLength = OutputLength;
AFSPipeIORequestCB *pIoRequest = NULL;
__Enter
if( pIoRequest != NULL)
{
- AFSExFreePool( pIoRequest);
+ AFSExFreePoolWithTag( pIoRequest, AFS_GENERIC_MEMORY_4_TAG);
}
}
if( pInfoRequest != NULL)
{
- AFSExFreePool( pInfoRequest);
+ AFSExFreePoolWithTag( pInfoRequest, AFS_GENERIC_MEMORY_5_TAG);
}
}
{
BOOLEAN bRequestQueued = FALSE;
- NTSTATUS ntStatus = STATUS_SUCCESS;
AFSDeviceExt *pControlDevExt = (AFSDeviceExt *)AFSControlDeviceObject->DeviceExtension;
AFSCommSrvcCB *pCommSrvc = NULL;
AFSPoolEntry *pPoolEntry = NULL;