aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/export.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/export.c')
-rw-r--r--fs/nfsd/export.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index c1c9e035d4a4..872a5ef550c7 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1,7 +1,5 @@
1#define MSNFS /* HACK HACK */ 1#define MSNFS /* HACK HACK */
2/* 2/*
3 * linux/fs/nfsd/export.c
4 *
5 * NFS exporting and validation. 3 * NFS exporting and validation.
6 * 4 *
7 * We maintain a list of clients, each of which has a list of 5 * We maintain a list of clients, each of which has a list of
@@ -14,29 +12,17 @@
14 * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de> 12 * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de>
15 */ 13 */
16 14
17#include <linux/unistd.h>
18#include <linux/slab.h> 15#include <linux/slab.h>
19#include <linux/stat.h>
20#include <linux/in.h>
21#include <linux/seq_file.h>
22#include <linux/syscalls.h>
23#include <linux/rwsem.h>
24#include <linux/dcache.h>
25#include <linux/namei.h> 16#include <linux/namei.h>
26#include <linux/mount.h>
27#include <linux/hash.h>
28#include <linux/module.h> 17#include <linux/module.h>
29#include <linux/exportfs.h> 18#include <linux/exportfs.h>
30 19
31#include <linux/sunrpc/svc.h>
32#include <linux/nfsd/nfsd.h>
33#include <linux/nfsd/nfsfh.h>
34#include <linux/nfsd/syscall.h> 20#include <linux/nfsd/syscall.h>
35#include <linux/lockd/bind.h>
36#include <linux/sunrpc/msg_prot.h>
37#include <linux/sunrpc/gss_api.h>
38#include <net/ipv6.h> 21#include <net/ipv6.h>
39 22
23#include "nfsd.h"
24#include "nfsfh.h"
25
40#define NFSDDBG_FACILITY NFSDDBG_EXPORT 26#define NFSDDBG_FACILITY NFSDDBG_EXPORT
41 27
42typedef struct auth_domain svc_client; 28typedef struct auth_domain svc_client;
@@ -369,16 +355,25 @@ static struct svc_export *svc_export_update(struct svc_export *new,
369 struct svc_export *old); 355 struct svc_export *old);
370static struct svc_export *svc_export_lookup(struct svc_export *); 356static struct svc_export *svc_export_lookup(struct svc_export *);
371 357
372static int check_export(struct inode *inode, int flags, unsigned char *uuid) 358static int check_export(struct inode *inode, int *flags, unsigned char *uuid)
373{ 359{
374 360
375 /* We currently export only dirs and regular files. 361 /*
376 * This is what umountd does. 362 * We currently export only dirs, regular files, and (for v4
363 * pseudoroot) symlinks.
377 */ 364 */
378 if (!S_ISDIR(inode->i_mode) && 365 if (!S_ISDIR(inode->i_mode) &&
366 !S_ISLNK(inode->i_mode) &&
379 !S_ISREG(inode->i_mode)) 367 !S_ISREG(inode->i_mode))
380 return -ENOTDIR; 368 return -ENOTDIR;
381 369
370 /*
371 * Mountd should never pass down a writeable V4ROOT export, but,
372 * just to make sure:
373 */
374 if (*flags & NFSEXP_V4ROOT)
375 *flags |= NFSEXP_READONLY;
376
382 /* There are two requirements on a filesystem to be exportable. 377 /* There are two requirements on a filesystem to be exportable.
383 * 1: We must be able to identify the filesystem from a number. 378 * 1: We must be able to identify the filesystem from a number.
384 * either a device number (so FS_REQUIRES_DEV needed) 379 * either a device number (so FS_REQUIRES_DEV needed)
@@ -387,7 +382,7 @@ static int check_export(struct inode *inode, int flags, unsigned char *uuid)
387 * This means that s_export_op must be set. 382 * This means that s_export_op must be set.
388 */ 383 */
389 if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) && 384 if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
390 !(flags & NFSEXP_FSID) && 385 !(*flags & NFSEXP_FSID) &&
391 uuid == NULL) { 386 uuid == NULL) {
392 dprintk("exp_export: export of non-dev fs without fsid\n"); 387 dprintk("exp_export: export of non-dev fs without fsid\n");
393 return -EINVAL; 388 return -EINVAL;
@@ -602,7 +597,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
602 goto out4; 597 goto out4;
603 } 598 }
604 599
605 err = check_export(exp.ex_path.dentry->d_inode, exp.ex_flags, 600 err = check_export(exp.ex_path.dentry->d_inode, &exp.ex_flags,
606 exp.ex_uuid); 601 exp.ex_uuid);
607 if (err) 602 if (err)
608 goto out4; 603 goto out4;
@@ -1041,7 +1036,7 @@ exp_export(struct nfsctl_export *nxp)
1041 goto finish; 1036 goto finish;
1042 } 1037 }
1043 1038
1044 err = check_export(path.dentry->d_inode, nxp->ex_flags, NULL); 1039 err = check_export(path.dentry->d_inode, &nxp->ex_flags, NULL);
1045 if (err) goto finish; 1040 if (err) goto finish;
1046 1041
1047 err = -ENOMEM; 1042 err = -ENOMEM;
@@ -1320,6 +1315,15 @@ rqst_exp_parent(struct svc_rqst *rqstp, struct path *path)
1320 return exp; 1315 return exp;
1321} 1316}
1322 1317
1318static struct svc_export *find_fsidzero_export(struct svc_rqst *rqstp)
1319{
1320 u32 fsidv[2];
1321
1322 mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
1323
1324 return rqst_exp_find(rqstp, FSID_NUM, fsidv);
1325}
1326
1323/* 1327/*
1324 * Called when we need the filehandle for the root of the pseudofs, 1328 * Called when we need the filehandle for the root of the pseudofs,
1325 * for a given NFSv4 client. The root is defined to be the 1329 * for a given NFSv4 client. The root is defined to be the
@@ -1330,11 +1334,8 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
1330{ 1334{
1331 struct svc_export *exp; 1335 struct svc_export *exp;
1332 __be32 rv; 1336 __be32 rv;
1333 u32 fsidv[2];
1334
1335 mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
1336 1337
1337 exp = rqst_exp_find(rqstp, FSID_NUM, fsidv); 1338 exp = find_fsidzero_export(rqstp);
1338 if (IS_ERR(exp)) 1339 if (IS_ERR(exp))
1339 return nfserrno(PTR_ERR(exp)); 1340 return nfserrno(PTR_ERR(exp));
1340 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL); 1341 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
@@ -1425,6 +1426,7 @@ static struct flags {
1425 { NFSEXP_CROSSMOUNT, {"crossmnt", ""}}, 1426 { NFSEXP_CROSSMOUNT, {"crossmnt", ""}},
1426 { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}}, 1427 { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}},
1427 { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}}, 1428 { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}},
1429 { NFSEXP_V4ROOT, {"v4root", ""}},
1428#ifdef MSNFS 1430#ifdef MSNFS
1429 { NFSEXP_MSNFS, {"msnfs", ""}}, 1431 { NFSEXP_MSNFS, {"msnfs", ""}},
1430#endif 1432#endif