summaryrefslogtreecommitdiffstats
path: root/sys/nfsserver
diff options
context:
space:
mode:
authorrmacklem <rmacklem@FreeBSD.org>2009-04-12 19:04:27 +0000
committerrmacklem <rmacklem@FreeBSD.org>2009-04-12 19:04:27 +0000
commitbb19ddd3ae86245d3ec07e01dddd703df190e108 (patch)
treef6962a19f747e88cf2ea71b892b0eb5a6b5797d4 /sys/nfsserver
parent2c81196a786de08a0665470134ae0462dadc103f (diff)
downloadFreeBSD-src-bb19ddd3ae86245d3ec07e01dddd703df190e108.zip
FreeBSD-src-bb19ddd3ae86245d3ec07e01dddd703df190e108.tar.gz
Change nfsserver so that it uses the nfssvc() system call provided
in sys/nfs/nfs_nfssvc.c by registering with it using the nfsd_call_nfsserver function pointer. Also, add the build glue for nfs_nfssvc.c optionally based on "nfsserver" and also as a loadable module. Submitted by: rmacklem Reviewed by: kib Approved by: kib (mentor)
Diffstat (limited to 'sys/nfsserver')
-rw-r--r--sys/nfsserver/nfs.h16
-rw-r--r--sys/nfsserver/nfs_srvkrpc.c18
-rw-r--r--sys/nfsserver/nfs_srvsubs.c17
-rw-r--r--sys/nfsserver/nfs_syscalls.c20
4 files changed, 22 insertions, 49 deletions
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h
index 2709377..b47ffea 100644
--- a/sys/nfsserver/nfs.h
+++ b/sys/nfsserver/nfs.h
@@ -40,6 +40,8 @@
#include "opt_nfs.h"
#endif
+#include <nfs/nfssvc.h>
+
/*
* Tunable constants for nfs
*/
@@ -116,13 +118,6 @@ struct nfsd_nfsd_args {
#endif
/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_OLDNFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_NFSD 0x010
-
-/*
* vfs.nfsrv sysctl(3) identifiers
*/
#define NFS_NFSRVSTATS 1 /* struct: struct nfsrvstats */
@@ -447,6 +442,13 @@ int nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
int nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
struct mbuf **mrq);
+/*
+ * #ifdef _SYS_SYSPROTO_H_ so that it is only defined when sysproto.h
+ * has been included, so that "struct nfssvc_args" is defined.
+ */
+#ifdef _SYS_SYSPROTO_H_
+int nfssvc_nfsserver(struct thread *, struct nfssvc_args *);
+#endif
#endif /* _KERNEL */
#endif
diff --git a/sys/nfsserver/nfs_srvkrpc.c b/sys/nfsserver/nfs_srvkrpc.c
index c6896ff..77bdec8 100644
--- a/sys/nfsserver/nfs_srvkrpc.c
+++ b/sys/nfsserver/nfs_srvkrpc.c
@@ -151,6 +151,9 @@ int32_t (*nfsrv3_procs[NFS_NPROCS])(struct nfsrv_descript *nd,
/*
* NFS server system calls
*/
+/*
+ * This is now called from nfssvc() in nfs/nfs_nfssvc.c.
+ */
/*
* Nfs server psuedo system call for the nfsd's
@@ -163,25 +166,14 @@ int32_t (*nfsrv3_procs[NFS_NPROCS])(struct nfsrv_descript *nd,
* - sockaddr with no IPv4-mapped addresses
* - mask for both INET and INET6 families if there is IPv4-mapped overlap
*/
-#ifndef _SYS_SYSPROTO_H_
-struct nfssvc_args {
- int flag;
- caddr_t argp;
-};
-#endif
int
-nfssvc(struct thread *td, struct nfssvc_args *uap)
+nfssvc_nfsserver(struct thread *td, struct nfssvc_args *uap)
{
struct file *fp;
struct nfsd_addsock_args addsockarg;
struct nfsd_nfsd_args nfsdarg;
int error;
- KASSERT(!mtx_owned(&Giant), ("nfssvc(): called with Giant"));
-
- error = priv_check(td, PRIV_NFS_DAEMON);
- if (error)
- return (error);
if (uap->flag & NFSSVC_ADDSOCK) {
error = copyin(uap->argp, (caddr_t)&addsockarg,
sizeof(addsockarg));
@@ -208,8 +200,6 @@ nfssvc(struct thread *td, struct nfssvc_args *uap)
} else {
error = ENXIO;
}
- if (error == EINTR || error == ERESTART)
- error = 0;
return (error);
}
diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c
index 00e5216..d154463 100644
--- a/sys/nfsserver/nfs_srvsubs.c
+++ b/sys/nfsserver/nfs_srvsubs.c
@@ -100,10 +100,6 @@ struct nfsd_head nfsd_head;
int nfsd_head_flag;
#endif
-static int nfssvc_offset = SYS_nfssvc;
-static struct sysent nfssvc_prev_sysent;
-MAKE_SYSENT(nfssvc);
-
struct mtx nfsd_mtx;
/*
@@ -519,13 +515,14 @@ static const short *nfsrv_v3errmap[] = {
nfsv3err_commit,
};
+extern int (*nfsd_call_nfsserver)(struct thread *, struct nfssvc_args *);
+
/*
* Called once to initialize data structures...
*/
static int
nfsrv_modevent(module_t mod, int type, void *data)
{
- static int registered;
int error = 0;
switch (type) {
@@ -560,11 +557,7 @@ nfsrv_modevent(module_t mod, int type, void *data)
NFSD_UNLOCK();
#endif
- error = syscall_register(&nfssvc_offset, &nfssvc_sysent,
- &nfssvc_prev_sysent);
- if (error)
- break;
- registered = 1;
+ nfsd_call_nfsserver = nfssvc_nfsserver;
break;
case MOD_UNLOAD:
@@ -573,8 +566,7 @@ nfsrv_modevent(module_t mod, int type, void *data)
break;
}
- if (registered)
- syscall_deregister(&nfssvc_offset, &nfssvc_prev_sysent);
+ nfsd_call_nfsserver = NULL;
callout_drain(&nfsrv_callout);
#ifdef NFS_LEGACYRPC
nfsrv_destroycache(); /* Free the server request cache */
@@ -596,6 +588,7 @@ DECLARE_MODULE(nfsserver, nfsserver_mod, SI_SUB_VFS, SI_ORDER_ANY);
/* So that loader and kldload(2) can find us, wherever we are.. */
MODULE_VERSION(nfsserver, 1);
+MODULE_DEPEND(nfsserver, nfssvc, 1, 1, 1);
#ifndef NFS_LEGACYRPC
MODULE_DEPEND(nfsserver, krpc, 1, 1, 1);
#endif
diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c
index 326d623..59a30a3 100644
--- a/sys/nfsserver/nfs_syscalls.c
+++ b/sys/nfsserver/nfs_syscalls.c
@@ -113,6 +113,9 @@ extern u_long sb_max_adj;
*/
/*
+ * This is now called from nfssvc() in nfs/nfs_nfssvc.c.
+ */
+/*
* Nfs server psuedo system call for the nfsd's
* Based on the flag value it either:
* - adds a socket to the selection list
@@ -123,27 +126,14 @@ extern u_long sb_max_adj;
* - sockaddr with no IPv4-mapped addresses
* - mask for both INET and INET6 families if there is IPv4-mapped overlap
*/
-#ifndef _SYS_SYSPROTO_H_
-struct nfssvc_args {
- int flag;
- caddr_t argp;
-};
-#endif
int
-nfssvc(struct thread *td, struct nfssvc_args *uap)
+nfssvc_nfsserver(struct thread *td, struct nfssvc_args *uap)
{
struct file *fp;
struct sockaddr *nam;
struct nfsd_addsock_args nfsdarg;
int error;
- KASSERT(!mtx_owned(&Giant), ("nfssvc(): called with Giant"));
-
- AUDIT_ARG(cmd, uap->flag);
-
- error = priv_check(td, PRIV_NFS_DAEMON);
- if (error)
- return (error);
NFSD_LOCK();
while (nfssvc_sockhead_flag & SLP_INIT) {
nfssvc_sockhead_flag |= SLP_WANTINIT;
@@ -181,8 +171,6 @@ nfssvc(struct thread *td, struct nfssvc_args *uap)
} else {
error = ENXIO;
}
- if (error == EINTR || error == ERESTART)
- error = 0;
return (error);
}
OpenPOWER on IntegriCloud