summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/nfsserver/nfs_srvsubs.c21
-rw-r--r--sys/sys/sysent.h15
2 files changed, 21 insertions, 15 deletions
diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c
index b064fb3..374bf26 100644
--- a/sys/nfsserver/nfs_srvsubs.c
+++ b/sys/nfsserver/nfs_srvsubs.c
@@ -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;
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index e631f04..edf1717 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -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);
OpenPOWER on IntegriCloud