4 #include "afs/sysincludes.h"
5 #include "afsincludes.h"
7 #define MYBUNDLEID "org.openafs.filesystems.afs"
8 extern struct vfsops afs_vfsops
;
10 #ifdef AFS_DARWIN80_ENV
11 static vfstable_t afs_vfstable
;
12 extern struct vnodeopv_desc afs_vnodeop_opv_desc
;
13 extern struct vnodeopv_desc afs_dead_vnodeop_opv_desc
;
14 static struct vnodeopv_desc
*afs_vnodeop_opv_desc_list
[2] =
15 { &afs_vnodeop_opv_desc
, &afs_dead_vnodeop_opv_desc
};
17 struct vfs_fsentry afs_vfsentry
= {
20 afs_vnodeop_opv_desc_list
,
23 VFS_TBLNOTYPENUM
|VFS_TBLTHREADSAFE
|VFS_TBL64BITREADY
,
29 #include <miscfs/devfs/devfs.h>
30 #define seltrue eno_select
31 struct cdevsw afs_cdev
= NO_CDEVICE
;
33 static int afs_cdev_major
;
34 extern open_close_fcn_t afs_cdev_nop_openclose
;
35 extern ioctl_fcn_t afs_cdev_ioctl
;
36 static void *afs_cdev_devfs_handle
;
38 #include <sys/syscall.h>
39 struct vfsconf afs_vfsconf
;
41 #include <mach/kmod.h>
43 extern struct mount
*afs_globalVFS
;
44 extern int Afs_xsetgroups();
47 extern int setgroups();
48 extern int maxvfsconf
;
50 afs_modload(struct kmod_info
*kmod_info
, void *data
)
54 #ifdef AFS_DARWIN80_ENV
56 afs_global_lock
= lck_mtx_alloc_init(openafs_lck_grp
, 0);
58 if (ret
= vfs_fsadd(&afs_vfsentry
, &afs_vfstable
)) {
59 afs_warn("AFS: vfs_fsadd failed. aborting: %d\n", ret
);
63 afs_cdev
.d_open
= &afs_cdev_nop_openclose
;
64 afs_cdev
.d_close
= &afs_cdev_nop_openclose
;
65 afs_cdev
.d_ioctl
= &afs_cdev_ioctl
;
66 afs_cdev_major
= cdevsw_add(-1, &afs_cdev
);
67 if (afs_cdev_major
== -1) {
68 afs_warn("AFS: cdevsw_add failed. aborting\n");
71 afs_cdev_devfs_handle
= devfs_make_node(makedev(afs_cdev_major
, 0),
72 DEVFS_CHAR
, UID_ROOT
, GID_WHEEL
,
73 0666, "openafs_ioctl", 0);
74 if (!afs_cdev_devfs_handle
) {
75 afs_warn("AFS: devfs_make_node failed. aborting\n");
76 cdevsw_remove(afs_cdev_major
, &afs_cdev
);
78 vfs_fsremove(afs_vfstable
);
81 lck_mtx_free(afs_global_lock
, openafs_lck_grp
);
85 memset(&afs_vfsconf
, 0, sizeof(struct vfsconf
));
86 strcpy(afs_vfsconf
.vfc_name
, "afs");
87 afs_vfsconf
.vfc_vfsops
= &afs_vfsops
;
88 afs_vfsconf
.vfc_typenum
= maxvfsconf
++; /* oddly not VT_AFS */
89 afs_vfsconf
.vfc_flags
= MNT_NODEV
;
90 if (vfsconf_add(&afs_vfsconf
)) {
91 afs_warn("AFS: vfsconf_add failed. aborting\n");
94 if (sysent
[AFS_SYSCALL
].sy_call
!= nosys
) {
95 afs_warn("AFS_SYSCALL in use. aborting\n");
98 sysent
[SYS_setgroups
].sy_call
= Afs_xsetgroups
;
99 sysent
[AFS_SYSCALL
].sy_call
= afs3_syscall
;
100 sysent
[AFS_SYSCALL
].sy_narg
= 5;
101 sysent
[AFS_SYSCALL
].sy_parallel
= 0;
103 sysent
[AFS_SYSCALL
].sy_funnel
= KERNEL_FUNNEL
;
106 afs_warn("%s kext loaded; %u pages at 0x%lx (load tag %u).\n",
107 kmod_info
->name
, (unsigned)kmod_info
->size
/ PAGE_SIZE
,
108 (unsigned long)kmod_info
->address
, (unsigned)kmod_info
->id
);
114 afs_modunload(struct kmod_info
* kmod_info
, void *data
)
118 if ((afs_initState
!= 0) || (afs_shuttingdown
!= AFS_RUNNING
))
120 #ifdef AFS_DARWIN80_ENV
121 if (vfs_fsremove(afs_vfstable
))
123 devfs_remove(afs_cdev_devfs_handle
);
124 cdevsw_remove(afs_cdev_major
, &afs_cdev
);
126 if (vfsconf_del("afs"))
128 /* give up syscall entries for ioctl & setgroups, which we've stolen */
129 sysent
[SYS_setgroups
].sy_call
= setgroups
;
130 /* give up the stolen syscall entry */
131 sysent
[AFS_SYSCALL
].sy_narg
= 0;
132 sysent
[AFS_SYSCALL
].sy_call
= nosys
;
134 #ifdef AFS_DARWIN80_ENV
136 lck_mtx_free(afs_global_lock
, openafs_lck_grp
);
138 afs_warn("%s kext unloaded; (load tag %u).\n",
139 kmod_info
->name
, (unsigned)kmod_info
->id
);
143 KMOD_EXPLICIT_DECL(MYBUNDLEID
, VERSION
, afs_modload
,