AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSQueryFileInfo Attempted access (%08lX) when pFcb == NULL\n",
+ "AFSQueryFileInfo Attempted access (%p) when pFcb == NULL\n",
Irp);
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSQueryFileInfo Acquiring Fcb lock %08lX SHARED %08lX\n",
+ "AFSQueryFileInfo Acquiring Fcb lock %p SHARED %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
- "AFSSetFileInfo Attempted access (%08lX) when pFcb == NULL\n",
+ "AFSSetFileInfo Attempted access (%p) when pFcb == NULL\n",
Irp);
try_return( ntStatus = STATUS_INVALID_DEVICE_REQUEST);
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetFileInfo Acquiring Fcb lock %08lX EXCL %08lX\n",
+ "AFSSetFileInfo Acquiring Fcb lock %p EXCL %08lX\n",
&pFcb->NPFcb->Resource,
PsGetCurrentThread());
RtlZeroMemory( &stParentFileId,
sizeof( AFSFileID));
- if( pFcb->ObjectInformation->ParentObjectInformation != NULL)
+ if( BooleanFlagOn( pFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID))
{
- stParentFileId = pFcb->ObjectInformation->ParentObjectInformation->FileId;
+
+ stParentFileId = pFcb->ObjectInformation->ParentFileId;
}
//
if( *Length >= sizeof( FILE_INTERNAL_INFORMATION))
{
- Buffer->IndexNumber.HighPart = Fcb->ObjectInformation->FileId.Volume;
+ Buffer->IndexNumber.HighPart = Fcb->ObjectInformation->FileId.Vnode;
- Buffer->IndexNumber.LowPart = Fcb->ObjectInformation->FileId.Vnode;
+ Buffer->IndexNumber.LowPart = Fcb->ObjectInformation->FileId.Unique;
*Length -= sizeof( FILE_INTERNAL_INFORMATION);
}
if( ulNotifyFilter > 0)
{
- if( DirectoryCB->ObjectInformation->ParentObjectInformation != NULL)
+ if( BooleanFlagOn( DirectoryCB->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID))
{
- AFSFsRtlNotifyFullReportChange( DirectoryCB->ObjectInformation->ParentObjectInformation,
- pCcb,
- (ULONG)ulNotifyFilter,
- (ULONG)FILE_ACTION_MODIFIED);
+ AFSObjectInfoCB * pParentObjectInfo = AFSFindObjectInfo( DirectoryCB->ObjectInformation->VolumeCB,
+ &DirectoryCB->ObjectInformation->ParentFileId);
+
+ if ( pParentObjectInfo != NULL)
+ {
+ AFSFsRtlNotifyFullReportChange( pParentObjectInfo,
+ pCcb,
+ (ULONG)ulNotifyFilter,
+ (ULONG)FILE_ACTION_MODIFIED);
+
+ AFSReleaseObjectInfo( &pParentObjectInfo);
+ }
}
}
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetDispositionInfo Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetDispositionInfo Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetDispositionInfo Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetDispositionInfo Releasing Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
pSrcCcb = (AFSCcb *)pSrcFileObj->FsContext2;
pSrcObject = pSrcFcb->ObjectInformation;
- pSrcParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation;
+
+ if ( BooleanFlagOn( pSrcFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID))
+ {
+
+ pSrcParentObject = AFSFindObjectInfo( pSrcFcb->ObjectInformation->VolumeCB,
+ &pSrcFcb->ObjectInformation->ParentFileId);
+ }
pFileLinkInfo = (PFILE_LINK_INFORMATION)Irp->AssociatedIrp.SystemBuffer;
if( pTargetDirEntry != NULL)
{
- ASSERT( pTargetParentObject == pTargetDirEntry->ObjectInformation->ParentObjectInformation);
+ ASSERT( BooleanFlagOn( pTargetDirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID) &&
+ AFSIsEqualFID( &pTargetParentObject->FileId, &pTargetDirEntry->ObjectInformation->ParentFileId));
lCount = InterlockedIncrement( &pTargetDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_ERROR,
- "AFSSetFileLinkInfo Target %wZ exists DE %p Count %08lX, performing delete of target\n",
+ "AFSSetFileLinkInfo Target %wZ exists DE %p Count %d, performing delete of target\n",
&pTargetDirEntry->NameInformation.FileName,
pTargetDirEntry,
- pTargetDirEntry->DirOpenReferenceCount);
+ lCount);
//
// Pull the directory entry from the parent
ntStatus = AFSNotifyHardLink( pSrcFcb->ObjectInformation,
&pSrcCcb->AuthGroup,
- pSrcFcb->ObjectInformation->ParentObjectInformation,
+ pSrcParentObject,
pTargetDcb->ObjectInformation,
pSrcCcb->DirectoryCB,
&uniTargetName,
pFileLinkInfo->ReplaceIfExists,
&pNewTargetDirEntry);
- if( !NT_SUCCESS( ntStatus))
+ if( ntStatus != STATUS_REPARSE &&
+ !NT_SUCCESS( ntStatus))
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
try_return( ntStatus);
}
- AFSInsertDirectoryNode( pTargetDcb->ObjectInformation,
- pNewTargetDirEntry,
- TRUE);
+ if ( ntStatus != STATUS_REPARSE)
+ {
+
+ AFSInsertDirectoryNode( pTargetDcb->ObjectInformation,
+ pNewTargetDirEntry,
+ TRUE);
+ }
//
// Send notification for the target link file
ulNotificationAction = FILE_ACTION_ADDED;
}
- AFSFsRtlNotifyFullReportChange( pTargetParentObject->ParentObjectInformation,
+ AFSFsRtlNotifyFullReportChange( pTargetParentObject,
pSrcCcb,
(ULONG)ulNotifyFilter,
(ULONG)ulNotificationAction);
if( bTargetEntryExists)
{
- AFSInsertDirectoryNode( pTargetDirEntry->ObjectInformation->ParentObjectInformation,
+ AFSInsertDirectoryNode( pTargetParentObject,
pTargetDirEntry,
FALSE);
}
if( pTargetDirEntry != NULL)
{
+ //
+ // Release DirOpenReferenceCount obtained above
+ //
+
lCount = InterlockedDecrement( &pTargetDirEntry->DirOpenReferenceCount);
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
ASSERT( lCount >= 0);
}
+ if( pNewTargetDirEntry != NULL)
+ {
+
+ //
+ // Release DirOpenReferenceCount obtained from AFSNotifyHardLink
+ //
+
+ lCount = InterlockedDecrement( &pNewTargetDirEntry->DirOpenReferenceCount);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetFileLinkInfo Decrement count on %wZ DE %p Ccb %p Cnt %d\n",
+ &pNewTargetDirEntry->NameInformation.FileName,
+ pNewTargetDirEntry,
+ pSrcCcb,
+ lCount);
+
+ ASSERT( lCount >= 0);
+ }
+
if( bReleaseTargetDirLock)
{
AFSReleaseResource( pTargetParentObject->Specific.Directory.DirectoryNodeHdr.TreeLock);
}
+
+ if ( pSrcParentObject != NULL)
+ {
+
+ AFSReleaseObjectInfo( &pSrcParentObject);
+ }
+
+ //
+ // No need to release pTargetParentObject as it is either a copy of pSrcParentObject
+ // or (AFSFcb *)pTargetFileObj->FsContext->ObjectInformation
+ //
+
+ pTargetParentObject = NULL;
}
return ntStatus;
pSrcCcb = (AFSCcb *)pSrcFileObj->FsContext2;
pSrcObject = pSrcFcb->ObjectInformation;
- pSrcParentObject = pSrcFcb->ObjectInformation->ParentObjectInformation;
+
+ if ( BooleanFlagOn( pSrcFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID))
+ {
+
+ pSrcParentObject = AFSFindObjectInfo( pSrcFcb->ObjectInformation->VolumeCB,
+ &pSrcFcb->ObjectInformation->ParentFileId);
+ }
//
// Perform some basic checks to ensure FS integrity
if( pTargetDirEntry != NULL)
{
- ASSERT( pTargetParentObject == pTargetDirEntry->ObjectInformation->ParentObjectInformation);
+ ASSERT( BooleanFlagOn( pTargetDirEntry->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID) &&
+ AFSIsEqualFID( &pTargetParentObject->FileId, &pTargetDirEntry->ObjectInformation->ParentFileId));
lCount = InterlockedIncrement( &pTargetDirEntry->DirOpenReferenceCount);
-
AFSDbgLogMsg( AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_VERBOSE,
"AFSSetRenameInfo Increment count on %wZ DE %p Ccb %p Cnt %d\n",
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING | AFS_SUBSYSTEM_DIRENTRY_REF_COUNTING,
AFS_TRACE_LEVEL_ERROR,
- "AFSSetRenameInfo Target %wZ exists DE %p Count %08lX, performing delete of target\n",
+ "AFSSetRenameInfo Target %wZ exists DE %p Count %d, performing delete of target\n",
&pTargetDirEntry->NameInformation.FileName,
pTargetDirEntry,
- pTargetDirEntry->DirOpenReferenceCount);
+ lCount);
//
// Pull the directory entry from the parent
// same parent we do not pull the node from the enumeration list
//
- AFSRemoveDirNodeFromParent( pSrcFcb->ObjectInformation->ParentObjectInformation,
+ AFSRemoveDirNodeFromParent( pSrcParentObject,
pSrcCcb->DirectoryCB,
!bCommonParent);
ntStatus = AFSNotifyRename( pSrcFcb->ObjectInformation,
&pSrcCcb->AuthGroup,
- pSrcFcb->ObjectInformation->ParentObjectInformation,
+ pSrcParentObject,
pTargetDcb->ObjectInformation,
pSrcCcb->DirectoryCB,
&uniTargetName,
// Attempt to re-insert the directory entry
//
- AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation,
+ AFSInsertDirectoryNode( pSrcParentObject,
pSrcCcb->DirectoryCB,
!bCommonParent);
// Set the notification up for the source file
//
- if( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation == pTargetParentObject &&
+ if( pSrcParentObject == pTargetParentObject &&
!bTargetEntryExists)
{
ulNotifyFilter = FILE_NOTIFY_CHANGE_FILE_NAME;
}
- AFSFsRtlNotifyFullReportChange( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation,
+ AFSFsRtlNotifyFullReportChange( pSrcParentObject,
pSrcCcb,
(ULONG)ulNotifyFilter,
(ULONG)ulNotificationAction);
// Attempt to re-insert the directory entry
//
- AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation,
+ AFSInsertDirectoryNode( pSrcParentObject,
pSrcCcb->DirectoryCB,
!bCommonParent);
// Update the parent pointer in the source object if they are different
//
- if( pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation != pTargetParentObject)
+ if( pSrcParentObject != pTargetParentObject)
{
- lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenHandleCount);
+ lCount = InterlockedDecrement( &pSrcParentObject->Specific.Directory.ChildOpenHandleCount);
- lCount = InterlockedDecrement( &pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation->Specific.Directory.ChildOpenReferenceCount);
+ lCount = InterlockedDecrement( &pSrcParentObject->Specific.Directory.ChildOpenReferenceCount);
lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenHandleCount);
lCount = InterlockedIncrement( &pTargetParentObject->Specific.Directory.ChildOpenReferenceCount);
- pSrcCcb->DirectoryCB->ObjectInformation->ParentObjectInformation = pTargetParentObject;
+ lCount = AFSObjectInfoIncrement( pTargetParentObject,
+ AFS_OBJECT_REFERENCE_CHILD);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetRenameInfo Increment count on parent object %p Cnt %d\n",
+ pTargetParentObject,
+ lCount);
+
+ lCount = AFSObjectInfoDecrement( pSrcParentObject,
+ AFS_OBJECT_REFERENCE_CHILD);
+
+ AFSDbgLogMsg( AFS_SUBSYSTEM_OBJECT_REF_COUNTING,
+ AFS_TRACE_LEVEL_VERBOSE,
+ "AFSSetRenameInfo Decrement count on parent object %p Cnt %d\n",
+ pSrcParentObject,
+ lCount);
+
+ pSrcCcb->DirectoryCB->ObjectInformation->ParentFileId = pTargetParentObject->FileId;
+
+ SetFlag( pSrcCcb->DirectoryCB->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID);
+
+ pSrcParentObject = pTargetParentObject;
ulNotificationAction = FILE_ACTION_ADDED;
}
// Now update the notification for the target file
//
- AFSFsRtlNotifyFullReportChange( pTargetParentObject->ParentObjectInformation,
+ AFSFsRtlNotifyFullReportChange( pTargetParentObject,
pSrcCcb,
(ULONG)ulNotifyFilter,
(ULONG)ulNotificationAction);
ASSERT( lCount >= 0);
- if( lCount == 0)
+ if( lCount == 0 &&
+ pTargetDirEntry->NameArrayReferenceCount <= 0)
{
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetRenameInfo Acquiring Fcb lock %08lX EXCL %08lX\n",
+ "AFSSetRenameInfo Acquiring Fcb lock %p EXCL %08lX\n",
&pTargetFcb->NPFcb->Resource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetRenameInfo Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetRenameInfo Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
&pTargetFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
AFS_TRACE_LEVEL_ERROR,
"AFSSetRenameInfo Failed to delete section for target file %wZ\n",
- &pTargetDirEntry->NameInformation.FileName);
+ &uniTargetName);
}
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetRenameInfo Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetRenameInfo Releasing Fcb SectionObject lock %p EXCL %08lX\n",
&pTargetFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetRenameInfo Releasing Fcb lock %08lX EXCL %08lX\n",
+ "AFSSetRenameInfo Releasing Fcb lock %p EXCL %08lX\n",
&pTargetFcb->NPFcb->Resource,
PsGetCurrentThread());
if( bTargetEntryExists)
{
- AFSInsertDirectoryNode( pTargetDirEntry->ObjectInformation->ParentObjectInformation,
+
+ ASSERT( pTargetParentObject != NULL);
+
+ AFSInsertDirectoryNode( pTargetParentObject,
pTargetDirEntry,
FALSE);
}
AFSReleaseResource( pSourceDirLock);
}
- }
- if ( bDereferenceTargetParentObject)
- {
+ if ( bDereferenceTargetParentObject)
+ {
+
+ ObDereferenceObject( pTargetParentFileObj);
+ }
+
+ if ( pSrcParentObject != NULL)
+ {
+
+ AFSReleaseObjectInfo( &pSrcParentObject);
+ }
- ObDereferenceObject( pTargetParentFileObj);
+ //
+ // No need to release pTargetParentObject as it is either a copy of pSrcParentObject
+ // or (AFSFcb *)pTargetFileObj->FsContext->ObjectInformation
+ //
+
+ pTargetParentObject = NULL;
}
return ntStatus;
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Releasing Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %p EXCL %08lX\n",
&pFcb->NPFcb->PagingResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %p EXCL %08lX\n",
&pFcb->NPFcb->PagingResource,
PsGetCurrentThread());
//
if (bTellService)
{
- ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentObjectInformation->FileId,
+
+ ASSERT( BooleanFlagOn( pFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID));
+
+ ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentFileId,
pFcb->ObjectInformation,
&pCcb->AuthGroup);
}
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetEndOfFileInfo Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetEndOfFileInfo Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetEndOfFileInfo Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+ "AFSSetEndOfFileInfo Releasing Fcb SectionObject lock %p EXCL %08lX\n",
&pFcb->NPFcb->SectionObjectResource,
PsGetCurrentThread());
//
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %p EXCL %08lX\n",
&pFcb->NPFcb->PagingResource,
PsGetCurrentThread());
//
AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
AFS_TRACE_LEVEL_VERBOSE,
- "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %08lX EXCL %08lX\n",
+ "AFSSetAllocationInfo Acquiring Fcb PagingIo lock %p EXCL %08lX\n",
&pFcb->NPFcb->PagingResource,
PsGetCurrentThread());
// Tell the server
//
- ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentObjectInformation->FileId,
+ ASSERT( BooleanFlagOn( pFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_PARENT_FID));
+
+ ntStatus = AFSUpdateFileInformation( &pFcb->ObjectInformation->ParentFileId,
pFcb->ObjectInformation,
&pCcb->AuthGroup);