Windows: EvalByName pass LastComponent flag
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 19 Feb 2013 04:11:27 +0000 (23:11 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 23 Feb 2013 08:20:52 +0000 (00:20 -0800)
Add AFS_REQUEST_FLAG_LAST_COMPONENT flag for use with
AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME requests to the service.
When set the service will perform cm_Lookup calls without the
CM_FLAG_CHECKPATH flag set.

Change-Id: I47ec2fb8b1e2699f2d87a6625b1db549ecb4e03d
Reviewed-on: http://gerrit.openafs.org/9133
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/common/AFSUserDefines.h
src/WINNT/afsrdr/kernel/lib/AFSCommSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSNameSupport.cpp
src/WINNT/afsrdr/kernel/lib/AFSNetworkProviderSupport.cpp
src/WINNT/afsrdr/kernel/lib/Include/AFSCommon.h
src/WINNT/afsrdr/user/RDRFunction.c
src/WINNT/afsrdr/user/RDRInit.cpp
src/WINNT/afsrdr/user/RDRPrototypes.h

index 8fccecc..c2ca477 100644 (file)
 #define AFS_REQUEST_LOCAL_SYSTEM_PAG             0x00000200 // Indicates that the caller is or was at some point a system
                                                             // process
 
+#define AFS_REQUEST_FLAG_LAST_COMPONENT          0x00000800 // During an AFS_REQUEST_TYPE_TARGET_BY_NAME the provided name
+                                                            // is the last component in the path.
+
 //
 // Request Flags, these are passed down from the sevice
 //
index 705c2df..b005aa6 100644 (file)
@@ -2938,6 +2938,7 @@ NTSTATUS
 AFSEvaluateTargetByName( IN GUID *AuthGroup,
                          IN AFSObjectInfoCB *ParentObjectInfo,
                          IN PUNICODE_STRING SourceName,
+                         IN ULONG Flags,
                          OUT AFSDirEnumEntry **DirEnumEntry)
 {
 
@@ -2973,7 +2974,7 @@ AFSEvaluateTargetByName( IN GUID *AuthGroup,
         ulResultBufferLength = PAGE_SIZE;
 
         ntStatus = AFSProcessRequest( AFS_REQUEST_TYPE_EVAL_TARGET_BY_NAME,
-                                      AFS_REQUEST_FLAG_SYNCHRONOUS,
+                                      AFS_REQUEST_FLAG_SYNCHRONOUS | Flags,
                                       AuthGroup,
                                       SourceName,
                                       NULL,
index 5f962a3..24e9357 100644 (file)
@@ -4125,6 +4125,7 @@ AFSCheckCellName( IN GUID *AuthGroup,
         ntStatus = AFSEvaluateTargetByName( AuthGroup,
                                             &AFSGlobalRoot->ObjectInformation,
                                             CellName,
+                                            0,
                                             &pDirEnumEntry);
 
         if( !NT_SUCCESS( ntStatus))
index 5918a2c..872e2ba 100644 (file)
@@ -1689,6 +1689,7 @@ AFSGetConnectionInfo( IN AFSNetworkProviderConnectionCB *ConnectCB,
             ntStatus = AFSEvaluateTargetByName( NULL,
                                                 &AFSGlobalRoot->ObjectInformation,
                                                 &uniShareName,
+                                                0,
                                                 &pDirEnumEntry);
 
             if( !NT_SUCCESS( ntStatus))
index ad65527..5073563 100644 (file)
@@ -222,6 +222,7 @@ NTSTATUS
 AFSEvaluateTargetByName( IN GUID *AuthGroup,
                          IN AFSObjectInfoCB *ParentObjectInfo,
                          IN PUNICODE_STRING SourceName,
+                         IN ULONG Flags,
                          OUT AFSDirEnumEntry **DirEnumEntry);
 
 NTSTATUS
index 34dcef2..36894c1 100644 (file)
@@ -988,6 +988,7 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
                         IN WCHAR   *FileNameCounted,
                         IN DWORD    FileNameLength,
                         IN BOOL     CaseSensitive,
+                        IN BOOL     LastComponent,
                         IN BOOL     bWow64,
                         IN BOOL     bHoldFid,
                         IN BOOL     bNoFollow,
@@ -1008,6 +1009,7 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
     size_t        cbName;
     BOOL          bVol = FALSE;
     wchar_t       FileName[260];
+    afs_uint32    lookupFlags;
 
     StringCchCopyNW(FileName, 260, FileNameCounted, FileNameLength / sizeof(WCHAR));
 
@@ -1092,14 +1094,16 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
         return;
     }
 
-    code = cm_Lookup(dscp, wszName, CM_FLAG_CHECKPATH | CM_FLAG_NOMOUNTCHASE,
-                     userp, &req, &scp);
+    lookupFlags = CM_FLAG_NOMOUNTCHASE;
+
+    if ( !LastComponent )
+        lookupFlags |= CM_FLAG_CHECKPATH;
+    code = cm_Lookup(dscp, wszName, lookupFlags, userp, &req, &scp);
 
     if (!CaseSensitive &&
         (code == CM_ERROR_NOSUCHPATH || code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH)) {
-        code = cm_Lookup(dscp, wszName,
-                         CM_FLAG_CHECKPATH | CM_FLAG_NOMOUNTCHASE | CM_FLAG_CASEFOLD,
-                         userp, &req, &scp);
+        lookupFlags |= CM_FLAG_CASEFOLD;
+        code = cm_Lookup(dscp, wszName, lookupFlags, userp, &req, &scp);
     }
 
     if ((code == CM_ERROR_NOSUCHPATH || code == CM_ERROR_NOSUCHFILE || code == CM_ERROR_BPLUS_NOMATCH) &&
index 05f8bac..d38508f 100644 (file)
@@ -624,6 +624,7 @@ RDR_ProcessRequest( AFSCommRequest *RequestBuffer)
                                     RequestBuffer->Name,
                                     RequestBuffer->NameLength,
                                     RequestBuffer->RequestFlags & AFS_REQUEST_FLAG_CASE_SENSITIVE ? TRUE : FALSE,
+                                    RequestBuffer->RequestFlags & AFS_REQUEST_FLAG_LAST_COMPONENT ? TRUE : FALSE,
                                     bWow64, bFast, bHoldFid,
                                     RequestBuffer->ResultBufferLength,
                                     &pResultCB);
index 336cbac..e70213c 100644 (file)
@@ -77,6 +77,7 @@ RDR_EvaluateNodeByName( IN cm_user_t *userp,
                         IN WCHAR     *Name,
                         IN DWORD     NameLength,
                         IN BOOL      CaseSensitive,
+                        IN BOOL      LastComponent,
                         IN BOOL      bWow64,
                         IN BOOL      bQueryStatus,
                         IN BOOL      bHoldFid,