max_path: make an abs_path for lookup on mount

in handle_mount(), the call to nfs41_lookup() requires a mutable nfs41_abs_path because it can change on referrals, so make a copy for it

removed unused fields in struct nfs41_root and related arguments to nfs41_root_create()

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2010-10-12 10:06:01 -04:00
parent f727a1e4b4
commit 6d2b631080
3 changed files with 16 additions and 16 deletions

View file

@ -22,6 +22,7 @@
*/
#include <Windows.h>
#include <strsafe.h>
#include <stdio.h>
#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;
}

View file

@ -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);

View file

@ -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);