Skip to content

Commit

Permalink
NFS: Add support for mounting NFSv4 file systems with string options
Browse files Browse the repository at this point in the history
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Jul 11, 2007
1 parent 136d558 commit 8007122
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 8 deletions.
91 changes: 84 additions & 7 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1541,8 +1541,90 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
*ip_addr = c;

break;
default:
goto out_bad_version;
default: {
unsigned int len;
struct nfs_parsed_mount_data args = {
.rsize = NFS_MAX_FILE_IO_SIZE,
.wsize = NFS_MAX_FILE_IO_SIZE,
.timeo = 600,
.retrans = 2,
.acregmin = 3,
.acregmax = 60,
.acdirmin = 30,
.acdirmax = 60,
.nfs_server.protocol = IPPROTO_TCP,
};

if (nfs_parse_mount_options((char *) *options, &args) == 0)
return -EINVAL;

if (!nfs_verify_server_address((struct sockaddr *)
&args.nfs_server.address))
return -EINVAL;
*addr = args.nfs_server.address;

switch (args.auth_flavor_len) {
case 0:
*authflavour = RPC_AUTH_UNIX;
break;
case 1:
*authflavour = (rpc_authflavor_t) args.auth_flavors[0];
break;
default:
goto out_inval_auth;
}

/*
* Translate to nfs4_mount_data, which nfs4_fill_super
* can deal with.
*/
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
*options = data;

data->version = 1;
data->flags = args.flags & NFS4_MOUNT_FLAGMASK;
data->rsize = args.rsize;
data->wsize = args.wsize;
data->timeo = args.timeo;
data->retrans = args.retrans;
data->acregmin = args.acregmin;
data->acregmax = args.acregmax;
data->acdirmin = args.acdirmin;
data->acdirmax = args.acdirmax;
data->proto = args.nfs_server.protocol;

/*
* Split "dev_name" into "hostname:mntpath".
*/
c = strchr(dev_name, ':');
if (c == NULL)
return -EINVAL;
/* while calculating len, pretend ':' is '\0' */
len = c - dev_name;
if (len > NFS4_MAXNAMLEN)
return -EINVAL;
*hostname = kzalloc(len, GFP_KERNEL);
if (*hostname == NULL)
return -ENOMEM;
strncpy(*hostname, dev_name, len - 1);

c++; /* step over the ':' */
len = strlen(c);
if (len > NFS4_MAXPATHLEN)
return -EINVAL;
*mntpath = kzalloc(len + 1, GFP_KERNEL);
if (*mntpath == NULL)
return -ENOMEM;
strncpy(*mntpath, c, len);

dprintk("MNTPATH: %s\n", *mntpath);

*ip_addr = args.client_address;

break;
}
}

return 0;
Expand All @@ -1559,11 +1641,6 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
out_no_address:
dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
return -EINVAL;

out_bad_version:
dfprintk(MOUNT, "NFS4: bad nfs_mount_data version %d\n",
data->version);
return -EINVAL;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion include/linux/nfs4_mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ struct nfs4_mount_data {
#define NFS4_MOUNT_NOCTO 0x0010 /* 1 */
#define NFS4_MOUNT_NOAC 0x0020 /* 1 */
#define NFS4_MOUNT_STRICTLOCK 0x1000 /* 1 */
#define NFS4_MOUNT_FLAGMASK 0xFFFF
#define NFS4_MOUNT_FLAGMASK 0x1033

#endif

0 comments on commit 8007122

Please sign in to comment.