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