freebsd-20050429
authorJim Rees <rees@umich.edu>
Fri, 29 Apr 2005 19:24:01 +0000 (19:24 +0000)
committerJim Rees <rees@umich.edu>
Fri, 29 Apr 2005 19:24:01 +0000 (19:24 +0000)
Move module init/uninit code from module event handler to vfs ops
Use VFS_SET for FreeBSD 6.0

src/afs/FBSD/osi_module.c
src/afs/FBSD/osi_prototypes.h
src/afs/FBSD/osi_vfsops.c
src/afs/FBSD/osi_vm.c
src/afs/FBSD/osi_vnodeops.c

index 804a6d9..9b22d20 100644 (file)
@@ -19,23 +19,32 @@ RCSID
 #include <sys/module.h>
 #include <sys/sysproto.h>
 #include <sys/syscall.h>
-#include <sys/sysent.h>
 
 extern struct vfsops afs_vfsops;
 extern struct vnodeopv_desc afs_vnodeop_opv_desc;
 extern struct mount *afs_globalVFS;
-static struct vfsconf afs_vfsconf;
 
 MALLOC_DEFINE(M_AFS, "afsmisc", "memory used by the AFS filesystem");
 
-extern int afs3_syscall();
-extern int Afs_xsetgroups();
-extern int afs_xioctl();
+#ifdef AFS_FBSD60_ENV
+VFS_SET(afs_vfsops, afs, VFCF_NETWORK);
+#else
+int afs_module_handler(module_t mod, int what, void *arg);
+
+static struct vfsconf afs_vfsconf;
+static moduledata_t afs_mod = {
+    "afs",
+    afs_module_handler,
+    &afs_mod
+};
 
+DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE);
+#endif
+
+#ifndef AFS_FBSD60_ENV
 int
 afs_module_handler(module_t mod, int what, void *arg)
 {
-    static sy_call_t *old_handler;
     static int inited = 0;
     int error = 0;
 
@@ -46,12 +55,6 @@ afs_module_handler(module_t mod, int what, void *arg)
            error = EBUSY;
            break;
        }
-       if (sysent[AFS_SYSCALL].sy_call != nosys
-           && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
-           printf("AFS_SYSCALL in use. aborting\n");
-           error = EBUSY;
-           break;
-       }
        memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
 #ifdef AFS_FBSD53_ENV
        afs_vfsconf.vfc_version = VFS_VERSION;
@@ -63,14 +66,6 @@ afs_module_handler(module_t mod, int what, void *arg)
        if ((error = vfs_register(&afs_vfsconf)) != 0)
            break;
        vfs_add_vnodeops(&afs_vnodeop_opv_desc);
-       osi_Init();
-#if 0
-       sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
-       sysent[SYS_ioctl].sy_call = afs_xioctl;
-#endif
-       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:
@@ -83,31 +78,13 @@ afs_module_handler(module_t mod, int what, void *arg)
            error = 0;
            break;
        }
-       if (afs_globalVFS) {
-           error = EBUSY;
-           break;
-       }
        if ((error = vfs_unregister(&afs_vfsconf)) != 0) {
            break;
        }
        vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
-#if 0
-       sysent[SYS_ioctl].sy_call = ioctl;
-       sysent[SYS_setgroups].sy_call = setgroups;
-#endif
-       sysent[AFS_SYSCALL].sy_narg = 0;
-       sysent[AFS_SYSCALL].sy_call = old_handler;
        break;
     }
 
     return (error);
 }
-
-
-static moduledata_t afs_mod = {
-    "afs",
-    afs_module_handler,
-    &afs_mod
-};
-
-DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE);
+#endif
index 8ff1dff..3788f86 100644 (file)
@@ -24,6 +24,8 @@ extern void *osi_fbsd_alloc(size_t size, int dropglobal);
 extern void osi_fbsd_free(void *p);
 
 /* osi_vfsops.c */
+int afs_init(struct vfsconf *vfc);
+int afs_uninit(struct vfsconf *vfc);
 #ifdef AFS_FBSD50_ENV
 extern int afs_statfs(struct mount *mp, struct statfs *abp, struct thread *th);
 #else
index 25d6a9a..18138c5 100644 (file)
@@ -10,7 +10,10 @@ RCSID
 #include <sys/malloc.h>
 #include <sys/namei.h>
 #include <sys/conf.h>
+#include <sys/module.h>
+#include <sys/sysproto.h>
 #include <sys/syscall.h>
+#include <sys/sysent.h>
 
 struct vcache *afs_globalVp = NULL;
 struct mount *afs_globalVFS = NULL;
@@ -22,10 +25,50 @@ 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();
+
+static sy_call_t *old_handler;
+
+
 int
-afs_start(struct mount *mp, int flags, THREAD_OR_PROC)
+afs_init(struct vfsconf *vfc)
 {
+    if (sysent[AFS_SYSCALL].sy_call != nosys
+       && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
+       printf("AFS_SYSCALL in use. aborting\n");
+       return EBUSY;
+    }
+    osi_Init();
     afs_pbuf_freecnt = nswbuf / 2 + 1;
+#if 0
+    sysent[SYS_setgroups].sy_call = Afs_xsetgroups;
+    sysent[SYS_ioctl].sy_call = afs_xioctl;
+#endif
+    old_handler = sysent[AFS_SYSCALL].sy_call;
+    sysent[AFS_SYSCALL].sy_call = afs3_syscall;
+    sysent[AFS_SYSCALL].sy_narg = 5;
+    return 0;
+}
+
+int
+afs_uninit(struct vfsconf *vfc)
+{
+    if (afs_globalVFS)
+       return EBUSY;
+#if 0
+    sysent[SYS_ioctl].sy_call = ioctl;
+    sysent[SYS_setgroups].sy_call = setgroups;
+#endif
+    sysent[AFS_SYSCALL].sy_narg = 0;
+    sysent[AFS_SYSCALL].sy_call = old_handler;
+    return 0;
+}
+
+int
+afs_start(struct mount *mp, int flags, THREAD_OR_PROC)
+{
     return (0);                        /* nothing to do. ? */
 }
 
@@ -228,12 +271,6 @@ afs_sync(struct mount *mp, int waitfor, struct ucred *cred, THREAD_OR_PROC)
     return 0;
 }
 
-int
-afs_init(struct vfsconf *vfc)
-{
-    return 0;
-}
-
 #ifdef AFS_FBSD60_ENV
 struct vfsops afs_vfsops = {
        .vfs_init =             afs_init,
@@ -242,7 +279,7 @@ struct vfsops afs_vfsops = {
        .vfs_root =             afs_root,
        .vfs_statfs =           afs_statfs,
        .vfs_sync =             afs_sync,
-       .vfs_uninit =           vfs_stduninit,
+       .vfs_uninit =           afs_uninit,
        .vfs_unmount =          afs_unmount,
        .vfs_sysctl =           vfs_stdsysctl,
 };
@@ -263,7 +300,7 @@ struct vfsops afs_vfsops = {
     vfs_stdcheckexp,
     vfs_stdvptofh,
     afs_init,
-    vfs_stduninit,
+    afs_uninit,
     vfs_stdextattrctl,
 #ifdef AFS_FBSD50_ENV
     vfs_stdsysctl,
index 1b57c76..5634658 100644 (file)
@@ -48,6 +48,10 @@ RCSID
  * rather than an explicit lock.
  */
 
+#ifdef AFS_FBSD60_ENV
+#define VOP_GETVOBJECT(vp, objp) (*(objp) = (vp)->v_object)
+#endif
+
 #ifdef AFS_FBSD50_ENV
 #define        lock_vnode(v)   vn_lock((v), LK_EXCLUSIVE | LK_RETRY, curthread)
 #define unlock_vnode(v)        VOP_UNLOCK((v), 0, curthread)
index 300e610..4f53581 100644 (file)
@@ -491,15 +491,17 @@ afs_vop_open(ap)
                                 * } */ *ap;
 {
     int error;
-    int bad;
     struct vcache *vc = VTOAFS(ap->a_vp);
-    bad = 0;
+
     AFS_GLOCK();
     error = afs_open(&vc, ap->a_mode, ap->a_cred);
 #ifdef DIAGNOSTIC
     if (AFSTOV(vc) != ap->a_vp)
        panic("AFS open changed vnode!");
 #endif
+#ifdef AFS_FBSD60_ENV
+    vnode_create_vobject(ap->a_vp, vc->m.Length, ap->a_td);
+#endif
     osi_FlushPages(vc, ap->a_cred);
     AFS_GUNLOCK();
     return error;