Windows: AFSInitFcb STATUS_REPARSE cleanup
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSFcbSupport.cpp
index 0ea85fa..9f1a979 100644 (file)
@@ -59,7 +59,6 @@ AFSInitFcb( IN AFSDirectoryCB  *DirEntry)
     AFSFcb *pFcb = NULL;
     AFSNonPagedFcb *pNPFcb = NULL;
     IO_STATUS_BLOCK stIoSb = {0,0};
-    BOOLEAN bUninitFileLock = FALSE;
     USHORT  usFcbLength = 0;
     ULONGLONG   ullIndex = 0;
     AFSDirEnumEntry *pDirEnumCB = NULL;
@@ -179,14 +178,6 @@ AFSInitFcb( IN AFSDirectoryCB  *DirEntry)
             //
 
             pFcb->Header.NodeTypeCode = AFS_DIRECTORY_FCB;
-
-            //
-            // Initialize enumeration information
-            //
-
-            KeInitializeEvent( &pFcb->NPFcb->Specific.Directory.DirectoryEnumEvent,
-                               NotificationEvent,
-                               FALSE);
         }
         else if( pObjectInfo->FileType == AFS_FILE_TYPE_FILE)
         {
@@ -201,8 +192,6 @@ AFSInitFcb( IN AFSDirectoryCB  *DirEntry)
                                      NULL,
                                      NULL);
 
-            bUninitFileLock = TRUE;
-
             //
             // Initialize the header file sizes to our dir entry information
             //
@@ -322,32 +311,34 @@ try_exit:
             if( pFcb != NULL)
             {
 
-                if( bUninitFileLock)
-                {
-
-                    FsRtlUninitializeFileLock( &pFcb->Specific.File.FileLock);
-                }
-
                 if( pNPFcb != NULL)
                 {
 
                     AFSReleaseResource( &pNPFcb->Resource);
 
+                    FsRtlTeardownPerStreamContexts( &pFcb->Header);
+
+                    if ( pObjectInfo->FileType == AFS_FILE_TYPE_FILE)
+                    {
+
+                        FsRtlUninitializeFileLock( &pFcb->Specific.File.FileLock);
+
+                        ExDeleteResourceLite( &pNPFcb->Specific.File.ExtentsResource);
+
+                        ExDeleteResourceLite( &pNPFcb->Specific.File.DirtyExtentsListLock);
+                    }
+
                     ExDeleteResourceLite( &pNPFcb->PagingResource);
 
                     ExDeleteResourceLite( &pNPFcb->CcbListLock);
 
                     ExDeleteResourceLite( &pNPFcb->Resource);
+
+                    AFSExFreePool( pNPFcb);
                 }
 
                 AFSExFreePool( pFcb);
             }
-
-            if( pNPFcb != NULL)
-            {
-
-                AFSExFreePool( pNPFcb);
-            }
         }
     }
 
@@ -792,7 +783,7 @@ AFSRemoveVolume( IN AFSVolumeCB *VolumeCB)
             if( VolumeCB->ObjectInformation.Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb != NULL)
             {
 
-                AFSRemoveFcb( VolumeCB->ObjectInformation.Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb);
+                AFSRemoveFcb( &VolumeCB->ObjectInformation.Specific.Directory.PIOCtlDirectoryCB->ObjectInformation->Fcb);
             }
 
             AFSDeleteObjectInfo( VolumeCB->ObjectInformation.Specific.Directory.PIOCtlDirectoryCB->ObjectInformation);
@@ -958,14 +949,6 @@ AFSInitRootFcb( IN ULONGLONG ProcessID,
         pFcb->NPFcb = pNPFcb;
 
         //
-        // Initialize enumeration information
-        //
-
-        KeInitializeEvent( &pFcb->NPFcb->Specific.Directory.DirectoryEnumEvent,
-                           NotificationEvent,
-                           FALSE);
-
-        //
         // Save the root Fcb in the VolumeCB
         //
 
@@ -1054,9 +1037,19 @@ AFSRemoveRootFcb( IN AFSFcb *RootFcb)
 //
 
 void
-AFSRemoveFcb( IN AFSFcb *Fcb)
+AFSRemoveFcb( IN AFSFcb **ppFcb)
 {
 
+    AFSFcb * pFcb;
+
+    pFcb = (AFSFcb *) InterlockedCompareExchangePointer( (PVOID *)ppFcb, NULL, (PVOID)(*ppFcb));
+
+    if ( pFcb == NULL)
+    {
+
+        return;
+    }
+
     //
     // Uninitialize the file lock if it is a file
     //
@@ -1064,23 +1057,23 @@ AFSRemoveFcb( IN AFSFcb *Fcb)
     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
                   AFS_TRACE_LEVEL_VERBOSE,
                   "AFSRemoveFcb Removing Fcb %08lX\n",
-                  Fcb);
+                  pFcb);
 
-    if( Fcb->Header.NodeTypeCode == AFS_FILE_FCB)
+    if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
     {
 
-        FsRtlUninitializeFileLock( &Fcb->Specific.File.FileLock);
+        FsRtlUninitializeFileLock( &pFcb->Specific.File.FileLock);
 
         //
         // The resource we allocated
         //
 
-        ExDeleteResourceLite( &Fcb->NPFcb->Specific.File.ExtentsResource );
+        ExDeleteResourceLite( &pFcb->NPFcb->Specific.File.ExtentsResource );
 
-        ExDeleteResourceLite( &Fcb->NPFcb->Specific.File.DirtyExtentsListLock);
+        ExDeleteResourceLite( &pFcb->NPFcb->Specific.File.DirtyExtentsListLock);
 
     }
-    else if( Fcb->Header.NodeTypeCode == AFS_DIRECTORY_FCB)
+    else if( pFcb->Header.NodeTypeCode == AFS_DIRECTORY_FCB)
     {
 
 
@@ -1090,29 +1083,29 @@ AFSRemoveFcb( IN AFSFcb *Fcb)
     // Tear down the FM specific contexts
     //
 
-    FsRtlTeardownPerStreamContexts( &Fcb->Header);
+    FsRtlTeardownPerStreamContexts( &pFcb->Header);
 
     //
     // Delete the resources
     //
 
-    ExDeleteResourceLite( &Fcb->NPFcb->Resource);
+    ExDeleteResourceLite( &pFcb->NPFcb->Resource);
 
-    ExDeleteResourceLite( &Fcb->NPFcb->PagingResource);
+    ExDeleteResourceLite( &pFcb->NPFcb->PagingResource);
 
-    ExDeleteResourceLite( &Fcb->NPFcb->CcbListLock);
+    ExDeleteResourceLite( &pFcb->NPFcb->CcbListLock);
 
     //
     // The non paged region
     //
 
-    AFSExFreePool( Fcb->NPFcb);
+    AFSExFreePool( pFcb->NPFcb);
 
     //
     // And the Fcb itself, which includes the name
     //
 
-    AFSExFreePool( Fcb);
+    AFSExFreePool( pFcb);
 
     return;
 }