diff --git a/daemon/mount.c b/daemon/mount.c index 737669e..73d8b29 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -22,6 +22,7 @@ */ #include +#include #include #include "daemon_debug.h" @@ -50,20 +51,19 @@ int handle_mount(nfs41_upcall *upcall) { int status; mount_upcall_args *args = &upcall->args.mount; + nfs41_abs_path path; multi_addr4 addrs; - const unsigned short port = 2049; nfs41_root *root; nfs41_client *client; // resolve hostname,port - status = nfs41_server_resolve(args->hostname, port, &addrs); + status = nfs41_server_resolve(args->hostname, 2049, &addrs); if (status) { eprintf("nfs41_server_resolve() failed with %d\n", status); goto out; } // create root - status = nfs41_root_create(args->hostname, port, &args->path, - NFS41_MAX_FILEIO_SIZE + WRITE_OVERHEAD, + status = nfs41_root_create(NFS41_MAX_FILEIO_SIZE + WRITE_OVERHEAD, NFS41_MAX_FILEIO_SIZE + READ_OVERHEAD, &root); if (status) { eprintf("nfs41_rpc_clnt_create failed %d\n", status); @@ -75,12 +75,21 @@ int handle_mount(nfs41_upcall *upcall) eprintf("nfs41_root_mount() failed with %d\n", status); goto out_err; } + + // make a copy of the path for nfs41_lookup() + InitializeSRWLock(&path.lock); + if (FAILED(StringCchCopyA(path.path, NFS41_MAX_PATH_LEN, args->path))) { + status = ERROR_BUFFER_OVERFLOW; + goto out; + } + path.len = (unsigned short)strlen(path.path); + // look up the mount path, and fail if it doesn't exist status = nfs41_lookup(root, client->session, - &args->path, NULL, NULL, NULL, NULL); + &path, NULL, NULL, NULL, NULL); if (status) { eprintf("nfs41_lookup('%s') failed with %d\n", - args->path.path, status); + path.path, status); goto out_err; } diff --git a/daemon/namespace.c b/daemon/namespace.c index 9ca46d0..f24a745 100644 --- a/daemon/namespace.c +++ b/daemon/namespace.c @@ -37,9 +37,6 @@ /* nfs41_root */ int nfs41_root_create( - IN const char *hostname, - IN unsigned short port, - IN const nfs41_abs_path *path, IN uint32_t wsize, IN uint32_t rsize, OUT nfs41_root **root_out) @@ -47,8 +44,7 @@ int nfs41_root_create( int status = NO_ERROR; nfs41_root *root; - dprintf(NSLVL, "--> nfs41_root_create(%s:%u:%s)\n", - hostname, port, path); + dprintf(NSLVL, "--> nfs41_root_create()\n"); root = calloc(1, sizeof(nfs41_root)); if (root == NULL) { @@ -57,7 +53,6 @@ int nfs41_root_create( } list_init(&root->clients); - root->port = port; root->wsize = wsize; root->rsize = rsize; InitializeCriticalSection(&root->lock); diff --git a/daemon/nfs41.h b/daemon/nfs41.h index 29a0d1e..5eabaad 100644 --- a/daemon/nfs41.h +++ b/daemon/nfs41.h @@ -166,15 +166,11 @@ typedef struct __nfs41_root { struct list_entry clients; uint32_t wsize; uint32_t rsize; - unsigned short port; } nfs41_root; /* nfs41_namespace.c */ int nfs41_root_create( - IN const char *hostname, - IN unsigned short port, - IN const char *path, IN uint32_t wsize, IN uint32_t rsize, OUT nfs41_root **root_out);