[PATCH] knfsd: Restore functionality to read from file in /proc/fs/nfsd/
authorNeilBrown <neilb@cse.unsw.edu.au>
Mon, 7 Nov 2005 09:00:24 +0000 (01:00 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 7 Nov 2005 15:53:47 +0000 (07:53 -0800)
Most files in the nfsd filesystems are transaction files.  You write a
request, and read a response.

For some (e.g.  'threads') it makes sense to just be able to read and get the
current value.

This functionality did exist but was broken recently when someone modified
nfsctl.c without going through the maintainer.  This patch fixes the
regression.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/nfsd/nfsctl.c

index 841c562..2a99a0b 100644 (file)
@@ -104,9 +104,23 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu
        return rv;
 }
 
        return rv;
 }
 
+static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos)
+{
+       if (! file->private_data) {
+               /* An attempt to read a transaction file without writing
+                * causes a 0-byte write so that the file can return
+                * state information
+                */
+               ssize_t rv = nfsctl_transaction_write(file, buf, 0, pos);
+               if (rv < 0)
+                       return rv;
+       }
+       return simple_transaction_read(file, buf, size, pos);
+}
+
 static struct file_operations transaction_ops = {
        .write          = nfsctl_transaction_write,
 static struct file_operations transaction_ops = {
        .write          = nfsctl_transaction_write,
-       .read           = simple_transaction_read,
+       .read           = nfsctl_transaction_read,
        .release        = simple_transaction_release,
 };
 
        .release        = simple_transaction_release,
 };