summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorSteve Dickson <SteveD@redhat.com>2006-06-26 15:23:19 +1000
committerNeil Brown <neilb@suse.de>2006-06-26 15:23:19 +1000
commitfde2ae7794047a698feeaf17963d690a1e660a80 (patch)
tree3fec36ef5414306769e9c0c9e0e7833636e30b87 /support
parent0523fd513c6baa8dbf45d1a7afea2044262aeb3d (diff)
downloadnfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.tar.gz
nfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.tar.xz
nfs-utils-fde2ae7794047a698feeaf17963d690a1e660a80.zip
Add support for suppressing different NFS versions.
e.g. -N 2 means that NFSv2 won't be supported, just v3 and v4 (if the kernel supports them).
Diffstat (limited to 'support')
-rw-r--r--support/include/nfs/nfs.h7
-rw-r--r--support/include/nfslib.h2
-rw-r--r--support/nfs/nfssvc.c33
3 files changed, 40 insertions, 2 deletions
diff --git a/support/include/nfs/nfs.h b/support/include/nfs/nfs.h
index c7fc42c..2cf6857 100644
--- a/support/include/nfs/nfs.h
+++ b/support/include/nfs/nfs.h
@@ -10,6 +10,9 @@
#define NFS3_FHSIZE 64
#define NFS_FHSIZE 32
+#define NFSD_MINVERS 2
+#define NFSD_MAXVERS 4
+
struct nfs_fh_len {
int fh_size;
u_int8_t fh_handle[NFS3_FHSIZE];
@@ -40,7 +43,11 @@ struct nfs_fh_old {
#define NFSCTL_LOCKD 0x10000
#define LOCKDCTL_SVC NFSCTL_LOCKD
+#define NFSCTL_VERUNSET(_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1)))
+
+#define NFSCTL_VERISSET(_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1)))
+#define NFSCTL_ALLBITS (~0)
/* SVC */
struct nfsctl_svc {
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
index 8c83262..50892e2 100644
--- a/support/include/nfslib.h
+++ b/support/include/nfslib.h
@@ -120,7 +120,7 @@ int wildmat(char *text, char *pattern);
* nfsd library functions.
*/
int nfsctl(int, struct nfsctl_arg *, union nfsctl_res *);
-int nfssvc(int port, int nrservs);
+int nfssvc(int port, int nrservs, unsigned int versbits);
int nfsaddclient(struct nfsctl_client *clp);
int nfsdelclient(struct nfsctl_client *clp);
int nfsexport(struct nfsctl_export *exp);
diff --git a/support/nfs/nfssvc.c b/support/nfs/nfssvc.c
index 38240a0..c51ace1 100644
--- a/support/nfs/nfssvc.c
+++ b/support/nfs/nfssvc.c
@@ -12,15 +12,46 @@
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
+#include <syslog.h>
#include "nfslib.h"
+static void
+nfssvc_versbits(unsigned int ctlbits)
+{
+ int fd, n, off;
+ char buf[BUFSIZ], *ptr;
+
+ ptr = buf;
+ off = 0;
+ fd = open("/proc/fs/nfsd/versions", O_WRONLY);
+ if (fd < 0)
+ return;
+
+ for (n = NFSD_MINVERS; n <= NFSD_MAXVERS; n++) {
+ if (NFSCTL_VERISSET(ctlbits, n))
+ off += snprintf(ptr+off, BUFSIZ - off, "+%d ", n);
+ else
+ off += snprintf(ptr+off, BUFSIZ - off, "-%d ", n);
+ }
+ snprintf(ptr+off, BUFSIZ - off, "\n");
+ if (write(fd, buf, strlen(buf)) != strlen(buf)) {
+ syslog(LOG_ERR, "nfssvc: Setting version failed: errno %d (%s)",
+ errno, strerror(errno));
+ }
+ close(fd);
+
+ return;
+}
int
-nfssvc(int port, int nrservs)
+nfssvc(int port, int nrservs, unsigned int versbits)
{
struct nfsctl_arg arg;
int fd;
+ nfssvc_versbits(versbits);
+
fd = open("/proc/fs/nfsd/threads", O_WRONLY);
if (fd < 0)
fd = open("/proc/fs/nfs/threads", O_WRONLY);