2 * Copyright (c) 2011 Jonathan A. Kollasch
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
16 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <afsconfig.h>
28 #include "afs/param.h"
30 #include <sys/cdefs.h>
31 #include <sys/param.h>
32 #include <sys/types.h>
33 #include <sys/kernel.h>
34 #if !defined(AFS_NBSD60_ENV)
37 #include <sys/module.h>
38 #include <sys/systm.h>
39 #include <sys/syscall.h>
40 #include <sys/syscallargs.h>
41 #include <sys/syscallvar.h>
43 #include "afs/sysincludes.h" /* Standard vendor system headers */
44 #include "afs/afsincludes.h" /* Afs-based standard headers */
46 extern int afs3_syscall(struct lwp
*, const void *, register_t
*);
47 extern int afs_xioctl(struct lwp
*, const void *, register_t
*);
48 extern int Afs_xsetgroups(struct lwp
*, const void *, register_t
*);
50 #if !defined(AFS_NBSD60_ENV)
51 extern int sys_lkmnosys(struct lwp
*, const void *, register_t
*);
54 extern struct vfsops afs_vfsops
;
56 static const struct sysent openafs_sysent
= {
57 sizeof(struct afs_sysargs
)/sizeof(register_t
),
58 sizeof(struct afs_sysargs
),
63 static struct sysent old_sysent
;
64 static sy_call_t
*old_setgroups
;
65 static sy_call_t
*old_ioctl
;
67 MODULE(MODULE_CLASS_VFS
, openafs
, NULL
);
69 #if defined(AFS_NBSD70_ENV)
70 #define SYS_NOSYSCALL sys_nomodule
71 #elif defined(AFS_NBSD60_ENV)
72 #define SYS_NOSYSCALL sys_nosys
74 #define SYS_NOSYSCALL sys_lkmnosys
78 openafs_modcmd(modcmd_t cmd
, void *arg
)
86 se
= emul_netbsd
.e_sysent
;
91 error
= vfs_attach(&afs_vfsops
);
94 old_sysent
= se
[AFS_SYSCALL
];
95 old_setgroups
= se
[SYS_setgroups
].sy_call
;
96 old_ioctl
= se
[SYS_ioctl
].sy_call
;
101 if (old_sysent
.sy_call
== SYS_NOSYSCALL
) {
103 #if defined(AFS_NBSD60_ENV)
106 se
[AFS_SYSCALL
] = openafs_sysent
;
107 se
[SYS_setgroups
].sy_call
= Afs_xsetgroups
;
108 se
[SYS_ioctl
].sy_call
= afs_xioctl
;
109 #if defined(AFS_NBSD60_ENV)
118 case MODULE_CMD_FINI
:
119 #if defined(AFS_NBSD60_ENV)
122 se
[SYS_ioctl
].sy_call
= old_ioctl
;
123 se
[SYS_setgroups
].sy_call
= old_setgroups
;
124 se
[AFS_SYSCALL
] = old_sysent
;
125 #if defined(AFS_NBSD60_ENV)
128 error
= vfs_detach(&afs_vfsops
);
132 #if defined(AFS_NBSD70_ENV)
133 case MODULE_CMD_AUTOUNLOAD
: