aboutsummaryrefslogtreecommitdiffstats
path: root/main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2014-10-02 16:59:11 +0300
committerTimo Teräs <timo.teras@iki.fi>2014-10-02 17:00:16 +0300
commit4c57113c71d286a57c2f4e487260597d04319902 (patch)
tree73d9bee40c433d846c4637e0dea7e556c9d09882 /main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch
parent9265bc1da1deb74e43fb5028a0aa02e583f85f69 (diff)
downloadaports-4c57113c71d286a57c2f4e487260597d04319902.tar.gz
aports-4c57113c71d286a57c2f4e487260597d04319902.tar.bz2
aports-4c57113c71d286a57c2f4e487260597d04319902.tar.xz
main/nfs-utils: remove old cruft, and update proc/net/rpc rework patch(set)
Diffstat (limited to 'main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch')
-rw-r--r--main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch135
1 files changed, 135 insertions, 0 deletions
diff --git a/main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch b/main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch
new file mode 100644
index 0000000000..8cd1e3b474
--- /dev/null
+++ b/main/nfs-utils/0004-nfsexport-talk-to-kernel-using-file-descriptors-inst.patch
@@ -0,0 +1,135 @@
+From 9be231f2dde111d4841549140c7fd7aa2c6f3b9e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Thu, 2 Oct 2014 16:17:30 +0300
+Subject: [PATCH v2 4/5] nfsexport: talk to kernel using file descriptors
+ instead of FILE
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Timo Teräs <timo.teras@iki.fi>
+---
+ support/nfs/nfsexport.c | 77 ++++++++++++++++++++++++++++---------------------
+ 1 file changed, 44 insertions(+), 33 deletions(-)
+
+diff --git a/support/nfs/nfsexport.c b/support/nfs/nfsexport.c
+index f129fd2..afd7c90 100644
+--- a/support/nfs/nfsexport.c
++++ b/support/nfs/nfsexport.c
+@@ -18,6 +18,7 @@
+ #include <fcntl.h>
+
+ #include "nfslib.h"
++#include "misc.h"
+
+ /* if /proc/net/rpc/... exists, then
+ * write to it, as that interface is more stable.
+@@ -32,62 +33,72 @@
+ static int
+ exp_unexp(struct nfsctl_export *exp, int export)
+ {
+- FILE *f;
++ char buf[RPC_CHAN_BUF_SIZE], *bp;
+ struct stat stb;
+ __u32 fsid;
+ char fsidstr[8];
+ __u16 dev;
+ __u32 inode;
+- int err;
++ int err = 0, f, blen;
+
++ f = open("/proc/net/rpc/nfsd.export/channel", O_WRONLY);
++ if (f < 0) return -1;
+
+- f = fopen("/proc/net/rpc/nfsd.export/channel", "w");
+- if (f == NULL) return -1;
+- qword_print(f, exp->ex_client);
+- qword_print(f, exp->ex_path);
++ bp = buf; blen = sizeof(buf);
++ qword_add(&bp, &blen, exp->ex_client);
++ qword_add(&bp, &blen, exp->ex_path);
+ if (export) {
+- qword_printint(f, 0x7fffffff);
+- qword_printint(f, exp->ex_flags);
+- qword_printint(f, exp->ex_anon_uid);
+- qword_printint(f, exp->ex_anon_gid);
+- qword_printint(f, exp->ex_dev);
++ qword_addint(&bp, &blen, 0x7fffffff);
++ qword_addint(&bp, &blen, exp->ex_flags);
++ qword_addint(&bp, &blen, exp->ex_anon_uid);
++ qword_addint(&bp, &blen, exp->ex_anon_gid);
++ qword_addint(&bp, &blen, exp->ex_dev);
+ } else
+- qword_printint(f, 1);
+-
+- err = qword_eol(f);
+- fclose(f);
++ qword_addint(&bp, &blen, 1);
++ qword_addeol(&bp, &blen);
++ if (blen <= 0 || write(f, buf, bp - buf) != bp - buf)
++ err = -1;
++ close(f);
+
+ if (stat(exp->ex_path, &stb) != 0)
+ return -1;
+- f = fopen("/proc/net/rpc/nfsd.fh/channel", "w");
+- if (f==NULL) return -1;
++
++ f = open("/proc/net/rpc/nfsd.fh/channel", O_WRONLY);
++ if (f < 0) return -1;
+ if (exp->ex_flags & NFSEXP_FSID) {
+- qword_print(f,exp->ex_client);
+- qword_printint(f,1);
++ bp = buf; blen = sizeof(buf);
++ qword_add(&bp, &blen, exp->ex_client);
++ qword_addint(&bp, &blen, 1);
+ fsid = exp->ex_dev;
+- qword_printhex(f, (char*)&fsid, 4);
++ qword_addhex(&bp, &blen, (char*)&fsid, 4);
+ if (export) {
+- qword_printint(f, 0x7fffffff);
+- qword_print(f, exp->ex_path);
++ qword_addint(&bp, &blen, 0x7fffffff);
++ qword_add(&bp, &blen, exp->ex_path);
+ } else
+- qword_printint(f, 1);
+-
+- err = qword_eol(f) || err;
++ qword_addint(&bp, &blen, 1);
++ qword_addeol(&bp, &blen);
++ if (blen <= 0 || write(f, buf, bp - buf) != bp - buf)
++ err = -1;
+ }
+- qword_print(f,exp->ex_client);
+- qword_printint(f,0);
++
++ bp = buf; blen = sizeof(buf);
++ qword_add(&bp, &blen, exp->ex_client);
++ qword_addint(&bp, &blen, 0);
+ dev = htons(major(stb.st_dev)); memcpy(fsidstr, &dev, 2);
+ dev = htons(minor(stb.st_dev)); memcpy(fsidstr+2, &dev, 2);
+ inode = stb.st_ino; memcpy(fsidstr+4, &inode, 4);
+
+- qword_printhex(f, fsidstr, 8);
++ qword_addhex(&bp, &blen, fsidstr, 8);
+ if (export) {
+- qword_printint(f, 0x7fffffff);
+- qword_print(f, exp->ex_path);
++ qword_addint(&bp, &blen, 0x7fffffff);
++ qword_add(&bp, &blen, exp->ex_path);
+ } else
+- qword_printint(f, 1);
+- err = qword_eol(f) || err;
+- fclose(f);
++ qword_addint(&bp, &blen, 1);
++ qword_addeol(&bp, &blen);
++ if (blen <= 0 || write(f, buf, bp - buf) != bp - buf)
++ err = -1;
++ close(f);
++
+ return err;
+ }
+
+--
+2.1.2
+