diff options
| author | neilbrown <neilbrown> | 2003-05-30 05:16:52 +0000 |
|---|---|---|
| committer | neilbrown <neilbrown> | 2003-05-30 05:16:52 +0000 |
| commit | d38ea02d0e4bcdc4e0114567028596f7bcba45b9 (patch) | |
| tree | a464ad88e48a90c4efa48fd4caefc843caa88d05 /utils | |
| parent | 936ecbb5750e0e29b9e2464998a8e03eca617b72 (diff) | |
| download | nfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.tar.gz nfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.tar.xz nfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.zip | |
new "mountpoint" export option.
Diffstat (limited to 'utils')
| -rw-r--r-- | utils/exportfs/Makefile | 2 | ||||
| -rw-r--r-- | utils/exportfs/exportfs.c | 14 | ||||
| -rw-r--r-- | utils/exportfs/exports.man | 19 | ||||
| -rw-r--r-- | utils/mountd/cache.c | 28 | ||||
| -rw-r--r-- | utils/mountd/mountd.c | 7 |
5 files changed, 68 insertions, 2 deletions
diff --git a/utils/exportfs/Makefile b/utils/exportfs/Makefile index 851a294..8cd7029 100644 --- a/utils/exportfs/Makefile +++ b/utils/exportfs/Makefile @@ -5,7 +5,7 @@ PROGRAM = exportfs OBJS = exportfs.o LIBDEPS = $(TOP)support/lib/libexport.a $(TOP)/support/lib/libnfs.a -LIBS = -lexport -lnfs +LIBS = -lexport -lnfs -lmisc MAN8 = exportfs MAN5 = exports diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 936dff5..bd48e98 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -147,6 +147,16 @@ exports_update(int verbose) nfs_export *exp; for (exp = exportlist[MCL_FQDN]; exp; exp=exp->m_next) { + /* check mountpoint option */ + if (exp->m_mayexport && + exp->m_export.e_mountpoint && + !is_mountpoint(exp->m_export.e_mountpoint[0]? + exp->m_export.e_mountpoint: + exp->m_export.e_path)) { + printf("%s not exported as %s not a mountpoint.\n", + exp->m_export.e_path, exp->m_export.e_mountpoint); + exp->m_mayexport = 0; + } if (exp->m_mayexport && ((exp->m_exported<1) || exp->m_changed)) { if (verbose) printf("%sexporting %s:%s to kernel\n", @@ -366,6 +376,10 @@ dump(int verbose) c = dumpopt(c, "insecure_locks"); if (ep->e_flags & NFSEXP_FSID) c = dumpopt(c, "fsid=%d", ep->e_fsid); + if (ep->e_mountpoint) + c = dumpopt(c, "mountpoint%s%s", + ep->e_mountpoint[0]?"=":"", + ep->e_mountpoint); if (ep->e_maptype == CLE_MAP_UGIDD) c = dumpopt(c, "mapping=ugidd"); else if (ep->e_maptype == CLE_MAP_FILE) diff --git a/utils/exportfs/exports.man b/utils/exportfs/exports.man index 7ab7640..6223944 100644 --- a/utils/exportfs/exports.man +++ b/utils/exportfs/exports.man @@ -237,6 +237,25 @@ or '''.TP '''.IR link_absolute '''Leave all symbolic link as they are. This is the default operation. + +.TP +.IR mountpoint= path +.TP +.I mp +This option makes it possible to only export a directory if it has +successfully been mounted. +If no path is given (e.g. +.IR mountpoint " or " mp ) +then the export point must also be a mount point. If it isn't then +the export point is not exported. This allows you to be sure that the +directory underneath a mountpoint will never be exported by accident +if, for example, the filesystem failed to mount due to a disc error. + +If a path is given (e.g. +.IR mountpoint= "/path or " mp= /path) +then the nominted path must be a mountpoint for the exportpoint to be +exported. + .SS User ID Mapping .PP .I nfsd diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index c5bc53f..9d7d20d 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -100,6 +100,7 @@ void nfsd_fh(FILE *f) struct exportent *found = NULL; nfs_export *exp; int i; + int dev_missing = 0; if (readline(fileno(f), &lbuf, &lbuflen) != 1) return; @@ -145,6 +146,11 @@ void nfsd_fh(FILE *f) continue; if (fsidtype == 0) { struct stat stb; + if (exp->m_export.e_mountpoint && + !is_mountpoint(exp->m_export.e_mountpoint[0]? + exp->m_export.e_mountpoint: + exp->m_export.e_path)) + dev_missing ++; if (stat(exp->m_export.e_path, &stb) != 0) continue; if (stb.st_ino != inode) @@ -158,11 +164,31 @@ void nfsd_fh(FILE *f) found = &exp->m_export; else if (strcmp(found->e_path, exp->m_export.e_path)!= 0) { - xlog(L_WARNING, "%s and %s have name filehandle for %s, using first", + xlog(L_WARNING, "%s and %s have same filehandle for %s, using first", found->e_path, exp->m_export.e_path, dom); } } } + if (found && + found->e_mountpoint && + !is_mountpoint(found->e_mountpoint[0]? + found->e_mountpoint: + found->e_path)) { + /* Cannot export this yet + * should log a warning, but need to rate limit + xlog(L_WARNING, "%s not exported as %d not a mountpoint", + found->e_path, found->e_mountpoint); + */ + /* FIXME we need to make sure we re-visit this later */ + goto out; + } + if (!found && dev_missing) { + /* The missing dev could be what we want, so just be + * quite rather than returning stale yet + */ + goto out; + } + cache_export_ent(dom, found); qword_print(f, dom); diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index b1bce1d..3769c92 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -282,6 +282,13 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, int *error, int v3) xlog(L_WARNING, "request to export directory %s below nearest filesystem %s", p, exp->m_export.e_path); *error = NFSERR_ACCES; + } else if (exp->m_export.e_mountpoint && + !is_mountpoint(exp->m_export.e_mountpoint[0]? + exp->m_export.e_mountpoint: + exp->m_export.e_path)) { + xlog(L_WARNING, "request to export an unmounted filesystem: %s", + p); + *error = NFSERR_NOENT; } else if (new_cache) { /* This will be a static private nfs_export with just one * address. We feed it to kernel then extract the filehandle, |
