From 9824a53aea25a150f770e6b37536aa5fd7eb87df Mon Sep 17 00:00:00 2001 From: Rod Widdowson Date: Fri, 21 Oct 2011 16:57:02 +0100 Subject: [PATCH] Windows: Set new file index correctly during rename Directory entries are required to have a file index which is used during directory enumeration. When inserting into a new directory we have to update this from the target directory. This code fixes a bug whereby it was being set from the source FCB, rather than the target one. On failure we now also reset the value to its old value. Change-Id: I726dd2e7ecc84e4a8b28f1f551c89fc6e815d853 Reviewed-on: http://gerrit.openafs.org/5646 Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp index 27e508db1..2c73dafbd 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp @@ -1751,6 +1751,7 @@ AFSSetRenameInfo( IN PIRP Irp) ULONG ulNotificationAction = 0, ulNotifyFilter = 0; UNICODE_STRING uniFullTargetPath; BOOLEAN bCommonParent = FALSE; + ULONG oldFileIndex; __Enter { @@ -2110,6 +2111,7 @@ AFSSetRenameInfo( IN PIRP Irp) AFSReleaseResource( pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock); + oldFileIndex = pSrcCcb->DirectoryCB->FileIndex; if( !bCommonParent) { @@ -2120,7 +2122,7 @@ AFSSetRenameInfo( IN PIRP Irp) // pSrcCcb->DirectoryCB->FileIndex = - (ULONG)InterlockedIncrement( &pSrcFcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.ContentIndex); + (ULONG)InterlockedIncrement( &pTargetDcb->ObjectInformation->ParentObjectInformation->Specific.Directory.DirectoryNodeHdr.ContentIndex); } // @@ -2142,6 +2144,7 @@ AFSSetRenameInfo( IN PIRP Irp) // Attempt to re-insert the directory entry // + pSrcCcb->DirectoryCB->FileIndex = oldFileIndex; AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation, pSrcCcb->DirectoryCB, !bCommonParent); @@ -2202,6 +2205,7 @@ AFSSetRenameInfo( IN PIRP Irp) // Attempt to re-insert the directory entry // + pSrcCcb->DirectoryCB->FileIndex = oldFileIndex; AFSInsertDirectoryNode( pSrcFcb->ObjectInformation->ParentObjectInformation, pSrcCcb->DirectoryCB, !bCommonParent); -- 2.39.5