summaryrefslogtreecommitdiffstats
path: root/support/export
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-12-06 11:02:42 -0500
committerSteve Dickson <steved@redhat.com>2016-12-06 11:15:37 -0500
commitfc1127d754578cd1dc3b52aebce1d5ae09f2d347 (patch)
tree4ea987b878532eff62f797d3933dd9ff5f29f24f /support/export
parent6a060231b029aa6b7a0af4fa69c84603f9f663dd (diff)
downloadnfs-utils-fc1127d754578cd1dc3b52aebce1d5ae09f2d347.tar.gz
nfs-utils-fc1127d754578cd1dc3b52aebce1d5ae09f2d347.tar.xz
nfs-utils-fc1127d754578cd1dc3b52aebce1d5ae09f2d347.zip
Remove all use of the nfsctl system call.
This systemcall was deprecated early in the 2.6 series as it was replaced by an in-kernel cache which was refilled using an upcall. All communication to kernel is now through the nfsd filesystem. The nfsctl systemcall itself was removed in 3.1. It is unlikely to have been used for over a decade. To remove all uses for the nfsctl systemcall, and call code that only runs when "new_cache" is false. We now assume "new_cache" is always true. This allows the removal of several files as well as assorted functions. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'support/export')
-rw-r--r--support/export/Makefile.am2
-rw-r--r--support/export/export.c56
-rw-r--r--support/export/nfsctl.c118
-rw-r--r--support/export/rmtab.c98
-rw-r--r--support/export/xtab.c16
5 files changed, 1 insertions, 289 deletions
diff --git a/support/export/Makefile.am b/support/export/Makefile.am
index 1ea1539..be3de69 100644
--- a/support/export/Makefile.am
+++ b/support/export/Makefile.am
@@ -10,7 +10,7 @@ GENFILES = $(GENFILES_CLNT) $(GENFILES_SVC) $(GENFILES_XDR) $(GENFILES_H)
EXTRA_DIST = mount.x
noinst_LIBRARIES = libexport.a
-libexport_a_SOURCES = client.c export.c hostname.c nfsctl.c rmtab.c \
+libexport_a_SOURCES = client.c export.c hostname.c \
xtab.c mount_clnt.c mount_xdr.c
BUILT_SOURCES = $(GENFILES)
diff --git a/support/export/export.c b/support/export/export.c
index 15e91cb..fbe68e8 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -29,9 +29,6 @@ static void export_init(nfs_export *exp, nfs_client *clp,
static void export_add(nfs_export *exp);
static int export_check(const nfs_export *exp, const struct addrinfo *ai,
const char *path);
-static nfs_export *
- export_allowed_internal(const struct addrinfo *ai,
- const char *path);
void
exportent_release(struct exportent *eep)
@@ -296,59 +293,6 @@ export_find(const struct addrinfo *ai, const char *path)
return NULL;
}
-static nfs_export *
-export_allowed_internal(const struct addrinfo *ai, const char *path)
-{
- nfs_export *exp;
- int i;
-
- for (i = 0; i < MCL_MAXTYPES; i++) {
- for (exp = exportlist[i].p_head; exp; exp = exp->m_next) {
- if (!exp->m_mayexport ||
- !export_check(exp, ai, path))
- continue;
- return exp;
- }
- }
-
- return NULL;
-}
-
-/**
- * export_allowed - determine if this export is allowed
- * @ai: pointer to addrinfo for client
- * @path: '\0'-terminated ASCII string containing export path
- *
- * Returns a pointer to nfs_export data matching @ai and @path,
- * or NULL if the export is not allowed.
- */
-nfs_export *
-export_allowed(const struct addrinfo *ai, const char *path)
-{
- nfs_export *exp;
- char epath[MAXPATHLEN+1];
- char *p = NULL;
-
- if (path [0] != '/') return NULL;
-
- strncpy(epath, path, sizeof (epath) - 1);
- epath[sizeof (epath) - 1] = '\0';
-
- /* Try the longest matching exported pathname. */
- while (1) {
- exp = export_allowed_internal(ai, epath);
- if (exp)
- return exp;
- /* We have to treat the root, "/", specially. */
- if (p == &epath[1]) break;
- p = strrchr(epath, '/');
- if (p == epath) p++;
- *p = '\0';
- }
-
- return NULL;
-}
-
/**
* export_lookup - search hash table for export entry
* @hname: '\0'-terminated ASCII string containing client hostname to look for
diff --git a/support/export/nfsctl.c b/support/export/nfsctl.c
deleted file mode 100644
index 2950a90..0000000
--- a/support/export/nfsctl.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * support/export/nfsctl.c
- *
- * Communicate export information to knfsd.
- *
- * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <ctype.h>
-#include "nfslib.h"
-#include "exportfs.h"
-#include "xio.h"
-
-static int expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport);
-static int cltsetup(struct nfsctl_client *cltarg, nfs_client *clp);
-
-int
-export_export(nfs_export *exp)
-{
- nfs_client * clp = exp->m_client;
- struct nfsctl_export exparg;
- struct nfsctl_client cltarg;
-
- if (!clp->m_exported && (clp->m_type != MCL_GSS)) {
- if (!cltsetup(&cltarg, clp))
- return 0;
- if (nfsaddclient(&cltarg) < 0)
- return 0;
- clp->m_exported = 1;
- }
- if (!expsetup(&exparg, exp, 0))
- return 0;
- if (nfsexport(&exparg) < 0)
- return 0;
- exp->m_exported = 1;
- return 1;
-}
-
-int
-export_unexport(nfs_export *exp)
-{
- struct nfsctl_export exparg;
-
- if (!expsetup(&exparg, exp, 1) || nfsunexport(&exparg) < 0)
- return 0;
- exp->m_exported = 0;
- return 1;
-}
-
-static void
-str_tolower(char *s)
-{
- for ( ; *s; s++)
- if (isupper(*s))
- *s = tolower(*s);
-}
-
-static int
-cltsetup(struct nfsctl_client *cltarg, nfs_client *clp)
-{
- int i, j;
-
- if (clp->m_type != MCL_FQDN) {
- xlog(L_ERROR, "internal: can't export non-FQDN host");
- return 0;
- }
- memset(cltarg, 0, sizeof(*cltarg));
- strncpy(cltarg->cl_ident, clp->m_hostname,
- sizeof (cltarg->cl_ident) - 1);
- str_tolower(cltarg->cl_ident);
-
- j = 0;
- for (i = 0; i < clp->m_naddr && i < NFSCLNT_ADDRMAX; i++) {
- const struct sockaddr_in *sin = get_addrlist_in(clp, i);
- if (sin->sin_family == AF_INET)
- cltarg->cl_addrlist[j++] = sin->sin_addr;
- }
- if (j == 0) {
- xlog(L_ERROR, "internal: no supported addresses in nfs_client");
- return 0;
- }
-
- cltarg->cl_naddr = j;
- return 1;
-}
-
-static int
-expsetup(struct nfsctl_export *exparg, nfs_export *exp, int unexport)
-{
- nfs_client *clp = exp->m_client;
- struct stat stb;
-
- if (stat(exp->m_export.e_path, &stb) < 0)
- return 0;
-
- memset(exparg, 0, sizeof(*exparg));
- strncpy(exparg->ex_path, exp->m_export.e_path,
- sizeof (exparg->ex_path) - 1);
- strncpy(exparg->ex_client, clp->m_hostname,
- sizeof (exparg->ex_client) - 1);
- str_tolower(exparg->ex_client);
- exparg->ex_flags = exp->m_export.e_flags;
- exparg->ex_dev = (!unexport && (exp->m_export.e_flags & NFSEXP_FSID)) ?
- (__nfsd_dev_t)exp->m_export.e_fsid : stb.st_dev;
- exparg->ex_ino = stb.st_ino;
- exparg->ex_anon_uid = exp->m_export.e_anonuid;
- exparg->ex_anon_gid = exp->m_export.e_anongid;
-
- return 1;
-}
diff --git a/support/export/rmtab.c b/support/export/rmtab.c
deleted file mode 100644
index d16b3b3..0000000
--- a/support/export/rmtab.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * support/export/rmtab.c
- *
- * Interface to the rmtab file.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include "misc.h"
-#include "nfslib.h"
-#include "exportfs.h"
-#include "xio.h"
-#include "xlog.h"
-
-/*
- * See if the entry already exists. If not,
- * this was an instantiated wild card, and we
- * must add it.
- */
-static void
-rmtab_read_wildcard(struct rmtabent *rep)
-{
- nfs_export *exp, *exp2;
- struct addrinfo *ai;
-
- ai = host_addrinfo(rep->r_client);
- if (ai == NULL)
- return;
-
- exp = export_allowed(ai, rep->r_path);
- freeaddrinfo(ai);
- if (exp == NULL)
- return;
-
- exp2 = export_lookup(rep->r_client, exp->m_export.e_path, 0);
- if (exp2 == NULL) {
- struct exportent ee;
-
- memset(&ee, 0, sizeof(ee));
- dupexportent(&ee, &exp->m_export);
-
- ee.e_hostname = rep->r_client;
- exp2 = export_create(&ee, 0);
- exp2->m_changed = exp->m_changed;
- }
- exp2->m_mayexport = 1;
-}
-
-int
-rmtab_read(void)
-{
- struct rmtabent *rep;
-
- setrmtabent("r");
- while ((rep = getrmtabent(1, NULL)) != NULL) {
- int htype;
-
- htype = client_gettype(rep->r_client);
- if (htype == MCL_FQDN || htype == MCL_SUBNETWORK)
- rmtab_read_wildcard(rep);
- }
-
- if (errno == EINVAL) {
- /* Something goes wrong. We need to fix the rmtab
- file. */
- int lockid;
- FILE *fp;
- if ((lockid = xflock(_PATH_RMTABLCK, "w")) < 0)
- return -1;
- rewindrmtabent();
- if (!(fp = fsetrmtabent(_PATH_RMTABTMP, "w"))) {
- endrmtabent ();
- xfunlock(lockid);
- return -1;
- }
- while ((rep = getrmtabent(0, NULL)) != NULL) {
- fputrmtabent(fp, rep, NULL);
- }
- if (rename(_PATH_RMTABTMP, _PATH_RMTAB) < 0) {
- xlog(L_ERROR, "couldn't rename %s to %s",
- _PATH_RMTABTMP, _PATH_RMTAB);
- }
- endrmtabent();
- fendrmtabent(fp);
- xfunlock(lockid);
- }
- else {
- endrmtabent();
- }
- return 0;
-}
diff --git a/support/export/xtab.c b/support/export/xtab.c
index 10d9dbc..22cf539 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -63,22 +63,6 @@ xtab_read(char *xtab, char *lockfn, int is_export)
}
int
-xtab_mount_read(void)
-{
- int fd;
- if ((fd=open(_PATH_PROC_EXPORTS, O_RDONLY))>=0) {
- close(fd);
- return xtab_read(_PATH_PROC_EXPORTS,
- _PATH_PROC_EXPORTS, 0);
- } else if ((fd=open(_PATH_PROC_EXPORTS_ALT, O_RDONLY) >= 0)) {
- close(fd);
- return xtab_read(_PATH_PROC_EXPORTS_ALT,
- _PATH_PROC_EXPORTS_ALT, 0);
- } else
- return 0;
-}
-
-int
xtab_export_read(void)
{
return xtab_read(_PATH_ETAB, _PATH_ETABLCK, 1);