summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog38
-rw-r--r--support/export/client.c8
-rw-r--r--support/export/export.c12
-rw-r--r--support/export/rmtab.c4
-rw-r--r--support/export/xtab.c4
-rw-r--r--support/include/exportfs.h6
-rw-r--r--utils/exportfs/exportfs.c57
7 files changed, 69 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 3826e5e..1c6b466 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,40 @@
-2001-09020 NeilBrown <neilb@cse.unsw.edu.au>
+2001-09-20 NeilBrown <neilb@cse.unsw.edu.au>
+
+ Arrange that "exportfs -au" never does DNS lookup:
+
+ * support/export/client.c (client_lookup) : add "canonical"
+ flag which says that the hostname is known to be canonical, so
+ don't do a lookup
+
+ * support/export/export.c (export_create) : add "canonical"
+ flag to be passed down to client_lookup
+ * support/export/export.c (export_lookup) : Likewise
+
+ * support/export/xtab.c (xtab_read) : pass appropriate
+ "canonical" flag to export_lookup and export_create:
+ set if reading list of filesystems currently exports
+ (is_export != 1).
+
+ * support/export/export.c (export_read) : pass 0 as
+ "canonical" flag to export_lookup and export_create
+ * support/export/rmtab.s (rmtab_read) : Likewise
+
+ * support/include/exportfs.h : redeclare various routines
+ to have "canonical" flag
+
+ * utils/exportfs/exportfs.c (main) : redo logic for
+ "-au" to read in what is currently exported, but never even
+ look at what "should" be exported.
+
+ * utils/exportfs/exportfs.c (unexportall) : remove this
+ routine. Functionality is completely included in
+ exports_update
+
+ * utils/exportfs/exportfs.c (exportfs) : set "canonical"
+ flag to zero in calls to export_lookup and export_create.
+
+
+2001-09-20 NeilBrown <neilb@cse.unsw.edu.au>
Anne Milicia <milicia@missioncriticallinux.com>
* support/export/client.c (client_lookup) call gethostbyadd
diff --git a/support/export/client.c b/support/export/client.c
index 076b0c0..da3a976 100644
--- a/support/export/client.c
+++ b/support/export/client.c
@@ -32,8 +32,12 @@ static int client_checkaddr(nfs_client *clp, struct in_addr addr);
nfs_client *clientlist[MCL_MAXTYPES] = { NULL, };
+/* if canonical is set, then we *know* this is already a canonical name
+ * so hostname lookup is avoided.
+ * This is used when reading /proc/fs/nfs/exports
+ */
nfs_client *
-client_lookup(char *hname)
+client_lookup(char *hname, int canonical)
{
nfs_client *clp = NULL;
int htype;
@@ -41,7 +45,7 @@ client_lookup(char *hname)
htype = client_gettype(hname);
- if (htype == MCL_FQDN) {
+ if (htype == MCL_FQDN && !canonical) {
struct hostent *hp2;
hp = gethostbyname(hname);
if (hp == NULL || hp->h_addrtype != AF_INET) {
diff --git a/support/export/export.c b/support/export/export.c
index ef12056..4cfb448 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -33,9 +33,9 @@ export_read(char *fname)
setexportent(fname, "r");
while ((eep = getexportent()) != NULL) {
- exp = export_lookup(eep->e_hostname, eep->e_path);
+ exp = export_lookup(eep->e_hostname, eep->e_path, 0);
if (!exp)
- export_create(eep);
+ export_create(eep,0);
else {
if (exp->m_export.e_flags != eep->e_flags) {
xlog(L_ERROR, "incompatible duplicated export entries:");
@@ -61,12 +61,12 @@ export_read(char *fname)
* Create an in-core export struct from an export entry.
*/
nfs_export *
-export_create(struct exportent *xep)
+export_create(struct exportent *xep, int canonical)
{
nfs_client *clp;
nfs_export *exp;
- if (!(clp = client_lookup(xep->e_hostname))) {
+ if (!(clp = client_lookup(xep->e_hostname, canonical))) {
/* bad export entry; complaint already logged */
return NULL;
}
@@ -203,12 +203,12 @@ export_allowed(struct hostent *hp, char *path)
}
nfs_export *
-export_lookup(char *hname, char *path)
+export_lookup(char *hname, char *path, int canonical)
{
nfs_client *clp;
nfs_export *exp;
- if (!(clp = client_lookup(hname)))
+ if (!(clp = client_lookup(hname, canonical)))
return NULL;
for (exp = exportlist[clp->m_type]; exp; exp = exp->m_next)
if (exp->m_client == clp && !strcmp(exp->m_export.e_path, path))
diff --git a/support/export/rmtab.c b/support/export/rmtab.c
index 4e141c3..3c55267 100644
--- a/support/export/rmtab.c
+++ b/support/export/rmtab.c
@@ -37,12 +37,12 @@ rmtab_read(void)
/* see if the entry already exists, otherwise this was an instantiated
* wild card, and we must add it
*/
- exp = export_lookup(rep->r_client, xp->e_path);
+ exp = export_lookup(rep->r_client, xp->e_path, 0);
if (!exp) {
strncpy (xp->e_hostname, rep->r_client,
sizeof (xp->e_hostname) - 1);
xp->e_hostname[sizeof (xp->e_hostname) -1] = '\0';
- exp = export_create(xp);
+ exp = export_create(xp, 0);
}
free (hp);
diff --git a/support/export/xtab.c b/support/export/xtab.c
index b0c3095..54470c1 100644
--- a/support/export/xtab.c
+++ b/support/export/xtab.c
@@ -33,8 +33,8 @@ xtab_read(char *xtab, int is_export)
return 0;
setexportent(xtab, "r");
while ((xp = getexportent()) != NULL) {
- if (!(exp = export_lookup(xp->e_hostname, xp->e_path)) &&
- !(exp = export_create(xp))) {
+ if (!(exp = export_lookup(xp->e_hostname, xp->e_path, is_export != 1)) &&
+ !(exp = export_create(xp, is_export!=1))) {
continue;
}
switch (is_export) {
diff --git a/support/include/exportfs.h b/support/include/exportfs.h
index 3ca248e..deb837c 100644
--- a/support/include/exportfs.h
+++ b/support/include/exportfs.h
@@ -45,7 +45,7 @@ typedef struct mexport {
extern nfs_client * clientlist[MCL_MAXTYPES];
extern nfs_export * exportlist[MCL_MAXTYPES];
-nfs_client * client_lookup(char *hname);
+nfs_client * client_lookup(char *hname, int canonical);
nfs_client * client_find(struct hostent *);
void client_add(nfs_client *);
nfs_client * client_dup(nfs_client *, struct hostent *);
@@ -58,10 +58,10 @@ void client_freeall(void);
int export_read(char *fname);
void export_add(nfs_export *);
void export_reset(nfs_export *);
-nfs_export * export_lookup(char *hname, char *path);
+nfs_export * export_lookup(char *hname, char *path, int caconical);
nfs_export * export_find(struct hostent *, char *path);
struct exportent * export_allowed(struct hostent *, char *path);
-nfs_export * export_create(struct exportent *);
+nfs_export * export_create(struct exportent *, int canonical);
nfs_export * export_dup(nfs_export *, struct hostent *);
void export_freeall(void);
int export_export(nfs_export *);
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index c012961..4c04098 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -24,7 +24,6 @@
#include "xlog.h"
static void export_all(int verbose);
-static void unexport_all(int verbose);
static void exportfs(char *arg, char *options, int verbose);
static void unexportfs(char *arg, int verbose);
static void exports_update(int verbose);
@@ -100,19 +99,21 @@ main(int argc, char **argv)
for (i = optind; i < argc ; i++)
exportfs(argv[i], options, f_verbose);
}
- /* note: xtab_*_read does not update entries if they already exist,
- * so this will not lose new options
+ /* If we are unexporting everything, then
+ * don't care about what should be exported, as that
+ * may require DNS lookups..
*/
- if (!f_reexport)
- xtab_export_read();
- if (!f_export) {
- if (f_all)
- unexport_all(f_verbose);
- else
+ if (! ( !f_export && f_all)) {
+ /* note: xtab_*_read does not update entries if they already exist,
+ * so this will not lose new options
+ */
+ if (!f_reexport)
+ xtab_export_read();
+ if (!f_export)
for (i = optind ; i < argc ; i++)
unexportfs(argv[i], f_verbose);
+ rmtab_read();
}
- rmtab_read();
xtab_mount_read();
exports_update(f_verbose);
xtab_export_write();
@@ -174,38 +175,6 @@ export_all(int verbose)
}
}
}
-/*
- * unexport_all finds all entries that are mayexport, and
- * marks them not xtabent and not mayexport
- */
-static void
-unexport_all(int verbose)
-{
- nfs_export *exp;
- int i;
-
- for (i = 0; i < MCL_MAXTYPES; i++) {
- for (exp = exportlist[i]; exp; exp = exp->m_next)
- if (exp->m_mayexport) {
- if (verbose) {
- if (exp->m_exported) {
- printf("unexporting %s:%s from kernel\n",
- exp->m_client->m_hostname,
- exp->m_export.e_path);
- }
- else {
- printf("unexporting %s:%s\n",
- exp->m_client->m_hostname,
- exp->m_export.e_path);
- }
- }
- if (exp->m_exported && !export_unexport(exp))
- error(exp, errno);
- exp->m_xtabent = 0;
- exp->m_mayexport = 0;
- }
- }
-}
static void
@@ -238,12 +207,12 @@ exportfs(char *arg, char *options, int verbose)
hp = hp2;
exp = export_find(hp, path);
} else {
- exp = export_lookup(hname, path);
+ exp = export_lookup(hname, path, 0);
}
if (!exp) {
if (!(eep = mkexportent(hname, path, options)) ||
- !(exp = export_create(eep))) {
+ !(exp = export_create(eep, 0))) {
if (hp) free (hp);
return;
}