macos103-update-20050403
[openafs.git] / src / afs / DARWIN / osi_module.c
1 #include <afsconfig.h>
2 #include "afs/param.h"
3
4 RCSID
5     ("$Header$");
6
7 #include "afs/sysincludes.h"
8 #include "afsincludes.h"
9 #ifdef AFS_DARWIN60_ENV         /* not in Kernel.framework anymore !?! */
10 #include <sys/syscall.h>
11 #else
12 #include "sys/syscall.h"
13 #endif
14 #include <mach/kmod.h>
15
16 struct vfsconf afs_vfsconf;
17 extern struct vfsops afs_vfsops;
18 extern struct mount *afs_globalVFS;
19 extern int Afs_xsetgroups();
20 extern int afs_xioctl();
21 extern int afs3_syscall();
22
23 extern int ioctl();
24 extern int setgroups();
25 extern int maxvfsconf;
26 kern_return_t
27 afs_modload(struct kmod_info *ki, void *data)
28 {
29     if (sysent[AFS_SYSCALL].sy_call != nosys) {
30         printf("AFS_SYSCALL in use. aborting\n");
31         return KERN_FAILURE;
32     }
33     memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
34     strcpy(afs_vfsconf.vfc_name, "afs");
35     afs_vfsconf.vfc_vfsops = &afs_vfsops;
36     afs_vfsconf.vfc_typenum = maxvfsconf++;     /* oddly not VT_AFS */
37     afs_vfsconf.vfc_flags = MNT_NODEV;
38     if (vfsconf_add(&afs_vfsconf)) {
39         printf("AFS: vfsconf_add failed. aborting\n");
40         return KERN_FAILURE;
41     }
42     sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
43 #if 0
44     sysent[SYS_ioctl].sy_call = afs_xioctl;
45 #endif
46     sysent[AFS_SYSCALL].sy_call = afs3_syscall;
47     sysent[AFS_SYSCALL].sy_narg = 5;
48     sysent[AFS_SYSCALL].sy_parallel = 0;
49 #ifdef KERNEL_FUNNEL
50     sysent[AFS_SYSCALL].sy_funnel = KERNEL_FUNNEL;
51 #endif
52     return KERN_SUCCESS;
53 }
54
55 kern_return_t
56 afs_modunload(struct kmod_info * ki, void *data)
57 {
58     if (afs_globalVFS)
59         return KERN_FAILURE;
60     if (vfsconf_del("afs"))
61         return KERN_FAILURE;
62     /* give up syscall entries for ioctl & setgroups, which we've stolen */
63 #if 0
64     sysent[SYS_ioctl].sy_call = ioctl;
65 #endif
66     sysent[SYS_setgroups].sy_call = setgroups;
67     /* give up the stolen syscall entry */
68     sysent[AFS_SYSCALL].sy_narg = 0;
69     sysent[AFS_SYSCALL].sy_call = nosys;
70     return KERN_SUCCESS;
71 }
72
73 KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload,
74                    afs_modunload)