patch-2.1.65 linux/fs/nfsd/nfsctl.c

Next file: linux/fs/nfsd/nfsfh.c
Previous file: linux/fs/nfsd/export.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.64/linux/fs/nfsd/nfsctl.c linux/fs/nfsd/nfsctl.c
@@ -17,11 +17,11 @@
 #include <linux/fcntl.h>
 #include <linux/net.h>
 #include <linux/in.h>
-#include <linux/nfs.h>
 #include <linux/version.h>
 #include <linux/unistd.h>
 #include <linux/malloc.h>
 
+#include <linux/nfs.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/cache.h>
@@ -38,6 +38,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 
+extern void nfsd_fh_init(void);
 extern long sys_call_table[];
 
 static int	nfsctl_svc(struct nfsctl_svc *data);
@@ -64,6 +65,7 @@
 	nfsd_export_init();	/* Exports table */
 	nfsd_lockd_init();	/* lockd->nfsd callbacks */
 	nfsd_racache_init();	/* Readahead param cache */
+	nfsd_fh_init();		/* FH table */
 	initialized = 1;
 }
 
@@ -141,31 +143,33 @@
 	union nfsctl_res *	res = NULL;
 	int			err;
 
+	MOD_INC_USE_COUNT;
 	lock_kernel ();
 	if (!initialized)
 		nfsd_init();
+	err = -EPERM;
 	if (!suser()) {
-		err = -EPERM;
 		goto done;
 	}
+	err = -EFAULT;
 	if (!access_ok(VERIFY_READ, argp, sizeof(*argp))
 	 || (resp && !access_ok(VERIFY_WRITE, resp, sizeof(*resp)))) {
-		err = -EFAULT;
 		goto done;
 	}
+
+	err = -ENOMEM;	/* ??? */
 	if (!(arg = kmalloc(sizeof(*arg), GFP_USER)) ||
 	    (resp && !(res = kmalloc(sizeof(*res), GFP_USER)))) {
-		err = -ENOMEM;	/* ??? */
 		goto done;
 	}
+
+	err = -EINVAL;
 	copy_from_user(arg, argp, sizeof(*argp));
 	if (arg->ca_version != NFSCTL_VERSION) {
 		printk(KERN_WARNING "nfsd: incompatible version in syscall.\n");
-		err = -EINVAL;
 		goto done;
 	}
 
-	MOD_INC_USE_COUNT;
 	switch(cmd) {
 	case NFSCTL_SVC:
 		err = nfsctl_svc(&arg->ca_svc);
@@ -193,7 +197,6 @@
 	default:
 		err = -EINVAL;
 	}
-	MOD_DEC_USE_COUNT;
 
 	if (!err && resp)
 		copy_to_user(resp, res, sizeof(*resp));
@@ -205,6 +208,7 @@
 		kfree(res);
 
 	unlock_kernel ();
+	MOD_DEC_USE_COUNT;
 	return err;
 }
 
@@ -224,7 +228,6 @@
 init_module(void)
 {
 	printk("Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n");
-	nfsd_init();
 	do_nfsservctl = handle_sys_nfsservctl;
 	return 0;
 }
@@ -242,6 +245,7 @@
 	do_nfsservctl = NULL;
 	nfsd_export_shutdown();
 	nfsd_cache_shutdown();
+	nfsd_fh_free();
 #ifdef CONFIG_PROC_FS
 	nfsd_stat_shutdown();
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov