Windows: Add global root to name array if share name
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 19 Apr 2012 11:14:16 +0000 (07:14 -0400)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Sun, 22 Apr 2012 23:26:04 +0000 (16:26 -0700)
If the share name was resolved by querying the service instead
of finding the entry in the root.afs root directory, construct
a name array in AFSParseName() that includes the AFSGlobalRoot
above the resolved share root directory.

In AFSBackupEntry, check for the case where two volume root entries
appear in sequence without an intervening mount point.

Change-Id: Ied0e0dc8226b0460d85a1f3a8b389294cfdef34b
Reviewed-on: http://gerrit.openafs.org/7252
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

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

index d38387c..7e1e96f 100644 (file)
@@ -5403,19 +5403,25 @@ AFSBackupEntry( IN AFSNameArrayHdr *NameArray)
                           pCurrentElement->FileId.Unique,
                           &pCurrentElement->DirectoryCB->NameInformation.FileName,
                           pCurrentElement->DirectoryCB->ObjectInformation->FileType);
-        }
 
-        //
-        // If the entry we are removing is a volume root,
-        // we must remove the mount point entry as well.
-        //
+            //
+            // If the entry we are removing is a volume root,
+            // we must remove the mount point entry as well.
+            // If the NameArray was constructed by checking the
+            // share name via the service, the name array can
+            // contain two volume roots in sequence without a
+            // mount point separating them.
+            //
 
-        if ( bVolumeRoot)
-        {
+            if ( bVolumeRoot &&
+                 !BooleanFlagOn( NameArray->CurrentEntry->Flags, AFS_NAME_ARRAY_FLAG_ROOT_ELEMENT))
+            {
 
-            pDirectoryCB = AFSBackupEntry( NameArray);
+                pDirectoryCB = AFSBackupEntry( NameArray);
+            }
         }
 
+
 try_exit:
 
         NOTHING;
index 1610e91..743c3c5 100644 (file)
@@ -3543,6 +3543,7 @@ AFSParseName( IN PIRP Irp,
             AFSReleaseResource( AFSGlobalRoot->ObjectInformation.Specific.Directory.DirectoryNodeHdr.TreeLock);
         }
 
+
         //
         // Be sure we are starting from the correct volume
         //
@@ -3558,6 +3559,38 @@ AFSParseName( IN PIRP Irp,
             pVolumeCB = pDirEntry->ObjectInformation->VolumeCB;
 
             //
+            // Init our name array
+            //
+
+            pNameArray = AFSInitNameArray( AFSGlobalRoot->DirectoryCB,
+                                           0);
+
+            if( pNameArray == NULL)
+            {
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSParseName (%08lX) Failed to initialize name array\n",
+                              Irp);
+
+                try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+            }
+
+            ntStatus = AFSInsertNextElement( pNameArray,
+                                             pVolumeCB->DirectoryCB);
+
+            if ( ntStatus)
+            {
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSParseName (%08lX) Failed to insert name array element\n",
+                              Irp);
+
+                try_return( ntStatus);
+            }
+
+            //
             // In this case don't add back in the 'share' name since that is where we are
             // starting. Just put the leading slash back in
             //
@@ -3607,6 +3640,23 @@ AFSParseName( IN PIRP Irp,
             pVolumeCB = AFSGlobalRoot;
 
             //
+            // Init our name array
+            //
+
+            pNameArray = AFSInitNameArray( AFSGlobalRoot->DirectoryCB,
+                                           0);
+            if( pNameArray == NULL)
+            {
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSParseName (%08lX) Failed to initialize name array\n",
+                              Irp);
+
+                try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
+            }
+
+            //
             // Add back in the 'share' portion of the name since we will parse it out on return
             //
 
@@ -3664,24 +3714,7 @@ AFSParseName( IN PIRP Irp,
             //
 
             *ParentDirectoryCB = pVolumeCB->DirectoryCB;
-        }
-
-        //
-        // Init our name array
-        //
-
-        pNameArray = AFSInitNameArray( pVolumeCB->DirectoryCB,
-                                       0);
-
-        if( pNameArray == NULL)
-        {
-
-            AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
-                          AFS_TRACE_LEVEL_VERBOSE,
-                          "AFSParseName (%08lX) Failed to initialize name array\n",
-                          Irp);
 
-            try_return( ntStatus = STATUS_INSUFFICIENT_RESOURCES);
         }
 
         //