Date: Sun, 12 Apr 2009 19:04:27 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r190971 - in head/sys: conf modules modules/nfssvc nfsserver Message-ID: <200904121904.n3CJ4RTa035520@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Sun Apr 12 19:04:27 2009 New Revision: 190971 URL: http://svn.freebsd.org/changeset/base/190971 Log: 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) Added: head/sys/modules/nfssvc/ head/sys/modules/nfssvc/Makefile (contents, props changed) Modified: head/sys/conf/files head/sys/modules/Makefile head/sys/nfsserver/nfs.h head/sys/nfsserver/nfs_srvkrpc.c head/sys/nfsserver/nfs_srvsubs.c head/sys/nfsserver/nfs_syscalls.c Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/conf/files Sun Apr 12 19:04:27 2009 (r190971) @@ -2469,6 +2469,7 @@ nfsserver/nfs_srvsock.c optional nfsser nfsserver/nfs_srvcache.c optional nfsserver nfsserver/nfs_srvsubs.c optional nfsserver nfsserver/nfs_syscalls.c optional nfsserver +nfs/nfs_nfssvc.c optional nfsserver nlm/nlm_advlock.c optional nfslockd nfsclient nlm/nlm_prot_clnt.c optional nfslockd nlm/nlm_prot_impl.c optional nfslockd Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/modules/Makefile Sun Apr 12 19:04:27 2009 (r190971) @@ -187,6 +187,7 @@ SUBDIR= ${_3dfx} \ nfsclient \ nfslockd \ nfsserver \ + nfssvc \ nge \ nmdm \ ${_nsp} \ Added: head/sys/modules/nfssvc/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/nfssvc/Makefile Sun Apr 12 19:04:27 2009 (r190971) @@ -0,0 +1,9 @@ + +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../nfs +KMOD= nfssvc +SRCS= nfs_nfssvc.c \ + opt_nfs.h + +.include <bsd.kmod.mk> Modified: head/sys/nfsserver/nfs.h ============================================================================== --- head/sys/nfsserver/nfs.h Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/nfsserver/nfs.h Sun Apr 12 19:04:27 2009 (r190971) @@ -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 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 Modified: head/sys/nfsserver/nfs_srvkrpc.c ============================================================================== --- head/sys/nfsserver/nfs_srvkrpc.c Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/nfsserver/nfs_srvkrpc.c Sun Apr 12 19:04:27 2009 (r190971) @@ -151,6 +151,9 @@ int32_t (*nfsrv3_procs[NFS_NPROCS])(stru /* * 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])(stru * - 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_ } else { error = ENXIO; } - if (error == EINTR || error == ERESTART) - error = 0; return (error); } Modified: head/sys/nfsserver/nfs_srvsubs.c ============================================================================== --- head/sys/nfsserver/nfs_srvsubs.c Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/nfsserver/nfs_srvsubs.c Sun Apr 12 19:04:27 2009 (r190971) @@ -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, v 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, v 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, /* 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 Modified: head/sys/nfsserver/nfs_syscalls.c ============================================================================== --- head/sys/nfsserver/nfs_syscalls.c Sun Apr 12 17:43:41 2009 (r190970) +++ head/sys/nfsserver/nfs_syscalls.c Sun Apr 12 19:04:27 2009 (r190971) @@ -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_ } else { error = ENXIO; } - if (error == EINTR || error == ERESTART) - error = 0; return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904121904.n3CJ4RTa035520>