7 #include <linux/types.h>
8 #include <linux/socket.h>
9 #include <linux/kernel.h>
10 #include <linux/errno.h>
11 #include <linux/uio.h>
12 #include <linux/net.h>
16 #include <linux/nfs_fs.h>
20 # define NFSDBG_FACILITY NFSDBG_MOUNT
26 #define MNTPATHLEN (1024)
31 #define encode_dirpath_sz (1 + XDR_QUADLEN(MNTPATHLEN))
32 #define MNT_status_sz (1)
33 #define MNT_fhs_status_sz (1)
34 #define MNT_fhandle_sz XDR_QUADLEN(NFS2_FHSIZE)
35 #define MNT_fhandle3_sz (1 + XDR_QUADLEN(NFS3_FHSIZE))
36 #define MNT_authflav3_sz (1 + NFS_MAX_SECFLAVORS)
41 #define MNT_enc_dirpath_sz encode_dirpath_sz
42 #define MNT_dec_mountres_sz (MNT_status_sz + MNT_fhandle_sz)
43 #define MNT_dec_mountres3_sz (MNT_status_sz + MNT_fhandle_sz + \
87 { .status =
MNT_OK, .errno = 0, },
114 { .status =
MNT3_OK, .errno = 0, },
155 struct rpc_create_args args = {
158 .address = info->
sap,
159 .addrsize = info->
salen,
161 .program = &mnt_program,
163 .authflavor = RPC_AUTH_UNIX,
168 dprintk(
"NFS: sending MNT request for %s:%s\n",
173 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
176 if (IS_ERR(mnt_clnt))
189 if (result.
errno != 0)
192 dprintk(
"NFS: MNT request succeeded\n");
199 status = PTR_ERR(mnt_clnt);
200 dprintk(
"NFS: failed to create MNT RPC client, status=%d\n", status);
204 dprintk(
"NFS: MNT request failed, status=%d\n", status);
208 dprintk(
"NFS: MNT server returned result %d\n", result.
errno);
209 status = result.
errno;
222 static const struct rpc_timeout nfs_umnt_timeout = {
223 .to_initval = 1 *
HZ,
227 struct rpc_create_args args = {
230 .address = info->
sap,
231 .addrsize = info->
salen,
232 .timeout = &nfs_umnt_timeout,
234 .program = &mnt_program,
236 .authflavor = RPC_AUTH_UNIX,
237 .flags = RPC_CLNT_CREATE_NOPING,
246 args.flags |= RPC_CLNT_CREATE_NONPRIVPORT;
252 dprintk(
"NFS: sending UMNT request for %s:%s\n",
269 dprintk(
"NFS: failed to create UMNT RPC client, status=%ld\n",
274 dprintk(
"NFS: UMNT request failed, status=%d\n", status);
281 static void encode_mntdirpath(
struct xdr_stream *xdr,
const char *
pathname)
283 const u32 pathname_len =
strlen(pathname);
291 static void mnt_xdr_enc_dirpath(
struct rpc_rqst *
req,
struct xdr_stream *xdr,
294 encode_mntdirpath(xdr, dirpath);
306 static int decode_status(
struct xdr_stream *xdr,
struct mountres *
res)
317 for (i = 0; i <
ARRAY_SIZE(mnt_errtbl); i++) {
318 if (mnt_errtbl[i].status == status) {
319 res->
errno = mnt_errtbl[
i].errno;
324 dprintk(
"NFS: unrecognized MNT status code: %u\n", status);
329 static int decode_fhandle(
struct xdr_stream *xdr,
struct mountres *res)
343 static int mnt_xdr_dec_mountres(
struct rpc_rqst *
req,
344 struct xdr_stream *xdr,
349 status = decode_status(xdr, res);
352 return decode_fhandle(xdr, res);
355 static int decode_fhs_status(
struct xdr_stream *xdr,
struct mountres *res)
366 for (i = 0; i <
ARRAY_SIZE(mnt3_errtbl); i++) {
367 if (mnt3_errtbl[i].status == status) {
368 res->
errno = mnt3_errtbl[
i].errno;
373 dprintk(
"NFS: unrecognized MNT3 status code: %u\n", status);
378 static int decode_fhandle3(
struct xdr_stream *xdr,
struct mountres *res)
401 static int decode_auth_flavors(
struct xdr_stream *xdr,
struct mountres *res)
415 dprintk(
"NFS: received %u auth flavors\n", entries);
423 if (entries > *count)
426 for (i = 0; i <
entries; i++) {
428 dprintk(
"NFS: auth flavor[%u]: %d\n", i, flavors[i]);
435 static int mnt_xdr_dec_mountres3(
struct rpc_rqst *req,
436 struct xdr_stream *xdr,
441 status = decode_fhs_status(xdr, res);
444 status = decode_fhandle3(xdr, res);
449 return decode_auth_flavors(xdr, res);
455 .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
456 .
p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres,
464 .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
474 .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
475 .
p_decode = (kxdrdproc_t)mnt_xdr_dec_mountres3,
483 .p_encode = (kxdreproc_t)mnt_xdr_enc_dirpath,
494 .procs = mnt_procedures,
500 .procs = mnt3_procedures,
516 .version = mnt_version,