summaryrefslogtreecommitdiffstats
path: root/support/nfs
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2005-10-06 05:20:19 +0000
committerneilbrown <neilbrown>2005-10-06 05:20:19 +0000
commitf73e7b9f69835d483cee95e6a20b6307b9d16b77 (patch)
tree3c6f5f0c0677f0bc30018b9619ea32ffc9efebb9 /support/nfs
parentb51ebed58a610b3104e9f218d609715cd468b0ea (diff)
downloadnfs-utils-f73e7b9f69835d483cee95e6a20b6307b9d16b77.tar.gz
nfs-utils-f73e7b9f69835d483cee95e6a20b6307b9d16b77.tar.xz
nfs-utils-f73e7b9f69835d483cee95e6a20b6307b9d16b77.zip
Assorted changes from Steve Dickson
Diffstat (limited to 'support/nfs')
-rw-r--r--support/nfs/Makefile2
-rw-r--r--support/nfs/closeall.c31
-rw-r--r--support/nfs/exports.c2
-rw-r--r--support/nfs/xlog.c2
4 files changed, 34 insertions, 3 deletions
diff --git a/support/nfs/Makefile b/support/nfs/Makefile
index fb8f508..7740224 100644
--- a/support/nfs/Makefile
+++ b/support/nfs/Makefile
@@ -6,7 +6,7 @@ LIBNAME = libnfs.a
OBJS = exports.o rmtab.o xio.o \
rpcmisc.o rpcdispatch.o xlog.o xmalloc.o wildmat.o \
nfssvc.o nfsclient.o nfsexport.o getfh.o nfsctl.o \
- lockdsvc.o svc_socket.o cacheio.o
+ lockdsvc.o svc_socket.o cacheio.o closeall.o
include $(TOP)rules.mk
diff --git a/support/nfs/closeall.c b/support/nfs/closeall.c
new file mode 100644
index 0000000..cc7fb3b
--- /dev/null
+++ b/support/nfs/closeall.c
@@ -0,0 +1,31 @@
+/*
+ * support/nfs/closeall.c
+ * Close all file descriptors greater than some limit,
+ * Use readdir "/proc/self/fd" to avoid excess close(2) calls.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <dirent.h>
+
+void
+closeall(int min)
+{
+ DIR *dir = opendir("/proc/self/fd");
+ if (dir != NULL) {
+ int dfd = dirfd(dir);
+ struct dirent *d;
+
+ while ((d = readdir(dir)) != NULL) {
+ char *endp;
+ long n = strtol(d->d_name, &endp, 10);
+ if (*endp != '\0' && n >= min && n != dfd)
+ (void) close(n);
+ }
+ closedir(dir);
+ } else {
+ int fd = sysconf(_SC_OPEN_MAX);
+ while (--fd >= min)
+ (void) close(fd);
+ }
+}
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 43e68b1..1048c80 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -448,7 +448,7 @@ bad_option:
ep->e_nsqgids = nsqgids;
out:
- if (warn && !had_sync_opt)
+ if (warn && !had_sync_opt && !(ep->e_flags & NFSEXP_READONLY))
xlog(L_WARNING, "%s [%d]: No 'sync' or 'async' option specified for export \"%s:%s\".\n"
" Assuming default behaviour ('sync').\n"
" NOTE: this default has changed from previous versions\n",
diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c
index e1e4c3f..d59f27f 100644
--- a/support/nfs/xlog.c
+++ b/support/nfs/xlog.c
@@ -161,7 +161,7 @@ xlog(int kind, const char *fmt, ...)
break;
default:
if (!log_stderr)
- syslog(LOG_DEBUG, "%s", buff);
+ syslog(LOG_INFO, "%s", buff);
break;
}
}