X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnfs%2Fnfssvc.c;h=c51ace18ea078c223aa597afb4637b9fbd1663a1;hp=38240a020f190ffbe12c5591752929e1c6baed30;hb=fde2ae7794047a698feeaf17963d690a1e660a80;hpb=0523fd513c6baa8dbf45d1a7afea2044262aeb3d 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 #include +#include +#include #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);