Windows: AFSSetDispositionInfo Verify Dir Enum
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 12 Apr 2013 05:53:54 +0000 (01:53 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Thu, 25 Apr 2013 21:25:06 +0000 (14:25 -0700)
Before testing whether or not a directory is empty, the directory
must be enumerated.  If it is not, enumerate it.

Change-Id: I0302733821e1d5c6be3198be7fe75333d8e01245
Reviewed-on: http://gerrit.openafs.org/9780
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

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

index d6bf731..cbc272b 100644 (file)
@@ -2130,6 +2130,52 @@ AFSSetDispositionInfo( IN PIRP Irp,
                     try_return( ntStatus = STATUS_DIRECTORY_NOT_EMPTY);
                 }
 
+                //
+                // Make sure the directory is enumerated before checking to see if it is empty.
+                //
+
+                if( !BooleanFlagOn( pFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED))
+                {
+
+                    AFSAcquireExcl( pFcb->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
+                                    TRUE);
+
+                    if( !BooleanFlagOn( pFcb->ObjectInformation->Flags, AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED))
+                    {
+
+                        AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
+                                      AFS_TRACE_LEVEL_VERBOSE,
+                                      "AFSSetDispositionInfo Enumerating parent FID %08lX-%08lX-%08lX-%08lX\n",
+                                      pFcb->ObjectInformation->FileId.Cell,
+                                      pFcb->ObjectInformation->FileId.Volume,
+                                      pFcb->ObjectInformation->FileId.Vnode,
+                                      pFcb->ObjectInformation->FileId.Unique));
+
+                        ntStatus = AFSEnumerateDirectory( &pCcb->AuthGroup,
+                                                          pFcb->ObjectInformation,
+                                                          TRUE);
+
+                        if( !NT_SUCCESS( ntStatus))
+                        {
+
+                            AFSReleaseResource( pFcb->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+
+                            AFSDbgTrace(( AFS_SUBSYSTEM_FILE_PROCESSING,
+                                          AFS_TRACE_LEVEL_ERROR,
+                                          "AFSSetDispositionInfo Failed to enumerate parent FID %08lX-%08lX-%08lX-%08lX Status %08lX\n",
+                                          pFcb->ObjectInformation->FileId.Cell,
+                                          pFcb->ObjectInformation->FileId.Volume,
+                                          pFcb->ObjectInformation->FileId.Vnode,
+                                          pFcb->ObjectInformation->FileId.Unique,
+                                          ntStatus));
+
+                            try_return( ntStatus);
+                        }
+                    }
+
+                    AFSReleaseResource( pFcb->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock);
+                }
+
                 if( !AFSIsDirectoryEmptyForDelete( pFcb))
                 {
 
index 3523283..cdcb70f 100644 (file)
@@ -7306,6 +7306,8 @@ AFSIsDirectoryEmptyForDelete( IN AFSFcb *Fcb)
     __Enter
     {
 
+        ASSERT( Fcb->ObjectInformation->FileType == AFS_FILE_TYPE_DIRECTORY);
+
         AFSAcquireShared( Fcb->ObjectInformation->Specific.Directory.DirectoryNodeHdr.TreeLock,
                           TRUE);