summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2003-05-30 05:16:52 +0000
committerneilbrown <neilbrown>2003-05-30 05:16:52 +0000
commitd38ea02d0e4bcdc4e0114567028596f7bcba45b9 (patch)
treea464ad88e48a90c4efa48fd4caefc843caa88d05 /support
parent936ecbb5750e0e29b9e2464998a8e03eca617b72 (diff)
downloadnfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.tar.gz
nfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.tar.xz
nfs-utils-d38ea02d0e4bcdc4e0114567028596f7bcba45b9.zip
new "mountpoint" export option.
Diffstat (limited to 'support')
-rw-r--r--support/export/export.c2
-rw-r--r--support/include/misc.h2
-rw-r--r--support/include/nfslib.h1
-rw-r--r--support/misc/Makefile2
-rw-r--r--support/misc/mountpoint.c34
-rw-r--r--support/nfs/exports.c17
6 files changed, 57 insertions, 1 deletions
diff --git a/support/export/export.c b/support/export/export.c
index ba0d095..eef2c3b 100644
--- a/support/export/export.c
+++ b/support/export/export.c
@@ -239,6 +239,8 @@ export_freeall(void)
xfree(exp->m_export.e_squids);
if (exp->m_export.e_sqgids)
xfree(exp->m_export.e_sqgids);
+ if (exp->m_export.e_mountpoint)
+ free(exp->m_export.e_mountpoint);
xfree(exp);
}
exportlist[i] = NULL;
diff --git a/support/include/misc.h b/support/include/misc.h
index 7d099d0..9a1b25d 100644
--- a/support/include/misc.h
+++ b/support/include/misc.h
@@ -22,4 +22,6 @@ struct hostent *hostent_dup(struct hostent *hp);
struct hostent *get_hostent (const char *addr, int len, int type);
struct hostent *get_reliable_hostbyaddr(const char *addr, int len, int type);
+extern int is_mountpoint(char *path);
+
#endif /* MISC_H */
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
index 5864305..c41f92e 100644
--- a/support/include/nfslib.h
+++ b/support/include/nfslib.h
@@ -73,6 +73,7 @@ struct exportent {
int * e_sqgids;
int e_nsqgids;
int e_fsid;
+ char * e_mountpoint;
};
struct rmtabent {
diff --git a/support/misc/Makefile b/support/misc/Makefile
index b2f73f8..c738564 100644
--- a/support/misc/Makefile
+++ b/support/misc/Makefile
@@ -3,7 +3,7 @@
#
LIBNAME = libmisc.a
-OBJS = tcpwrapper.o from_local.o
+OBJS = tcpwrapper.o from_local.o mountpoint.o
include $(TOP)rules.mk
diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c
new file mode 100644
index 0000000..6d0f34e
--- /dev/null
+++ b/support/misc/mountpoint.c
@@ -0,0 +1,34 @@
+
+/*
+ * check if a given path is a mountpoint
+ */
+
+#include <string.h>
+#include <malloc.h>
+#include <sys/stat.h>
+
+int
+is_mountpoint(char *path)
+{
+ /* Check if 'path' is a current mountpoint.
+ * Possibly we should also check it is the mountpoint of the
+ * filesystem holding the target directory, but there doesn't
+ * seem a lot of point.
+ *
+ * We deem it to be a mountpoint if appending a ".." gives a different
+ * device or the same inode number.
+ */
+ char *dotdot;
+ struct stat stb, pstb;
+
+ dotdot = malloc(strlen(path)+4);
+ strcat(strcpy(dotdot, path), "/..");
+ if (lstat(path, &stb) != 0 ||
+ lstat(dotdot, &pstb) != 0)
+ return 0;
+
+ if (stb.st_dev != pstb.st_dev
+ || stb.st_ino == pstb.st_ino)
+ return 1;
+ return 0;
+}
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index dfb241e..4d8665c 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -91,6 +91,7 @@ getexportent(int fromkernel, int fromexports)
ee.e_anongid = -2;
ee.e_squids = NULL;
ee.e_sqgids = NULL;
+ ee.e_mountpoint = NULL;
ee.e_nsquids = 0;
ee.e_nsqgids = 0;
@@ -187,6 +188,10 @@ putexportent(struct exportent *ep)
if (ep->e_flags & NFSEXP_FSID) {
fprintf(fp, "fsid=%d,", ep->e_fsid);
}
+ if (ep->e_mountpoint)
+ fprintf(fp, "mountpoint%s%s,",
+ ep->e_mountpoint[0]?"=":"", ep->e_mountpoint);
+
fprintf(fp, "mapping=");
switch (ep->e_maptype) {
case CLE_MAP_IDENT:
@@ -247,6 +252,8 @@ dupexportent(struct exportent *dst, struct exportent *src)
dst->e_sqgids = (int *) xmalloc(n * sizeof(int));
memcpy(dst->e_sqgids, src->e_sqgids, n * sizeof(int));
}
+ if (src->e_mountpoint)
+ dst->e_mountpoint = strdup(src->e_mountpoint);
}
struct exportent *
@@ -260,6 +267,7 @@ mkexportent(char *hname, char *path, char *options)
ee.e_anongid = -2;
ee.e_squids = NULL;
ee.e_sqgids = NULL;
+ ee.e_mountpoint = NULL;
ee.e_nsquids = 0;
ee.e_nsqgids = 0;
@@ -408,6 +416,15 @@ bad_option:
goto bad_option;
}
ep->e_flags |= NFSEXP_FSID;
+ } else if (strcmp(opt, "mountpoint")==0 ||
+ strcmp(opt, "mp") == 0 ||
+ strncmp(opt, "mountpoint=", 11)==0 ||
+ strncmp(opt, "mp=", 3) == 0) {
+ char * mp = strchr(opt, '=');
+ if (mp)
+ ep->e_mountpoint = strdup(mp+1);
+ else
+ ep->e_mountpoint = strdup("");
} else {
xlog(L_ERROR, "%s:%d: unknown keyword \"%s\"\n",
flname, flline, opt);