From 2e10b99489ca7fd425baff9101035f2b9f894589 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 3 May 2012 12:44:19 -0400 Subject: [PATCH] driver: fix for is_root_directory() is_root_directory() was failing to take mount paths into account, causing it to ignore the cached volume attributes and make unnecessary upcalls when a mount path was specified because the mount path is only available during nfs41_CreateVNetRoot(), its length is now saved in the new field NFS41_V_NET_ROOT_EXTENSION.MountPathLen for use in is_root_directory() Signed-off-by: Casey Bodley --- sys/nfs41_driver.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/nfs41_driver.c b/sys/nfs41_driver.c index 2ec6c12..d35f055 100644 --- a/sys/nfs41_driver.c +++ b/sys/nfs41_driver.c @@ -387,6 +387,7 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION { FILE_FS_ATTRIBUTE_INFORMATION FsAttrs; DWORD sec_flavor; DWORD timeout; + USHORT MountPathLen; BOOLEAN read_only; BOOLEAN write_thru; BOOLEAN nocache; @@ -2977,6 +2978,7 @@ NTSTATUS nfs41_CreateVNetRoot( Config->SrvName.MaximumLength = pSrvCall->pSrvCallName->MaximumLength - sizeof(WCHAR); } + pVNetRootContext->MountPathLen = Config->MntPt.Length; pVNetRootContext->timeout = Config->timeout; status = map_sec_flavor(&Config->SecFlavor, &pVNetRootContext->sec_flavor); @@ -4284,10 +4286,15 @@ static BOOLEAN is_root_directory( { __notnull PV_NET_ROOT VNetRoot = (PV_NET_ROOT) RxContext->pRelevantSrvOpen->pVNetRoot; - /* compare the FileObject name with the VNetRoot prefix to determine - * whether it's the root directory (allowing for added \) */ - return RxContext->CurrentIrpSp->FileObject->FileName.Length <= - VNetRoot->PrefixEntry.Prefix.Length + sizeof(WCHAR); + __notnull PNFS41_V_NET_ROOT_EXTENSION pVNetRootContext = + NFS41GetVNetRootExtension(RxContext->pRelevantSrvOpen->pVNetRoot); + + /* calculate the root directory's length, including vnetroot prefix, + * mount path, and a trailing \ */ + const USHORT RootPathLen = VNetRoot->PrefixEntry.Prefix.Length + + pVNetRootContext->MountPathLen + sizeof(WCHAR); + + return RxContext->CurrentIrpSp->FileObject->FileName.Length <= RootPathLen; } NTSTATUS nfs41_QueryVolumeInformation(