+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License. For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+#include <afsconfig.h>
#include <afs/param.h>
+
+RCSID("$Header$");
+
#include <afs/sysincludes.h>
#include <afsincludes.h>
#include <sys/module.h>
extern int Afs_xsetgroups();
extern int afs_xioctl();
-int afs_module_handler(module_t mod, int what, void *arg) {
- static sy_call_t *old_handler;
- static int inited=0;
- int error;
- error=0;
- switch (what) {
- case MOD_LOAD:
- if (inited) {
- printf ("afs cannot be MOD_LOAD'd more than once\n");
- error=-1;
- break;
- }
- if (sysent[AFS_SYSCALL].sy_call != nosys &&
- sysent[AFS_SYSCALL].sy_call != lkmnosys) {
- printf("AFS_SYSCALL in use. aborting\n");
- error=-1;
- break;
- }
- memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
- strcpy(afs_vfsconf.vfc_name, "AFS");
- afs_vfsconf.vfc_vfsops=&afs_vfsops;
- afs_vfsconf.vfc_typenum=-1; /* set by vfs_register */
- afs_vfsconf.vfc_flags=VFCF_NETWORK;
- vfs_register(&afs_vfsconf); /* doesn't fail */
- vfs_add_vnodeops(&afs_vnodeop_opv_desc);
- osi_Init();
- sysent[SYS_setgroups].sy_call=Afs_xsetgroups;
- sysent[SYS_ioctl].sy_call=afs_xioctl;
- old_handler=sysent[AFS_SYSCALL].sy_call;
- sysent[AFS_SYSCALL].sy_call=afs3_syscall;
- sysent[AFS_SYSCALL].sy_narg = 5;
- inited=1;
- break;
- case MOD_UNLOAD:
+int
+afs_module_handler(module_t mod, int what, void *arg)
+{
+ static sy_call_t *old_handler;
+ static int inited = 0;
+ int error;
+ error = 0;
+ switch (what) {
+ case MOD_LOAD:
+ if (inited) {
+ printf("afs cannot be MOD_LOAD'd more than once\n");
+ error = -1;
+ break;
+ }
+ if (sysent[AFS_SYSCALL].sy_call != nosys &&
+ sysent[AFS_SYSCALL].sy_call != lkmnosys) {
+ printf("AFS_SYSCALL in use. aborting\n");
+ error = -1;
+ break;
+ }
+ memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
+ strcpy(afs_vfsconf.vfc_name, "AFS");
+ afs_vfsconf.vfc_vfsops = &afs_vfsops;
+ afs_vfsconf.vfc_typenum = -1; /* set by vfs_register */
+ afs_vfsconf.vfc_flags = VFCF_NETWORK;
+ vfs_register(&afs_vfsconf); /* doesn't fail */
+ vfs_add_vnodeops(&afs_vnodeop_opv_desc);
+ osi_Init();
+ sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
+ sysent[SYS_ioctl].sy_call = afs_xioctl;
+ old_handler = sysent[AFS_SYSCALL].sy_call;
+ sysent[AFS_SYSCALL].sy_call = afs3_syscall;
+ sysent[AFS_SYSCALL].sy_narg = 5;
+ inited = 1;
+ break;
+ case MOD_UNLOAD:
#ifndef RXK_LISTENER_ENV
- /* shutdown is incomplete unless RXK_LISTENER_ENV */
- printf("afs: I can't be unloaded yet\n");
- return -1;
+ /* shutdown is incomplete unless RXK_LISTENER_ENV */
+ printf("afs: I can't be unloaded yet\n");
+ return -1;
#endif
- if (! inited) {
- error=0;
- break;
- }
- if (afs_globalVFS) {
- error=-1;
- break;
- }
- if (vfs_unregister(&afs_vfsconf)) {
- error=-1;
- break;
- }
- vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
- sysent[SYS_ioctl].sy_call = ioctl;
- sysent[SYS_setgroups].sy_call = setgroups;
- sysent[AFS_SYSCALL].sy_narg = 0;
- sysent[AFS_SYSCALL].sy_call = old_handler;
- break;
- }
+ if (!inited) {
+ error = 0;
+ break;
+ }
+ if (afs_globalVFS) {
+ error = -1;
+ break;
+ }
+ if (vfs_unregister(&afs_vfsconf)) {
+ error = -1;
+ break;
+ }
+ vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
+ sysent[SYS_ioctl].sy_call = ioctl;
+ sysent[SYS_setgroups].sy_call = setgroups;
+ sysent[AFS_SYSCALL].sy_narg = 0;
+ sysent[AFS_SYSCALL].sy_call = old_handler;
+ break;
+ }
- return (error);
+ return (error);
}
static moduledata_t afs_mod = {
- "afs",
- afs_module_handler,
- &afs_mod
+ "afs",
+ afs_module_handler,
+ &afs_mod
};
DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE);
-
#endif /* AFS_GLOBAL_SUNLOCK */
#endif /* AFS_HPUX_ENV */
- if ( !afs_osicred_initialized ) {
- memset((char *)&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
+ if (!afs_osicred_initialized) {
+ memset(&afs_osi_cred, 0, sizeof(struct AFS_UCRED));
+#ifdef AFS_FBSD50_ENV
+ /*
+ * We don't init the mutex.
+ * This will be trouble if anyone tries to use change the refcount.
+ * Proper fix would be to make afs_osi_cred into a pointer,
+ * and crdup() it from curthread.
+ */
+ afs_osi_cred.cr_ref = 1;
+#else
crhold(&afs_osi_cred); /* don't let it evaporate */
+#endif
afs_osicred_initialized = 1;
}
+
#ifdef AFS_SGI64_ENV
osi_flid.fl_pid = osi_flid.fl_sysid = 0;
#endif
#ifdef AFS_OBSD_ENV
#include "h/syscallargs.h"
#endif
+#ifdef AFS_FBSD50_ENV
+#include "h/sysproto.h"
+#endif
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#include "afs/vice.h"
u_long com;
caddr_t arg;
} *uap = (struct a *)args;
+#elif defined(AFS_FBSD50_ENV)
+#define arg data
+int
+afs_xioctl(td, uap, retval)
+ struct thread *td;
+ register struct ioctl_args *uap;
+ register_t *retval;
+{
+ struct proc *p = td->td_proc;
#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
struct ioctl_args {
int fd;
return EBADF;
if ((fd->f_flag & (FREAD | FWRITE)) == 0)
return EBADF;
-#else
-#if defined(AFS_DARWIN_ENV)
+#elif defined(AFS_DARWIN_ENV)
if ((code=fdgetf(p, uap->fd, &fd)))
return code;
-#else
-#ifdef AFS_LINUX22_ENV
+#elif defined(AFS_LINUX22_ENV)
ua.com = com;
ua.arg = arg;
-#else
-#ifdef AFS_AIX32_ENV
+#elif defined(AFS_AIX32_ENV)
uap->fd = fdes;
uap->com = com;
uap->arg = arg;
uap->arg2 = arg2;
uap->arg3 = arg3;
#endif
-
if (setuerror(getf(uap->fd, &fd))) {
return -1;
}
-#else
-#ifdef AFS_OSF_ENV
+#elif defined(AFS_OSF_ENV)
fd = NULL;
if (code = getf(&fd, uap->fd, FILE_FLAGS_NULL, &u.u_file_state))
return code;
-#else /* AFS_OSF_ENV */
-#ifdef AFS_SUN5_ENV
-#if defined(AFS_SUN57_ENV)
+#elif defined(AFS_SUN5_ENV)
+# if defined(AFS_SUN57_ENV)
fd = getf(uap->fd);
if (!fd) return(EBADF);
-#elif defined(AFS_SUN54_ENV)
+# elif defined(AFS_SUN54_ENV)
fd = GETF(uap->fd);
if (!fd) return(EBADF);
-#else
+# else
if (code = getf(uap->fd, &fd)) {
return (code);
}
-#endif
+# endif /* AFS_SUN57_ENV */
#else
fd = getf(uap->fd);
if (!fd) return(EBADF);
-#endif
-#endif
-#endif
-#endif
-#endif
#endif
/* first determine whether this is any sort of vnode */
#if defined(AFS_LINUX22_ENV)
releasef(fd);
#endif
code = ioctl(uap, rvp);
+#elif defined(AFS_FBSD50_ENV)
+ return ioctl(td, uap);
#elif defined(AFS_FBSD_ENV)
return ioctl(p, uap);
#elif defined(AFS_OBSD_ENV)