From fcce9a4727d80762552c10075b03a48ecd40edac Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Sun, 3 Jan 2010 19:01:47 -0500 Subject: [PATCH] darwin module prototype and cleanup tidy up the osi_module and osi_misc prototyping, and the error checking and returns at module load time. side effect: also use the afs3_syscall prototype for the BSDs. Change-Id: I373f44f3b5999dc05ba23f09c74149aaf237edcc Reviewed-on: http://gerrit.openafs.org/1056 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/DARWIN/osi_misc.c | 2 -- src/afs/DARWIN/osi_module.c | 35 +++++++++++++++-------------------- src/afs/FBSD/osi_vfsops.c | 1 - src/afs/NBSD/osi_vfsops.c | 2 +- src/afs/OBSD/osi_vfsops.c | 2 +- src/afs/afs_prototypes.h | 11 +++++++++++ 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/afs/DARWIN/osi_misc.c b/src/afs/DARWIN/osi_misc.c index 076d567..a90c24b 100644 --- a/src/afs/DARWIN/osi_misc.c +++ b/src/afs/DARWIN/osi_misc.c @@ -202,8 +202,6 @@ afs_cdev_nop_openclose(dev_t dev, int flags, int devtype,struct proc *p) return 0; } -extern int afs3_syscall(struct proc *p, void *data, unsigned int *retval); - int afs_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct proc *p) { unsigned int retval=0; diff --git a/src/afs/DARWIN/osi_module.c b/src/afs/DARWIN/osi_module.c index 5991b06..18711f5 100644 --- a/src/afs/DARWIN/osi_module.c +++ b/src/afs/DARWIN/osi_module.c @@ -1,9 +1,10 @@ #include #include "afs/param.h" - #include "afs/sysincludes.h" #include "afsincludes.h" + +#define MYBUNDLEID "org.openafs.filesystems.afs" #ifdef AFS_DARWIN80_ENV static vfstable_t afs_vfstable; static struct vfs_fsentry afs_vfsentry; @@ -12,7 +13,6 @@ extern struct vnodeopv_desc afs_dead_vnodeop_opv_desc; static struct vnodeopv_desc *afs_vnodeop_opv_desc_list[2] = { &afs_vnodeop_opv_desc, &afs_dead_vnodeop_opv_desc }; - #include #include #define seltrue eno_select @@ -35,8 +35,6 @@ struct vfsconf afs_vfsconf; extern struct vfsops afs_vfsops; extern struct mount *afs_globalVFS; extern int Afs_xsetgroups(); -extern int afs_xioctl(); -extern int afs3_syscall(); extern int ioctl(); extern int setgroups(); @@ -56,9 +54,7 @@ afs_modload(struct kmod_info *ki, void *data) afs_vfsentry.vfe_flags = VFS_TBLTHREADSAFE|VFS_TBLNOTYPENUM|VFS_TBL64BITREADY; if (vfs_fsadd(&afs_vfsentry, &afs_vfstable)) { printf("AFS: vfs_fsadd failed. aborting\n"); - MUTEX_FINISH(); - lck_mtx_free(afs_global_lock, openafs_lck_grp); - return KERN_FAILURE; + goto fsadd_out; } afs_cdev.d_open = &afs_cdev_nop_openclose; afs_cdev.d_close = &afs_cdev_nop_openclose; @@ -66,14 +62,21 @@ afs_modload(struct kmod_info *ki, void *data) afs_cdev_major = cdevsw_add(-1, &afs_cdev); if (afs_cdev_major == -1) { printf("AFS: cdevsw_add failed. aborting\n"); - vfs_fsremove(afs_vfstable); - MUTEX_FINISH(); - lck_mtx_free(afs_global_lock, openafs_lck_grp); - return KERN_FAILURE; + goto cdevsw_out; } afs_cdev_devfs_handle = devfs_make_node(makedev(afs_cdev_major, 0), DEVFS_CHAR, UID_ROOT, GID_WHEEL, 0666, "openafs_ioctl", 0); + if (!afs_cdev_devfs_handle) { + printf("AFS: devfs_make_node failed. aborting\n"); + cdevsw_remove(afs_cdev_major, &afs_cdev); + cdevsw_out: + vfs_fsremove(afs_vfstable); + fsadd_out: + MUTEX_FINISH(); + lck_mtx_free(afs_global_lock, openafs_lck_grp); + return KERN_FAILURE; + } #else memset(&afs_vfsconf, 0, sizeof(struct vfsconf)); strcpy(afs_vfsconf.vfc_name, "afs"); @@ -89,9 +92,6 @@ afs_modload(struct kmod_info *ki, void *data) return KERN_FAILURE; } sysent[SYS_setgroups].sy_call = Afs_xsetgroups; -#if 0 - sysent[SYS_ioctl].sy_call = afs_xioctl; -#endif sysent[AFS_SYSCALL].sy_call = afs3_syscall; sysent[AFS_SYSCALL].sy_narg = 5; sysent[AFS_SYSCALL].sy_parallel = 0; @@ -116,12 +116,7 @@ afs_modunload(struct kmod_info * ki, void *data) if (vfsconf_del("afs")) return KERN_FAILURE; /* give up syscall entries for ioctl & setgroups, which we've stolen */ -#if 0 - sysent[SYS_ioctl].sy_call = ioctl; -#endif -#ifndef AFS_DARWIN80_ENV sysent[SYS_setgroups].sy_call = setgroups; -#endif /* give up the stolen syscall entry */ sysent[AFS_SYSCALL].sy_narg = 0; sysent[AFS_SYSCALL].sy_call = nosys; @@ -133,5 +128,5 @@ afs_modunload(struct kmod_info * ki, void *data) return KERN_SUCCESS; } -KMOD_EXPLICIT_DECL(org.openafs.filesystems.afs, VERSION, afs_modload, +KMOD_EXPLICIT_DECL(MYBUNDLEID, VERSION, afs_modload, afs_modunload) diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c index 6ae76a6..8f97ae0 100644 --- a/src/afs/FBSD/osi_vfsops.c +++ b/src/afs/FBSD/osi_vfsops.c @@ -23,7 +23,6 @@ int afs_pbuf_freecnt = -1; #define THREAD_OR_PROC struct proc *p #endif -extern int afs3_syscall(); extern int Afs_xsetgroups(); extern int afs_xioctl(); diff --git a/src/afs/NBSD/osi_vfsops.c b/src/afs/NBSD/osi_vfsops.c index 361d6e3..5e5180c 100644 --- a/src/afs/NBSD/osi_vfsops.c +++ b/src/afs/NBSD/osi_vfsops.c @@ -482,7 +482,7 @@ afs_configure(cfg_op_t op, caddr_t indata, size_t indata_size, int mp_Afs_init(void) { - extern int Afs_xsetgroups(), afs_xioctl(), afs3_syscall(); + extern int Afs_xsetgroups(), afs_xioctl(); AFS_GLOCK(); sysent[AFS_SYSCALL].sy_call = afs3_syscall; diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c index 6daaf5d..40baec0 100644 --- a/src/afs/OBSD/osi_vfsops.c +++ b/src/afs/OBSD/osi_vfsops.c @@ -108,7 +108,7 @@ NONINFRINGEMENT. /* from /usr/src/sys/kern/vfs_subr.c */ extern void insmntque(struct vnode *, struct mount *); -extern int sys_lkmnosys(), afs3_syscall(), afs_xioctl(), Afs_xsetgroups(); +extern int sys_lkmnosys(), afs_xioctl(), Afs_xsetgroups(); static int lkmid = -1; static int afs_badcall(struct proc *p, void *xx, register_t * yy); diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 2e37ef7..6fed266 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -879,6 +879,17 @@ extern int copyin_afs_ioctl(user_addr_t cmarg, struct afs_ioctl *dst); #else extern int copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst); #endif + +#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) +#ifdef AFS_DARWIN100_ENV +extern int afs3_syscall(afs_proc_t *p, void *args, unsigned int *retval); +#elif defined(AFS_FBSD50_ENV) +extern int afs3_syscall(struct thread *p, void *args, long *retval); +#else +extern int afs3_syscall(afs_proc_t *p, void *args, long *retval); +#endif +#endif + #ifdef UKERNEL extern int Afs_syscall(void); #endif -- 1.9.4