summaryrefslogtreecommitdiff
path: root/support/nfs
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2003-03-26 03:05:39 +0000
committerneilbrown <neilbrown>2003-03-26 03:05:39 +0000
commit16be8c20d6fe1a997d90ecb229aee6a5f092b73d (patch)
tree72625879992ba430479dd80550918facef1dfb1c /support/nfs
parentcec295bf37b784ed6ae5674ce34b9c75d89ea0a1 (diff)
downloadnfs-utils-neilb-devel.tar.gz
Work towards support new cache in 2.5nfs-utils-1-1-0-pre11neilb-devel
Diffstat (limited to 'support/nfs')
-rw-r--r--support/nfs/cacheio.c54
-rw-r--r--support/nfs/exports.c8
2 files changed, 59 insertions, 3 deletions
diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index 960d801..69373b9 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -19,6 +19,10 @@
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
void qword_add(char **bpp, int *lp, char *str)
{
@@ -214,3 +218,53 @@ int readline(int fd, char **buf, int *lenp)
return 1;
}
+
+/* Check if we should use the new caching interface
+ * This succeeds iff the "nfsd" filesystem is mounted on
+ * /proc/fs/nfs
+ */
+int
+check_new_cache(void)
+{
+ struct stat stb;
+ return (stat("/proc/fs/nfs/filehandle", &stb) == 0);
+}
+
+
+
+
+/* flush the kNFSd caches.
+ * Set the flush time to the mtime of _PATH_ETAB or
+ * if force, to now.
+ * the caches to flush are:
+ * auth.unix.ip nfsd.export nfsd.fh
+ */
+
+void
+cache_flush(int force)
+{
+ struct stat stb;
+ int c;
+ char stime[20];
+ char path[200];
+ static char *cachelist[] = {
+ "auth.unix.ip",
+ "nfsd.export",
+ "nfsd.fh",
+ NULL
+ };
+ stb.st_mtime = time(0);
+ if (!force)
+ stat(_PATH_ETAB, &stb);
+
+ sprintf(stime, "%ld\n", stb.st_mtime);
+ for (c=0; cachelist[c]; c++) {
+ int fd;
+ sprintf(path, "/proc/net/rpc/%s/flush", cachelist[c]);
+ fd = open(path, O_RDWR);
+ if (fd) {
+ write(fd, stime, strlen(stime));
+ close(fd);
+ }
+ }
+}
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index 3d23959..3bef3ab 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -170,8 +170,10 @@ putexportent(struct exportent *ep)
fprintf(fp, "%ssync,", (ep->e_flags & NFSEXP_ASYNC)? "a" : "");
fprintf(fp, "%swdelay,", (ep->e_flags & NFSEXP_GATHERED_WRITES)?
"" : "no_");
- fprintf(fp, "%shide,", (ep->e_flags & NFSEXP_CROSSMNT)?
+ fprintf(fp, "%shide,", (ep->e_flags & NFSEXP_NOHIDE)?
"no" : "");
+ fprintf(fp, "%scrossmnt,", (ep->e_flags & NFSEXP_CROSSMNT)?
+ "" : "no");
fprintf(fp, "%ssecure,", (ep->e_flags & NFSEXP_INSECURE_PORT)?
"in" : "");
fprintf(fp, "%sroot_squash,", (ep->e_flags & NFSEXP_ROOTSQUASH)?
@@ -333,9 +335,9 @@ parseopts(char *cp, struct exportent *ep, int warn)
had_sync_opt = 1;
ep->e_flags |= NFSEXP_ASYNC;
} else if (!strcmp(opt, "nohide"))
- ep->e_flags |= NFSEXP_CROSSMNT;
+ ep->e_flags |= NFSEXP_NOHIDE;
else if (!strcmp(opt, "hide"))
- ep->e_flags &= ~NFSEXP_CROSSMNT;
+ ep->e_flags &= ~NFSEXP_NOHIDE;
else if (!strcmp(opt, "crossmnt")) /* old style */
ep->e_flags |= NFSEXP_CROSSMNT;
else if (!strcmp(opt, "nocrossmnt")) /* old style */