- diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
- index 2da4efa..5a1a357 100644
- --- a/build.vc19/libtirpc/libtirpc.vcxproj
- +++ b/build.vc19/libtirpc/libtirpc.vcxproj
- @@ -135,6 +135,7 @@
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- @@ -158,6 +159,7 @@
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
- @@ -206,6 +208,7 @@
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -231,6 +234,7 @@
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>ws2_32.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <ModuleDefinitionFile>..\..\libtirpc\libtirpc\libtirpc.def</ModuleDefinitionFile>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
- index 43d07f7..50712bc 100644
- --- a/build.vc19/nfsd/nfsd.vcxproj
- +++ b/build.vc19/nfsd/nfsd.vcxproj
- @@ -1,20 +1,10 @@
- <?xml version="1.0" encoding="utf-8"?>
- <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Target Name="generate_git_version_header" BeforeTargets="ClCompile">
- - <Exec
- - Command="git describe --long --always --dirty --exclude=* --abbrev=8"
- - ConsoleToMSBuild="True"
- - IgnoreExitCode="False">
- + <Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
- <Output TaskParameter="ConsoleOutput" PropertyName="git_version_string" />
- </Exec>
- -
- - <WriteLinesToFile
- - File="$(IntermediateOutputPath)/git_version.h"
- - Overwrite="True"
- - Lines="
- -/* Generated file, do not edit */
- -#define GIT_COMMIT_ID "$(git_version_string)"
- -" />
- + <WriteLinesToFile File="$(IntermediateOutputPath)/git_version.h" Overwrite="True" Lines="
/* Generated file, do not edit */
#define GIT_COMMIT_ID "$(git_version_string)"
" />
- </Target>
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- @@ -150,6 +140,7 @@
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- @@ -172,6 +163,7 @@
- <SubSystem>Console</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
- @@ -218,6 +210,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- @@ -242,6 +235,7 @@
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>iphlpapi.lib;ws2_32.lib;wldap32.lib;ntdll.lib;..\$(Platform)\$(Configuration)\libtirpc.lib;%(AdditionalDependencies)</AdditionalDependencies>
- + <RandomizedBaseAddress>false</RandomizedBaseAddress>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- diff --git a/daemon/callback_server.c b/daemon/callback_server.c
- index dc3139a..9b782c1 100644
- --- a/daemon/callback_server.c
- +++ b/daemon/callback_server.c
- @@ -387,9 +387,10 @@ static void handle_cb_compound(nfs41_rpc_clnt *rpc_clnt, cb_req *req, struct cb_
- }
- DPRINTF(CBSLVL, ("CB_COMPOUND('%s', %u)\n", args.tag.str, args.argarray_count));
- - if (args.minorversion != 1) {
- + if ((args.minorversion != 1) && (args.minorversion != 2)) {
- res->status = NFS4ERR_MINOR_VERS_MISMATCH; //XXXXX
- - eprintf("args.minorversion %u != 1\n", args.minorversion);
- + eprintf("handle_cb_compound: args.minorversion %u != 1/2\n",
- + (unsigned int)args.minorversion);
- goto out;
- }
- diff --git a/daemon/lookup.c b/daemon/lookup.c
- index ee883b9..085bc35 100644
- --- a/daemon/lookup.c
- +++ b/daemon/lookup.c
- @@ -135,7 +135,8 @@ static int lookup_rpc(
- nfs_argop4 argops[4+MAX_LOOKUP_COMPONENTS*3];
- nfs_resop4 resops[4+MAX_LOOKUP_COMPONENTS*3];
- - compound_init(&compound, argops, resops, "lookup");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "lookup");
- compound_add_op(&compound, OP_SEQUENCE, &args->sequence, &res->sequence);
- nfs41_session_sequence(&args->sequence, session, 0);
- diff --git a/daemon/mount.c b/daemon/mount.c
- index 63c5e1f..be8854f 100644
- --- a/daemon/mount.c
- +++ b/daemon/mount.c
- @@ -52,11 +52,15 @@ static int parse_mount(unsigned char *buffer, uint32_t length, nfs41_upcall *upc
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->use_nfspubfh, sizeof(DWORD));
- if (status) goto out;
- + status = safe_read(&buffer, &length, &args->nfsvers, sizeof(DWORD));
- + if (status) goto out;
- DPRINTF(1, ("parsing NFS41_SYSOP_MOUNT: hostport='%s' root='%s' "
- - "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d\n",
- + "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d "
- + "nfsvers=%d\n",
- args->hostport, args->path, secflavorop2name(args->sec_flavor),
- - args->rsize, args->wsize, args->use_nfspubfh));
- + args->rsize, args->wsize, args->use_nfspubfh,
- + args->nfsvers));
- return status;
- out:
- DPRINTF(1, ("parsing NFS41_SYSOP_MOUNT: failed %d\n", status));
- @@ -148,7 +152,9 @@ static int handle_mount(void *daemon_context, nfs41_upcall *upcall)
- } else {
- // create root
- status = nfs41_root_create(hostname, port,
- - args->use_nfspubfh?true:false, args->sec_flavor,
- + args->use_nfspubfh?true:false,
- + args->nfsvers,
- + args->sec_flavor,
- args->wsize + WRITE_OVERHEAD, args->rsize + READ_OVERHEAD, &root);
- if (status) {
- eprintf("nfs41_root_create(hostname='%s', port=%d) failed %d\n",
- diff --git a/daemon/name_cache.c b/daemon/name_cache.c
- index a5e5a1e..1925304 100644
- --- a/daemon/name_cache.c
- +++ b/daemon/name_cache.c
- @@ -1356,7 +1356,8 @@ static int rpc_array_putfh(
- *valid_out = 0;
- - compound_init(&compound, argops, resops, "array_putfh");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "array_putfh");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- diff --git a/daemon/namespace.c b/daemon/namespace.c
- index e0faf23..8bfba37 100644
- --- a/daemon/namespace.c
- +++ b/daemon/namespace.c
- @@ -26,6 +26,9 @@
- #include "nfs41_ops.h"
- #include "util.h"
- #include "daemon_debug.h"
- +/* for |ERROR_NFS_VERSION_MISMATCH|+|NFS_VERSION_AUTONEGOTIATION| */
- +#include "nfs41_driver.h"
- +
- #define NSLVL 2 /* dprintf level for namespace logging */
- @@ -39,6 +42,7 @@ int nfs41_root_create(
- IN const char *name,
- IN uint32_t port,
- IN bool use_nfspubfh,
- + IN DWORD nfsvers,
- IN uint32_t sec_flavor,
- IN uint32_t wsize,
- IN uint32_t rsize,
- @@ -47,7 +51,10 @@ int nfs41_root_create(
- int status = NO_ERROR;
- nfs41_root *root;
- - DPRINTF(NSLVL, ("--> nfs41_root_create(name='%s', port=%d)\n", name, port));
- + DPRINTF(NSLVL,
- + ("--> nfs41_root_create(name='%s', port=%d, "
- + "use_nfspubfh=%d, nfsvers=%d)\n",
- + name, port, (int)use_nfspubfh, (int)nfsvers));
- root = calloc(1, sizeof(nfs41_root));
- if (root == NULL) {
- @@ -57,6 +64,17 @@ int nfs41_root_create(
- list_init(&root->clients);
- root->use_nfspubfh = use_nfspubfh;
- + if (nfsvers == NFS_VERSION_AUTONEGOTIATION) {
- + /*
- + * Use auto negotiation, |nfs41_root_mount_addrs()| will
- + * set |root->nfsminorvers| to the minor version being used
- + */
- + root->nfsminorvers = NFS_VERSION_AUTONEGOTIATION;
- + }
- + else {
- + root->nfsminorvers = nfsvers % 10; /* 41 --> 1, 42 --> 2, ... */
- + EASSERT((root->nfsminorvers >= 1) && (root->nfsminorvers <= 2));
- + }
- root->wsize = wsize;
- root->rsize = rsize;
- InitializeCriticalSection(&root->lock);
- @@ -64,7 +82,8 @@ int nfs41_root_create(
- root->sec_flavor = sec_flavor;
- /* generate a unique client_owner */
- - status = nfs41_client_owner(name, port, use_nfspubfh, sec_flavor, &root->client_owner);
- + status = nfs41_client_owner(name, port, root->nfsminorvers,
- + use_nfspubfh, sec_flavor, &root->client_owner);
- if (status) {
- eprintf("nfs41_client_owner() failed with %d\n", status);
- free(root);
- @@ -368,12 +387,49 @@ int nfs41_root_mount_addrs(
- goto out;
- }
- + bool nfsminorvers_autonegotiate = false;
- +
- + /*
- + * NFSv4 protocol minor version "autonegotiation"
- + * First try with 4.2, and if this fails try 4.1
- + */
- + if (root->nfsminorvers == NFS_VERSION_AUTONEGOTIATION) {
- + root->nfsminorvers = 3;
- + nfsminorvers_autonegotiate = true;
- + }
- +
- +retry_nfs41_exchange_id:
- + if (nfsminorvers_autonegotiate) {
- + DPRINTF(0, ("nfs41_root_mount_addrs: "
- + "Autonegotiating NFS version, "
- + "trying NFSv4.%d\n",
- + (int)root->nfsminorvers));
- + }
- +
- /* get a clientid with exchangeid */
- - status = nfs41_exchange_id(rpc, &root->client_owner,
- + status = nfs41_exchange_id(rpc, root->nfsminorvers,
- + &root->client_owner,
- nfs41_exchange_id_flags(is_data), &exchangeid);
- if (status) {
- - eprintf("nfs41_exchange_id() failed '%s'\n", nfs_error_string(status));
- + if (status == NFS4ERR_MINOR_VERS_MISMATCH) {
- + if (nfsminorvers_autonegotiate &&
- + (root->nfsminorvers >= 1)) {
- + root->nfsminorvers--;
- + goto retry_nfs41_exchange_id;
- + }
- +
- + eprintf("nfs41_root_mount_addrs: "
- + "nfs41_exchange_id() NFS4ERR_MINOR_VERS_MISMATCH,"
- + "nfsminorvers=%d failed\n",
- + (int)root->nfsminorvers);
- + status = ERROR_NFS_VERSION_MISMATCH;
- + }
- + else {
- + eprintf("nfs41_root_mount_addrs: "
- + "nfs41_exchange_id() failed '%s'\n",
- + nfs_error_string(status));
- status = ERROR_BAD_NET_RESP;
- + }
- goto out_free_rpc;
- }
- diff --git a/daemon/nfs41.h b/daemon/nfs41.h
- index f5607a6..e6e82ad 100644
- --- a/daemon/nfs41.h
- +++ b/daemon/nfs41.h
- @@ -300,6 +300,7 @@ typedef struct __nfs41_root {
- CRITICAL_SECTION lock;
- struct list_entry clients;
- bool use_nfspubfh;
- + DWORD nfsminorvers;
- uint32_t wsize;
- uint32_t rsize;
- #pragma warning( push )
- @@ -318,6 +319,7 @@ int nfs41_root_create(
- IN const char *name,
- IN uint32_t port,
- IN bool use_nfspubfh,
- + IN DWORD nfsvers,
- IN uint32_t sec_flavor,
- IN uint32_t wsize,
- IN uint32_t rsize,
- @@ -436,6 +438,7 @@ void nfs41_server_addrs(
- int nfs41_client_owner(
- IN const char *name,
- IN uint32_t port,
- + IN int nfsminorvers,
- IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- OUT client_owner4 *owner);
- diff --git a/daemon/nfs41_client.c b/daemon/nfs41_client.c
- index aa2cc25..b33a22d 100644
- --- a/daemon/nfs41_client.c
- +++ b/daemon/nfs41_client.c
- @@ -174,7 +174,8 @@ int nfs41_client_renew(
- nfs41_exchange_id_res exchangeid = { 0 };
- int status;
- - status = nfs41_exchange_id(client->rpc, &client->owner,
- + status = nfs41_exchange_id(client->rpc,
- + client->root->nfsminorvers, &client->owner,
- nfs41_exchange_id_flags(client->is_data), &exchangeid);
- if (status) {
- eprintf("nfs41_exchange_id() failed with %d\n", status);
- @@ -362,6 +363,7 @@ out:
- int nfs41_client_owner(
- IN const char *name,
- IN uint32_t port,
- + IN int nfsminorvers,
- IN bool use_nfspubfh,
- IN uint32_t sec_flavor,
- OUT client_owner4 *owner)
- @@ -421,6 +423,13 @@ int nfs41_client_owner(
- goto out_context;
- }
- + if (!CryptHashData(hash,
- + (const BYTE*)&nfsminorvers, (DWORD)sizeof(int), 0)) {
- + status = GetLastError();
- + eprintf("CryptHashData() failed with %d\n", status);
- + goto out_hash;
- + }
- +
- if (!CryptHashData(hash,
- (const BYTE*)&use_nfspubfh, (DWORD)sizeof(bool), 0)) {
- status = GetLastError();
- diff --git a/daemon/nfs41_compound.c b/daemon/nfs41_compound.c
- index 08faf55..669ae04 100644
- --- a/daemon/nfs41_compound.c
- +++ b/daemon/nfs41_compound.c
- @@ -40,6 +40,7 @@ int compound_error(int status)
- void compound_init(
- nfs41_compound *compound,
- + int minorversion,
- nfs_argop4 *argops,
- nfs_resop4 *resops,
- const char *tag)
- @@ -47,7 +48,7 @@ void compound_init(
- /* initialize args */
- compound->args.tag_len = (uint32_t)strlen(tag);
- memcpy(compound->args.tag, tag, compound->args.tag_len);
- - compound->args.minorversion = 1;
- + compound->args.minorversion = minorversion;
- compound->args.argarray_count = 0;
- compound->args.argarray = argops;
- diff --git a/daemon/nfs41_compound.h b/daemon/nfs41_compound.h
- index d222559..9b09eba 100644
- --- a/daemon/nfs41_compound.h
- +++ b/daemon/nfs41_compound.h
- @@ -62,6 +62,7 @@ int compound_error(int status);
- void compound_init(
- nfs41_compound *compound,
- + int minorversion,
- nfs_argop4 *argops,
- nfs_resop4 *resops,
- const char *tag);
- diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c
- index 5e28c09..62a6bad 100644
- --- a/daemon/nfs41_ops.c
- +++ b/daemon/nfs41_ops.c
- @@ -50,6 +50,7 @@
- int nfs41_exchange_id(
- IN nfs41_rpc_clnt *rpc,
- + IN int nfsminorvers,
- IN client_owner4 *owner,
- IN uint32_t flags_in,
- OUT nfs41_exchange_id_res *res_out)
- @@ -64,7 +65,8 @@ int nfs41_exchange_id(
- /* fixme: This should be a function argument */
- extern nfs41_daemon_globals nfs41_dg;
- - compound_init(&compound, &argop, &resop, "exchange_id");
- + compound_init(&compound, nfsminorvers,
- + &argop, &resop, "exchange_id");
- compound_add_op(&compound, OP_EXCHANGE_ID, &ex_id, res_out);
- @@ -142,7 +144,8 @@ int nfs41_create_session(nfs41_client *clnt, nfs41_session *session, bool_t try_
- DPRINTF(1, ("--> nfs41_create_session(clnt=0x%p,session=0x%p,try_recovery=%d)\n",
- clnt, session, (int)try_recovery));
- - compound_init(&compound, &argop, &resop, "create_session");
- + compound_init(&compound, clnt->root->nfsminorvers,
- + &argop, &resop, "create_session");
- compound_add_op(&compound, OP_CREATE_SESSION, &req, &reply);
- @@ -256,7 +259,8 @@ enum nfsstat4 nfs41_bind_conn_to_session(
- nfs41_bind_conn_to_session_args bind_args = { 0 };
- nfs41_bind_conn_to_session_res bind_res = { 0 };
- - compound_init(&compound, &argop, &resop, "bind_conn_to_session");
- + compound_init(&compound, rpc->client->root->nfsminorvers,
- + &argop, &resop, "bind_conn_to_session");
- compound_add_op(&compound, OP_BIND_CONN_TO_SESSION, &bind_args, &bind_res);
- bind_args.sessionid = (unsigned char *)sessionid;
- @@ -283,7 +287,8 @@ int nfs41_destroy_session(
- nfs41_destroy_session_args ds_args;
- nfs41_destroy_session_res ds_res;
- - compound_init(&compound, &argop, &resop, "destroy_session");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + &argop, &resop, "destroy_session");
- compound_add_op(&compound, OP_DESTROY_SESSION, &ds_args, &ds_res);
- ds_args.dsa_sessionid = session->session_id;
- @@ -312,7 +317,8 @@ int nfs41_destroy_clientid(
- nfs41_destroy_clientid_args dc_args;
- nfs41_destroy_clientid_res dc_res;
- - compound_init(&compound, &argops, &resops, "destroy_clientid");
- + compound_init(&compound, rpc->client->root->nfsminorvers,
- + &argops, &resops, "destroy_clientid");
- compound_add_op(&compound, OP_DESTROY_CLIENTID, &dc_args, &dc_res);
- dc_args.dca_clientid = clientid;
- @@ -338,7 +344,8 @@ enum nfsstat4 nfs41_reclaim_complete(
- nfs41_sequence_res sequence_res;
- nfs41_reclaim_complete_res reclaim_res;
- - compound_init(&compound, argops, resops, "reclaim_complete");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "reclaim_complete");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -494,7 +501,8 @@ int nfs41_open(
- attr_request.arr[0] |= FATTR4_WORD0_FSID;
- - compound_init(&compound, argops, resops, "open");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "open");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -621,7 +629,8 @@ int nfs41_create(
- nfs41_superblock_getattr_mask(parent->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops, "create");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "create");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -709,7 +718,8 @@ int nfs41_close(
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops, "close");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "close");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -773,7 +783,8 @@ int nfs41_write(
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops,
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops,
- stateid->stateid.seqid == 0 ? "ds write" : "write");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- @@ -858,7 +869,8 @@ int nfs41_read(
- nfs41_read_args read_args;
- nfs41_read_res read_res;
- - compound_init(&compound, argops, resops,
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops,
- stateid->stateid.seqid == 0 ? "ds read" : "read");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- @@ -920,7 +932,8 @@ int nfs41_commit(
- bitmap4 attr_request;
- nfs41_file_info info, *pinfo;
- - compound_init(&compound, argops, resops,
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops,
- do_getattr ? "commit" : "ds commit");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- @@ -988,7 +1001,8 @@ int nfs41_lock(
- nfs41_lock_args lock_args;
- nfs41_lock_res lock_res;
- - compound_init(&compound, argops, resops, "lock");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "lock");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1046,7 +1060,8 @@ int nfs41_unlock(
- nfs41_locku_args locku_args;
- nfs41_locku_res locku_res;
- - compound_init(&compound, argops, resops, "unlock");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "unlock");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1092,7 +1107,8 @@ int nfs41_readdir(
- nfs41_readdir_args readdir_args;
- nfs41_readdir_res readdir_res;
- - compound_init(&compound, argops, resops, "readdir");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "readdir");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1142,7 +1158,8 @@ int nfs41_getattr(
- nfs41_getattr_args getattr_args;
- nfs41_getattr_res getattr_res NDSH(= { 0 });
- - compound_init(&compound, argops, resops, "getattr");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "getattr");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1202,7 +1219,8 @@ int nfs41_superblock_getattr(
- nfs41_openattr_args openattr_args;
- nfs41_openattr_res openattr_res;
- - compound_init(&compound, argops, resops, "getfsattr");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "getfsattr");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1269,7 +1287,8 @@ int nfs41_remove(
- nfs41_superblock_getattr_mask(parent->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops, "remove");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "remove");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -1340,7 +1359,8 @@ int nfs41_rename(
- nfs41_superblock_getattr_mask(src_dir->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops, "rename");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "rename");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -1434,7 +1454,8 @@ int nfs41_setattr(
- nfs41_getattr_res getattr_res NDSH(= { 0 });
- bitmap4 attr_request;
- - compound_init(&compound, argops, resops, "setattr");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "setattr");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1530,7 +1551,8 @@ int nfs41_link(
- nfs41_superblock_getattr_mask(dst_dir->fh.superblock, &cinfo->attrmask);
- cinfo->attrmask.arr[0] |= FATTR4_WORD0_FSID;
- - compound_init(&compound, argops, resops, "link");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "link");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 1);
- @@ -1619,7 +1641,8 @@ int nfs41_readlink(
- nfs41_putfh_res putfh_res;
- nfs41_readlink_res readlink_res;
- - compound_init(&compound, argops, resops, "readlink");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "readlink");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1663,7 +1686,8 @@ int nfs41_access(
- nfs41_access_args access_args;
- nfs41_access_res access_res;
- - compound_init(&compound, argops, resops, "access");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "access");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1700,7 +1724,8 @@ int nfs41_send_sequence(
- nfs41_sequence_args sequence_args;
- nfs41_sequence_res sequence_res;
- - compound_init(&compound, argops, resops, "sequence");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "sequence");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1734,7 +1759,8 @@ enum nfsstat4 nfs41_want_delegation(
- nfs41_want_delegation_args wd_args;
- nfs41_want_delegation_res wd_res;
- - compound_init(&compound, argops, resops, "want_delegation");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "want_delegation");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1768,7 +1794,8 @@ int nfs41_delegpurge(
- nfs41_sequence_res sequence_res;
- nfs41_delegpurge_res dp_res;
- - compound_init(&compound, argops, resops, "delegpurge");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "delegpurge");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1801,7 +1828,8 @@ int nfs41_delegreturn(
- nfs41_delegreturn_args dr_args;
- nfs41_delegreturn_res dr_res;
- - compound_init(&compound, argops, resops, "delegreturn");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "delegreturn");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1849,7 +1877,8 @@ enum nfsstat4 nfs41_fs_locations(
- bitmap4 attr_request = { .count=1, .arr[0]=FATTR4_WORD0_FS_LOCATIONS };
- nfs41_file_info info;
- - compound_init(&compound, argops, resops, "fs_locations");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "fs_locations");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1893,7 +1922,8 @@ int nfs41_secinfo(
- nfs41_secinfo_args secinfo_args;
- nfs41_secinfo_no_name_res secinfo_res;
- - compound_init(&compound, argops, resops, "secinfo");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "secinfo");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1941,7 +1971,8 @@ int nfs41_secinfo_noname(
- nfs41_secinfo_no_name_args noname_args;
- nfs41_secinfo_no_name_res noname_res;
- - compound_init(&compound, argops, resops, "secinfo_no_name");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "secinfo_no_name");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -1986,7 +2017,8 @@ enum nfsstat4 nfs41_free_stateid(
- nfs41_free_stateid_args freestateid_args;
- nfs41_free_stateid_res freestateid_res;
- - compound_init(&compound, argops, resops, "free_stateid");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "free_stateid");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2018,7 +2050,8 @@ enum nfsstat4 nfs41_test_stateid(
- nfs41_test_stateid_args teststateid_args;
- nfs41_test_stateid_res teststateid_res;
- - compound_init(&compound, argops, resops, "test_stateid");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "test_stateid");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2061,7 +2094,8 @@ enum nfsstat4 pnfs_rpc_layoutget(
- uint32_t i;
- struct list_entry *entry;
- - compound_init(&compound, argops, resops, "layoutget");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "layoutget");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2128,7 +2162,8 @@ enum nfsstat4 pnfs_rpc_layoutcommit(
- nfs41_superblock_getattr_mask(file->fh.superblock, &attr_request);
- - compound_init(&compound, argops, resops, "layoutcommit");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "layoutcommit");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2184,7 +2219,8 @@ enum nfsstat4 pnfs_rpc_layoutreturn(
- nfs41_putfh_res putfh_res;
- pnfs_layoutreturn_args layoutreturn_args;
- - compound_init(&compound, argops, resops, "layoutreturn");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "layoutreturn");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2225,7 +2261,8 @@ enum nfsstat4 pnfs_rpc_getdeviceinfo(
- pnfs_getdeviceinfo_args getdeviceinfo_args;
- pnfs_getdeviceinfo_res getdeviceinfo_res;
- - compound_init(&compound, argops, resops, "get_deviceinfo");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "get_deviceinfo");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- @@ -2265,7 +2302,8 @@ enum nfsstat4 nfs41_rpc_openattr(
- nfs41_openattr_res openattr_res;
- nfs41_getfh_res getfh_res;
- - compound_init(&compound, argops, resops, "openattr");
- + compound_init(&compound, session->client->root->nfsminorvers,
- + argops, resops, "openattr");
- compound_add_op(&compound, OP_SEQUENCE, &sequence_args, &sequence_res);
- nfs41_session_sequence(&sequence_args, session, 0);
- diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h
- index 8ac81a3..d95e6b3 100644
- --- a/daemon/nfs41_ops.h
- +++ b/daemon/nfs41_ops.h
- @@ -1001,6 +1001,7 @@ typedef struct __pnfs_getdeviceinfo_res {
- /* nfs41_ops.c */
- int nfs41_exchange_id(
- IN nfs41_rpc_clnt *rpc,
- + IN int nfsminorvers,
- IN client_owner4 *owner,
- IN uint32_t flags_in,
- OUT nfs41_exchange_id_res *res_out);
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index a02b70a..39b50fb 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -767,6 +767,13 @@ fetch_entries:
- nfs41_readdir_entry *entry = (nfs41_readdir_entry*)entry_buf;
- entry->cookie = 0;
- entry->name_len = (uint32_t)strlen(args->filter) + 1;
- + if (entry->name_len >= NFS41_MAX_COMPONENT_LEN) {
- + DPRINTF(1,
- + ("entry->name_len(=%d) >= NFS41_MAX_COMPONENT_LEN\n",
- + (int)entry->name_len));
- + status = ERROR_FILENAME_EXCED_RANGE;
- + goto out_free_cookie;
- + }
- StringCbCopyA(entry->name, entry->name_len, args->filter);
- entry->next_entry_offset = 0;
- diff --git a/daemon/upcall.h b/daemon/upcall.h
- index f6ac12d..5f44ede 100644
- --- a/daemon/upcall.h
- +++ b/daemon/upcall.h
- @@ -37,6 +37,7 @@ typedef struct __mount_upcall_args {
- DWORD rsize;
- DWORD wsize;
- DWORD use_nfspubfh;
- + DWORD nfsvers;
- DWORD lease_time;
- FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
- } mount_upcall_args;
- diff --git a/mount/mount.c b/mount/mount.c
- index c9b5637..2ebf8e5 100644
- --- a/mount/mount.c
- +++ b/mount/mount.c
- @@ -129,6 +129,9 @@ void PrintMountUsage(LPWSTR pProcess)
- "\tro\tmount as read-only\n"
- "\trw\tmount as read-write (default)\n"
- "\tport=#\tTCP port to use (defaults to 2049)\n"
- + "\tvers=#\tNFS protocol version, either 4.1 or 4.2\n"
- + "\t\tIf this option is not specified, the client negotiates a\n"
- + "\t\tsuitable version with the server, trying version 4.2 and then 4.1\n"
- "\trsize=#\tread buffer size in bytes\n"
- "\twsize=#\twrite buffer size in bytes\n"
- "\tsec=sys:krb5:krb5i:krb5p\tspecify (gss) security flavor\n"
- diff --git a/sys/nfs41_driver.h b/sys/nfs41_driver.h
- index c08e8fb..7d933f0 100644
- --- a/sys/nfs41_driver.h
- +++ b/sys/nfs41_driver.h
- @@ -104,4 +104,12 @@ typedef enum _nfs41_start_driver_state {
- NFS41_START_DRIVER_STARTED,
- NFS41_START_DRIVER_STOPPED
- } nfs41_start_driver_state;
- +
- +#define NFS_VERSION_AUTONEGOTIATION (0xFFFF)
- +
- +/*
- + * Error/Status codes
- + */
- +#define ERROR_NFS_VERSION_MISMATCH ERROR_REMOTE_FILE_VERSION_MISMATCH
- +#define STATUS_NFS_VERSION_MISMATCH STATUS_REMOTE_FILE_VERSION_MISMATCH
- #endif
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 0e0107c..79ef82c 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -208,6 +208,7 @@ typedef struct _updowncall_entry {
- DWORD wsize;
- DWORD lease_time;
- DWORD use_nfspubfh;
- + DWORD nfsvers;
- } Mount;
- struct {
- PMDL MdlAddress;
- @@ -308,6 +309,7 @@ typedef struct _NFS41_MOUNT_CREATEMODE {
- typedef struct _NFS41_MOUNT_CONFIG {
- BOOLEAN use_nfspubfh;
- + DWORD nfsvers;
- DWORD ReadSize;
- DWORD WriteSize;
- BOOLEAN ReadOnly;
- @@ -415,6 +417,7 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION {
- NFS41_MOUNT_CREATEMODE dir_createmode;
- NFS41_MOUNT_CREATEMODE file_createmode;
- USHORT MountPathLen;
- + DWORD nfsvers;
- BOOLEAN read_only;
- BOOLEAN write_thru;
- BOOLEAN nocache;
- diff --git a/sys/nfs41sys_mount.c b/sys/nfs41sys_mount.c
- index 8cc45f4..93a6d34 100644
- --- a/sys/nfs41sys_mount.c
- +++ b/sys/nfs41sys_mount.c
- @@ -112,7 +112,7 @@ NTSTATUS marshal_nfs41_mount(
- goto out;
- }
- header_len = *len + length_as_utf8(entry->u.Mount.srv_name) +
- - length_as_utf8(entry->u.Mount.root) + 4 * sizeof(DWORD);
- + length_as_utf8(entry->u.Mount.root) + 5 * sizeof(DWORD);
- if (header_len > buf_len) {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto out;
- @@ -128,16 +128,20 @@ NTSTATUS marshal_nfs41_mount(
- RtlCopyMemory(tmp, &entry->u.Mount.wsize, sizeof(DWORD));
- tmp += sizeof(DWORD);
- RtlCopyMemory(tmp, &entry->u.Mount.use_nfspubfh, sizeof(DWORD));
- + tmp += sizeof(DWORD);
- + RtlCopyMemory(tmp, &entry->u.Mount.nfsvers, sizeof(DWORD));
- *len = header_len;
- #ifdef DEBUG_MARSHAL_DETAIL
- DbgP("marshal_nfs41_mount: server name='%wZ' mount point='%wZ' "
- - "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d\n",
- + "sec_flavor='%s' rsize=%d wsize=%d use_nfspubfh=%d "
- + "nfsvers=%d\n",
- entry->u.Mount.srv_name, entry->u.Mount.root,
- secflavorop2name(entry->u.Mount.sec_flavor),
- (int)entry->u.Mount.rsize, (int)entry->u.Mount.wsize,
- - (int)entry->u.Mount.use_nfspubfh);
- + (int)entry->u.Mount.use_nfspubfh,
- + (int)entry->u.Mount.nfsvers);
- #endif
- out:
- return status;
- @@ -227,6 +231,7 @@ NTSTATUS map_mount_errors(
- case ERROR_BAD_NET_NAME: return STATUS_BAD_NETWORK_NAME;
- case ERROR_BAD_NETPATH: return STATUS_BAD_NETWORK_PATH;
- case ERROR_NOT_SUPPORTED: return STATUS_NOT_SUPPORTED;
- + case ERROR_NFS_VERSION_MISMATCH: return STATUS_NFS_VERSION_MISMATCH;
- case ERROR_INTERNAL_ERROR: return STATUS_INTERNAL_ERROR;
- default:
- print_error("map_mount_errors: "
- @@ -261,6 +266,7 @@ NTSTATUS nfs41_mount(
- entry->u.Mount.rsize = config->ReadSize;
- entry->u.Mount.wsize = config->WriteSize;
- entry->u.Mount.use_nfspubfh = config->use_nfspubfh;
- + entry->u.Mount.nfsvers = config->nfsvers;
- entry->u.Mount.sec_flavor = sec_flavor;
- entry->u.Mount.FsAttrs = FsAttrs;
- @@ -295,6 +301,7 @@ void nfs41_MountConfig_InitDefaults(
- Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
- Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
- Config->use_nfspubfh = FALSE;
- + Config->nfsvers = NFS_VERSION_AUTONEGOTIATION;
- Config->ReadOnly = FALSE;
- Config->write_thru = FALSE;
- Config->nocache = FALSE;
- @@ -484,6 +491,16 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
- &Config->WriteSize, MOUNT_CONFIG_RW_SIZE_MIN,
- MOUNT_CONFIG_RW_SIZE_MAX);
- }
- + else if (wcsncmp(L"vers", Name, NameLen) == 0) {
- + if (wcsncmp(L"4.2", usValue.Buffer, usValue.Length) == 0)
- + Config->nfsvers = 42;
- + else if (wcsncmp(L"4.1", usValue.Buffer, usValue.Length) == 0)
- + Config->nfsvers = 41;
- + else {
- + status = STATUS_INVALID_PARAMETER;
- + print_error("Invalid vers= string\n");
- + }
- + }
- else if (wcsncmp(L"public", Name, NameLen) == 0) {
- /*
- + We ignore this value here, and instead rely on the
- @@ -874,6 +891,8 @@ NTSTATUS nfs41_CreateVNetRoot(
- DbgP("nfs41_MountConfig_ParseOptions() failed\n");
- goto out_free;
- }
- +
- + pVNetRootContext->nfsvers = Config->nfsvers;
- pVNetRootContext->read_only = Config->ReadOnly;
- pVNetRootContext->write_thru = Config->write_thru;
- pVNetRootContext->nocache = Config->nocache;
- @@ -996,6 +1015,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- goto out_free;
- }
- + pVNetRootContext->nfsvers = Config->nfsvers;
- pVNetRootContext->read_only = Config->ReadOnly;
- pVNetRootContext->write_thru = Config->write_thru;
- pVNetRootContext->nocache = Config->nocache;
- @@ -1008,6 +1028,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- "MntPt='%wZ', "
- "SrvName='%wZ', "
- "usenfspubfh=%d, "
- + "nfsvers=%d, "
- "ro=%d, "
- "writethru=%d, "
- "nocache=%d "
- @@ -1019,6 +1040,7 @@ NTSTATUS nfs41_CreateVNetRoot(
- &Config->MntPt,
- &Config->SrvName,
- Config->use_nfspubfh?1:0,
- + (int)Config->nfsvers,
- Config->ReadOnly?1:0,
- Config->write_thru?1:0,
- Config->nocache?1:0,
NFSv4.2+misc prototype, backup 2025-01-06
Posted by Anonymous on Mon 6th Jan 2025 17:56
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.