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)
This commit is contained in:
parent
6bf65bcf3a
commit
45452edc37
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=190971
@ -2469,6 +2469,7 @@ nfsserver/nfs_srvsock.c optional nfsserver
|
||||
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
|
||||
|
@ -187,6 +187,7 @@ SUBDIR= ${_3dfx} \
|
||||
nfsclient \
|
||||
nfslockd \
|
||||
nfsserver \
|
||||
nfssvc \
|
||||
nge \
|
||||
nmdm \
|
||||
${_nsp} \
|
||||
|
9
sys/modules/nfssvc/Makefile
Normal file
9
sys/modules/nfssvc/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../nfs
|
||||
KMOD= nfssvc
|
||||
SRCS= nfs_nfssvc.c \
|
||||
opt_nfs.h
|
||||
|
||||
.include <bsd.kmod.mk>
|
@ -40,6 +40,8 @@
|
||||
#include "opt_nfs.h"
|
||||
#endif
|
||||
|
||||
#include <nfs/nfssvc.h>
|
||||
|
||||
/*
|
||||
* Tunable constants for nfs
|
||||
*/
|
||||
@ -115,13 +117,6 @@ struct nfsd_nfsd_args {
|
||||
#include <nfsserver/nfsrvstats.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flags for nfssvc() system call.
|
||||
*/
|
||||
#define NFSSVC_OLDNFSD 0x004
|
||||
#define NFSSVC_ADDSOCK 0x008
|
||||
#define NFSSVC_NFSD 0x010
|
||||
|
||||
/*
|
||||
* vfs.nfsrv sysctl(3) identifiers
|
||||
*/
|
||||
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -112,6 +112,9 @@ extern u_long sb_max_adj;
|
||||
* NFS server system calls
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user