Windows: Make CCB_FLAGS_DIRECTORY_QUERY_MAPPED consistent
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSDirControl.cpp
index 5471bee..d9e3e96 100644 (file)
@@ -89,12 +89,14 @@ AFSDirControl( IN PDEVICE_OBJECT LibDeviceObject,
                 break;
         }
     }
-    __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+    __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
     {
 
         AFSDbgLogMsg( 0,
                       0,
                       "EXCEPTION - AFSDirControl\n");
+
+        AFSDumpTraceFilesFnc();
     }
 
     if( ntStatus != STATUS_PENDING)
@@ -147,6 +149,7 @@ AFSQueryDirectory( IN PIRP Irp)
     BOOLEAN         bUseFileInfo = TRUE;
     AFSObjectInfoCB *pObjectInfo = NULL;
     ULONG ulAdditionalAttributes = 0;
+    LONG lCount;
 
     __Enter
     {
@@ -203,7 +206,7 @@ AFSQueryDirectory( IN PIRP Irp)
         bReturnSingleEntry = BooleanFlagOn( pIrpSp->Flags, SL_RETURN_SINGLE_ENTRY);
         bIndexSpecified    = BooleanFlagOn( pIrpSp->Flags, SL_INDEX_SPECIFIED);
 
-        bInitialQuery = (BOOLEAN)( !BooleanFlagOn( pCcb->Flags, CCB_FLAGS_DIRECTORY_QUERY_MAPPED));
+        bInitialQuery = (BOOLEAN)( !BooleanFlagOn( pCcb->Flags, CCB_FLAG_DIRECTORY_QUERY_MAPPED));
 
         if( bInitialQuery)
         {
@@ -223,26 +226,6 @@ AFSQueryDirectory( IN PIRP Irp)
                             TRUE);
 
             bReleaseFcb = TRUE;
-
-            //
-            // Tell the service to prime the cache of the directory content
-            //
-
-            ntStatus = AFSEnumerateDirectoryNoResponse( &pFcb->AuthGroup,
-                                                        &pFcb->ObjectInformation->FileId);
-
-            if( !NT_SUCCESS( ntStatus))
-            {
-
-                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
-                              AFS_TRACE_LEVEL_ERROR,
-                              "AFSQueryDirectory Enumerate directory failure for parent %wZ Mask %wZ Status %08lX\n",
-                              &pCcb->DirectoryCB->NameInformation.FileName,
-                              &pCcb->MaskName,
-                              ntStatus);
-
-                try_return( ntStatus);
-            }
         }
         else
         {
@@ -290,7 +273,7 @@ AFSQueryDirectory( IN PIRP Irp)
                           pFcb->ObjectInformation->FileId.Vnode,
                           pFcb->ObjectInformation->FileId.Unique);
 
-            ntStatus = AFSVerifyEntry( &pFcb->AuthGroup,
+            ntStatus = AFSVerifyEntry( &pCcb->AuthGroup,
                                        pCcb->DirectoryCB);
 
             if( !NT_SUCCESS( ntStatus))
@@ -375,7 +358,7 @@ AFSQueryDirectory( IN PIRP Irp)
                 try_return( ntStatus);
             }
 
-            SetFlag( pCcb->Flags, CCB_FLAGS_DIRECTORY_QUERY_MAPPED);
+            SetFlag( pCcb->Flags, CCB_FLAG_DIRECTORY_QUERY_MAPPED);
 
             ClearFlag( pCcb->Flags, CCB_FLAG_DIR_OF_DIRS_ONLY);
 
@@ -660,7 +643,7 @@ AFSQueryDirectory( IN PIRP Irp)
                      BooleanFlagOn( pDirEntry->Flags, AFS_DIR_ENTRY_DELETED))
             {
 
-                InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                 continue;
             }
@@ -684,7 +667,7 @@ AFSQueryDirectory( IN PIRP Irp)
                     if( !FlagOn( pObjectInfo->FileAttributes, FILE_ATTRIBUTE_DIRECTORY))
                     {
 
-                        InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                        lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                         continue;
                     }
@@ -705,7 +688,7 @@ AFSQueryDirectory( IN PIRP Irp)
                                                       NULL))
                         {
 
-                            InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                            lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                             continue;
                         }
@@ -727,7 +710,7 @@ AFSQueryDirectory( IN PIRP Irp)
                                                          TRUE))
                             {
 
-                                InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                                lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                                 continue;
                             }
@@ -742,8 +725,7 @@ AFSQueryDirectory( IN PIRP Irp)
             //
 
             AFSValidateEntry( pDirEntry,
-                              &pFcb->AuthGroup,
-                              FALSE,
+                              &pCcb->AuthGroup,
                               FALSE);
 
             pObjectInfo = pDirEntry->ObjectInformation;
@@ -768,6 +750,7 @@ AFSQueryDirectory( IN PIRP Irp)
                                                            pDirEntry,
                                                            &pCcb->FullFileName,
                                                            pCcb->NameArray,
+                                                           &pCcb->AuthGroup,
                                                            &stFileInfo)))
                 {
 
@@ -804,7 +787,7 @@ AFSQueryDirectory( IN PIRP Irp)
 
                 pCcb->CurrentDirIndex--;
 
-                InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                 try_return( ntStatus = STATUS_SUCCESS);
             }
@@ -928,7 +911,7 @@ AFSQueryDirectory( IN PIRP Irp)
                                   Irp,
                                   FileInformationClass);
 
-                    InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                    lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                     try_return( ntStatus = STATUS_INVALID_INFO_CLASS);
 
@@ -956,12 +939,12 @@ AFSQueryDirectory( IN PIRP Irp)
             if( ulBytesConverted < pDirEntry->NameInformation.FileName.Length)
             {
 
-                InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+                lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
                 try_return( ntStatus = STATUS_BUFFER_OVERFLOW);
             }
 
-            InterlockedDecrement( &pDirEntry->OpenReferenceCount);
+            lCount = InterlockedDecrement( &pDirEntry->OpenReferenceCount);
 
             dStatus = STATUS_SUCCESS;
 
@@ -1106,6 +1089,7 @@ AFSLocateNextDirEntry( IN AFSObjectInfoCB *ObjectInfo,
     AFSSnapshotHdr *pSnapshotHdr = NULL;
     AFSSnapshotEntry *pSnapshotEntry = NULL;
     ULONG ulCount = 0;
+    LONG lCount;
 
     __Enter
     {
@@ -1123,6 +1107,12 @@ AFSLocateNextDirEntry( IN AFSObjectInfoCB *ObjectInfo,
 
                 pDirEntry = ObjectInfo->Specific.Directory.PIOCtlDirectoryCB;
 
+                if( pDirEntry != NULL)
+                {
+
+                    lCount = InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+                }
+
                 AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
                               AFS_TRACE_LEVEL_VERBOSE,
                               "AFSLocateNextDirEntry Returning PIOctl entry %wZ in parent FID %08lX-%08lX-%08lX-%08lX\n",
@@ -1149,6 +1139,12 @@ AFSLocateNextDirEntry( IN AFSObjectInfoCB *ObjectInfo,
 
             pDirEntry = AFSGlobalDotDirEntry;
 
+            if( pDirEntry != NULL)
+            {
+
+                lCount = InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+            }
+
             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSLocateNextDirEntry Returning1 snapshot entry %wZ in parent FID %08lX-%08lX-%08lX-%08lX\n",
@@ -1167,6 +1163,12 @@ AFSLocateNextDirEntry( IN AFSObjectInfoCB *ObjectInfo,
 
             pDirEntry = AFSGlobalDotDotDirEntry;
 
+            if( pDirEntry != NULL)
+            {
+
+                lCount = InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+            }
+
             AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
                           AFS_TRACE_LEVEL_VERBOSE,
                           "AFSLocateNextDirEntry Returning2 snapshot entry %wZ in parent FID %08lX-%08lX-%08lX-%08lX\n",
@@ -1241,7 +1243,7 @@ AFSLocateNextDirEntry( IN AFSObjectInfoCB *ObjectInfo,
                                       ObjectInfo->FileId.Vnode,
                                       ObjectInfo->FileId.Unique);
 
-                        InterlockedIncrement( &pDirEntry->OpenReferenceCount);
+                        lCount = InterlockedIncrement( &pDirEntry->OpenReferenceCount);
                     }
                     else
                     {