- Split out the part of SYSCALL_MODULE_HELPER() that builds a 'struct

sysent' for a new system call into a new MAKE_SYSENT() macro.
- Use MAKE_SYSENT() to build a full sysent for the nfssvc system call in
  the NFS server and use syscall_register() and syscall_deregister() to
  manage the nfssvc system call entry instead of manually frobbing the
  sysent[] array.
This commit is contained in:
John Baldwin 2007-04-02 13:53:26 +00:00
parent ebb3c22c16
commit ddda35b8f6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168268
2 changed files with 21 additions and 15 deletions

View File

@ -98,8 +98,9 @@ int nfssvc_sockhead_flag;
struct nfsd_head nfsd_head;
int nfsd_head_flag;
static int nfs_prev_nfssvc_sy_narg;
static sy_call_t *nfs_prev_nfssvc_sy_call;
static int nfssvc_offset = SYS_nfssvc;
static struct sysent nfssvc_prev_sysent;
MAKE_SYSENT(nfssvc);
struct mtx nfsd_mtx;
@ -522,6 +523,7 @@ static const short *nfsrv_v3errmap[] = {
static int
nfsrv_modevent(module_t mod, int type, void *data)
{
static int registered;
int error = 0;
NET_LOCK_GIANT();
@ -554,11 +556,11 @@ nfsrv_modevent(module_t mod, int type, void *data)
NFSD_UNLOCK();
nfsrv_timer(0);
/* XXX: Should use SYSCALL_MODULE() */
nfs_prev_nfssvc_sy_narg = sysent[SYS_nfssvc].sy_narg;
sysent[SYS_nfssvc].sy_narg = 2;
nfs_prev_nfssvc_sy_call = sysent[SYS_nfssvc].sy_call;
sysent[SYS_nfssvc].sy_call = (sy_call_t *)nfssvc;
error = syscall_register(&nfssvc_offset, &nfssvc_sysent,
&nfssvc_prev_sysent);
if (error)
break;
registered = 1;
break;
case MOD_UNLOAD:
@ -567,9 +569,10 @@ nfsrv_modevent(module_t mod, int type, void *data)
break;
}
if (registered)
syscall_deregister(&nfssvc_offset, &nfssvc_prev_sysent);
callout_drain(&nfsrv_callout);
sysent[SYS_nfssvc].sy_narg = nfs_prev_nfssvc_sy_narg;
sysent[SYS_nfssvc].sy_call = nfs_prev_nfssvc_sy_call;
nfsrv_destroycache(); /* Free the server request cache */
nfsrv_destroycache(); /* Free the server request cache */
mtx_destroy(&nfsd_mtx);
break;

View File

@ -119,6 +119,14 @@ struct syscall_module_data {
struct sysent old_sysent; /* old sysent */
};
#define MAKE_SYSENT(syscallname) \
static struct sysent syscallname##_sysent = { \
(sizeof(struct syscallname ## _args ) \
/ sizeof(register_t)), \
(sy_call_t *)& syscallname, \
SYS_AUE_##syscallname \
}
#define SYSCALL_MODULE(name, offset, new_sysent, evh, arg) \
static struct syscall_module_data name##_syscall_mod = { \
evh, arg, offset, new_sysent, { 0, NULL, AUE_NULL } \
@ -133,12 +141,7 @@ DECLARE_MODULE(name, name##_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE)
#define SYSCALL_MODULE_HELPER(syscallname) \
static int syscallname##_syscall = SYS_##syscallname; \
static struct sysent syscallname##_sysent = { \
(sizeof(struct syscallname ## _args ) \
/ sizeof(register_t)), \
(sy_call_t *)& syscallname, \
SYS_AUE_##syscallname \
}; \
MAKE_SYSENT(syscallname); \
SYSCALL_MODULE(syscallname, \
& syscallname##_syscall, & syscallname##_sysent, \
NULL, NULL);