Windows: Set new file index correctly during rename
authorRod Widdowson <rdw@steadingsoftware.com>
Fri, 21 Oct 2011 15:57:02 +0000 (16:57 +0100)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 25 Oct 2011 01:06:44 +0000 (18:06 -0700)
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 <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsrdr/kernel/lib/AFSFileInfo.cpp

index 27e508d..2c73daf 100644 (file)
@@ -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);