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