freebsd-20030701
authorJim Rees <rees@umich.edu>
Tue, 1 Jul 2003 19:06:38 +0000 (19:06 +0000)
committerJim Rees <rees@umich.edu>
Tue, 1 Jul 2003 19:06:38 +0000 (19:06 +0000)
freebsd: eliminate unresolved symbols
kernel module loads now, but doesn't get very far

src/afs/FBSD/osi_file.c
src/afs/FBSD/osi_machdep.h
src/afs/FBSD/osi_misc.c
src/afs/FBSD/osi_prototypes.h
src/afs/FBSD/osi_sleep.c
src/afs/FBSD/osi_vfsops.c
src/afs/FBSD/osi_vnodeops.c
src/afs/afs_osi.c
src/afs/afs_vcache.c
src/libafs/MakefileProto.FBSD.in

index 22fc559..629f7f7 100644 (file)
@@ -14,17 +14,18 @@ RCSID("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
-#include "afs/afs_stats.h"  /* afs statistics */
+#include "afs/afs_stats.h"     /* afs statistics */
 
 
-int afs_osicred_initialized=0;
-struct  AFS_UCRED afs_osi_cred;
+int afs_osicred_initialized = 0;
+struct AFS_UCRED afs_osi_cred;
 afs_lock_t afs_xosi;           /* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct mount *afs_cacheVfsp;
 
 
-void *osi_UFSOpen(afs_int32 ainode)
+void *
+osi_UFSOpen(afs_int32 ainode)
 {
     struct inode *ip;
     register struct osi_file *afile = NULL;
@@ -32,7 +33,7 @@ void *osi_UFSOpen(afs_int32 ainode)
     afs_int32 code = 0;
     int dummy;
     AFS_STATCNT(osi_UFSOpen);
-    if(cacheDiskType != AFS_FCACHE_TYPE_UFS) {
+    if (cacheDiskType != AFS_FCACHE_TYPE_UFS) {
        osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
@@ -41,31 +42,42 @@ void *osi_UFSOpen(afs_int32 ainode)
        afs_osi_cred.cr_ref++;
        afs_osicred_initialized = 1;
     }
-    afile = (struct osi_file *) osi_AllocSmallSpace(sizeof(struct osi_file));
+    afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
-    code = igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t)ainode, &ip, &dummy);
+    code =
+       igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip,
+                 &dummy);
     AFS_GLOCK();
     if (code) {
        osi_FreeSmallSpace(afile);
        osi_Panic("UFSOpen: igetinode failed");
     }
     afile->vnode = ITOV(ip);
+#if defined(AFS_FBSD50_ENV)
+    VOP_UNLOCK(afile->vnode, 0, curthread);
+#else
     VOP_UNLOCK(afile->vnode, 0, curproc);
+#endif
     afile->size = VTOI(afile->vnode)->i_size;
     afile->offset = 0;
-    afile->proc = (int (*)()) 0;
-    afile->inum = ainode;        /* for hint validity checking */
+    afile->proc = (int (*)())0;
+    afile->inum = ainode;      /* for hint validity checking */
     return (void *)afile;
 }
 
-int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
+int
+afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *astat)
 {
     register afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    MObtainWriteLock(&afs_xosi,320);
+    MObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
-    code=VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, curproc);
+#if defined(AFS_FBSD50_ENV)
+    code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, curthread);
+#else
+    code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, curproc);
+#endif
     AFS_GLOCK();
     if (code == 0) {
        astat->size = tvattr.va_size;
@@ -77,18 +89,20 @@ int afs_osi_Stat(register struct osi_file *afile, register struct osi_stat *asta
     return code;
 }
 
-int osi_UFSClose(register struct osi_file *afile)
-  {
-      AFS_STATCNT(osi_Close);
-      if(afile->vnode) {
+int
+osi_UFSClose(register struct osi_file *afile)
+{
+    AFS_STATCNT(osi_Close);
+    if (afile->vnode) {
        AFS_RELE(afile->vnode);
-      }
-      
-      osi_FreeSmallSpace(afile);
-      return 0;
-  }
+    }
+
+    osi_FreeSmallSpace(afile);
+    return 0;
+}
 
-int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
+int
+osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
 {
     struct vattr tvattr;
     register afs_int32 code;
@@ -100,26 +114,34 @@ int osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
      * small enough.  Check now and save some time.
      */
     code = afs_osi_Stat(afile, &tstat);
-    if (code || tstat.size <= asize) return code;
-    MObtainWriteLock(&afs_xosi,321);    
+    if (code || tstat.size <= asize)
+       return code;
+    MObtainWriteLock(&afs_xosi, 321);
     VATTR_NULL(&tvattr);
     tvattr.va_size = asize;
     AFS_GUNLOCK();
-    code=VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, curproc);
+#if defined(AFS_FBSD50_ENV)
+    code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, curthread);
+#else
+    code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, curproc);
+#endif
     AFS_GLOCK();
     MReleaseWriteLock(&afs_xosi);
     return code;
 }
 
-void osi_DisableAtimes(struct vnode *avp)
+void
+osi_DisableAtimes(struct vnode *avp)
 {
-   struct inode *ip = VTOI(avp);
-   ip->i_flag &= ~IN_ACCESS;
+    struct inode *ip = VTOI(avp);
+    ip->i_flag &= ~IN_ACCESS;
 }
 
 
 /* Generic read interface */
-int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
+            afs_int32 asize)
 {
     unsigned int resid;
     register afs_int32 code;
@@ -129,55 +151,60 @@ int afs_osi_Read(register struct osi_file *afile, int offset, void *aptr, afs_in
       * If the osi_file passed in is NULL, panic only if AFS is not shutting
       * down. No point in crashing when we are already shutting down
       */
-    if ( !afile ) {
-       if ( !afs_shuttingdown )
+    if (!afile) {
+       if (!afs_shuttingdown)
            osi_Panic("osi_Read called with null param");
        else
            return EIO;
     }
 
-    if (offset != -1) afile->offset = offset;
+    if (offset != -1)
+       afile->offset = offset;
     AFS_GUNLOCK();
-    code = gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                  AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+    code =
+       gop_rdwr(UIO_READ, afile->vnode, (caddr_t) aptr, asize, afile->offset,
+                AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
     AFS_GLOCK();
     if (code == 0) {
        code = asize - resid;
        afile->offset += code;
        osi_DisableAtimes(afile->vnode);
-    }
-    else {
+    } else {
        afs_Trace2(afs_iclSetp, CM_TRACE_READFAILED, ICL_TYPE_INT32, resid,
-                ICL_TYPE_INT32, code);
+                  ICL_TYPE_INT32, code);
        code = -1;
     }
     return code;
 }
 
 /* Generic write interface */
-int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr, afs_int32 asize)
+int
+afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
+             afs_int32 asize)
 {
     unsigned int resid;
     register afs_int32 code;
     AFS_STATCNT(osi_Write);
-    if ( !afile )
-        osi_Panic("afs_osi_Write called with null param");
-    if (offset != -1) afile->offset = offset;
+    if (!afile)
+       osi_Panic("afs_osi_Write called with null param");
+    if (offset != -1)
+       afile->offset = offset;
     {
        AFS_GUNLOCK();
-       code = gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize, afile->offset,
-                  AFS_UIOSYS, IO_UNIT, &afs_osi_cred, &resid);
+       code =
+           gop_rdwr(UIO_WRITE, afile->vnode, (caddr_t) aptr, asize,
+                    afile->offset, AFS_UIOSYS, IO_UNIT, &afs_osi_cred,
+                    &resid);
        AFS_GLOCK();
     }
     if (code == 0) {
        code = asize - resid;
        afile->offset += code;
-    }
-    else {
+    } else {
        code = -1;
     }
     if (afile->proc) {
-       (*afile->proc)(afile, code);
+       (*afile->proc) (afile, code);
     }
     return code;
 }
@@ -186,7 +213,8 @@ int afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
 /*  This work should be handled by physstrat in ca/machdep.c.
     This routine written from the RT NFS port strategy routine.
     It has been generalized a bit, but should still be pretty clear. */
-int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp)
+int
+afs_osi_MapStrategy(int (*aproc) (), register struct buf *bp)
 {
     afs_int32 returnCode;
 
@@ -198,13 +226,13 @@ int afs_osi_MapStrategy(int (*aproc)(), register struct buf *bp)
 
 
 
-void shutdown_osifile(void)
+void
+shutdown_osifile(void)
 {
-  extern int afs_cold_shutdown;
+    extern int afs_cold_shutdown;
 
-  AFS_STATCNT(shutdown_osifile);
-  if (afs_cold_shutdown) {
-    afs_osicred_initialized = 0;
-  }
+    AFS_STATCNT(shutdown_osifile);
+    if (afs_cold_shutdown) {
+       afs_osicred_initialized = 0;
+    }
 }
-
index da0f7a9..694f0e5 100644 (file)
 /* #include <kern/sched_prim.h> */
 /* #include <sys/unix_defs.h> */
 
-#ifndef AFS_FBSD50_ENV
-#define getpid()               curproc
-#endif
 extern struct simplelock afs_rxglobal_lock;
 
 /* 
  * Time related macros
  */
-#define osi_Time() time_second
-#define        afs_hz      hz
+#define osi_Time()     time_second
+#define        afs_hz          hz
 
 #define PAGESIZE 8192
 
 #define        AFS_UCRED       ucred
 #define        AFS_PROC        struct proc
-#ifdef AFS_FBSD50_ENV
-#define osi_curcred()  (curthread->td_ucred)
-#else
-#define osi_curcred()  (curproc->p_cred->pc_ucred)
-#endif
 
 #define afs_bufferpages bufpages
+#ifndef iodone
+#define iodone biodone
+#endif
 
 #define osi_vnhold(avc,r) do { VN_HOLD((struct vnode *)(avc)); } while (0)
 
@@ -54,6 +49,8 @@ extern struct simplelock afs_rxglobal_lock;
 
 #undef afs_suser
 
+#define afs_strcat(s1, s2)     strcat((s1), (s2))
+
 #ifdef KERNEL
 extern struct lock afs_global_lock;
 
@@ -61,6 +58,7 @@ extern struct lock afs_global_lock;
 #define VT_AFS         "afs"
 #define VROOT          VV_ROOT
 #define v_flag         v_vflag
+#define osi_curcred()  (curthread->td_ucred)
 #define afs_suser()    (!suser(curthread))
 #define simple_lock(x) mtx_lock(x)
 #define simple_unlock(x) mtx_unlock(x)
@@ -85,6 +83,8 @@ extern struct thread * afs_global_owner;
 
 #else /* FBSD50 */
 
+#define osi_curcred()  (curproc->p_cred->pc_ucred)
+#define getpid()       curproc
 #define        gop_rdwr(rw,gp,base,len,offset,segflg,unit,cred,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(aresid), curproc)
 extern struct proc * afs_global_owner;
index 197822b..21a9967 100644 (file)
@@ -23,6 +23,12 @@ RCSID("$Header$");
 #include "afsincludes.h"       /* Afs-based standard headers */
 #include <sys/namei.h>
 
+#ifdef AFS_FBSD50_ENV
+/* serious cheating */
+#undef curproc
+#define curproc curthread
+#endif
+
 #ifndef AFS_FBSD50_ENV
 /*
  * afs_suser() returns true if the caller is superuser, false otherwise.
@@ -30,38 +36,69 @@ RCSID("$Header$");
  * Note that it must NOT set errno.
  */
 
-afs_suser() {
+afs_suser()
+{
     int error;
 
     if (suser(curproc) == 0) {
-       return(1);
+       return (1);
     }
-    return(0);
+    return (0);
 }
 #endif
 
-int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
-                          struct vnode **dirvpp, struct vnode **vpp)
+int
+osi_lookupname(char *aname, enum uio_seg seg, int followlink,
+              struct vnode **dirvpp, struct vnode **vpp)
 {
-   struct nameidata n;
-   int flags,error;
-   flags=0;
-   flags=LOCKLEAF;
-   if (followlink)
-     flags|=FOLLOW;
-   else 
-     flags|=NOFOLLOW;
-/*   if (dirvpp) flags|=WANTPARENT;*/ /* XXX LOCKPARENT? */
-   NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
-   if (error=namei(&n))
-      return error;
-   *vpp=n.ni_vp;
+    struct nameidata n;
+    int flags, error;
+    flags = 0;
+    flags = LOCKLEAF;
+    if (followlink)
+       flags |= FOLLOW;
+    else
+       flags |= NOFOLLOW;
+    /*   if (dirvpp) flags|=WANTPARENT;*//* XXX LOCKPARENT? */
+    NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
+    if (error = namei(&n))
+       return error;
+    *vpp = n.ni_vp;
 /*
    if (dirvpp)
       *dirvpp = n.ni_dvp;
 */
-   /* should we do this? */
-   VOP_UNLOCK(n.ni_vp, 0, curproc);
-   NDFREE(&n, NDF_ONLY_PNBUF);
-   return 0;
+    /* should we do this? */
+    VOP_UNLOCK(n.ni_vp, 0, curproc);
+    NDFREE(&n, NDF_ONLY_PNBUF);
+    return 0;
+}
+
+/*
+ * does not implement security features of kern_time.c:settime()
+ */
+void
+afs_osi_SetTime(osi_timeval_t * atv)
+{
+#ifdef AFS_FBSD50_ENV
+    printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
+#else
+    struct timespec ts;
+    struct timeval tv, delta;
+    int s;
+
+    AFS_GUNLOCK();
+    s = splclock();
+    microtime(&tv);
+    delta = *atv;
+    timevalsub(&delta, &tv);
+    ts.tv_sec = atv->tv_sec;
+    ts.tv_nsec = atv->tv_usec * 1000;
+    set_timecounter(&ts);
+    (void)splsoftclock();
+    lease_updatetime(delta.tv_sec);
+    splx(s);
+    resettodr();
+    AFS_GLOCK();
+#endif
 }
index f4aad3c..d2b3036 100644 (file)
@@ -9,7 +9,7 @@
 /*
  * osi_prototypes.h
  *
- * Exported macos support routines.
+ * Exported support routines.
  */
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
@@ -20,4 +20,8 @@ extern afs_rwlock_t afs_xosi;
 /* osi_misc.c */
 extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
                          struct vnode **dirvpp, struct vnode **vpp);
+
+/* osi_vfsops.c */
+extern int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p);
+
 #endif /* _OSI_PROTO_H_ */
index 25889f4..f4d8ba5 100644 (file)
@@ -15,7 +15,7 @@ RCSID("$Header$");
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afsincludes.h"       /* Afs-based standard headers */
-#include "afs/afs_stats.h"   /* afs statistics */
+#include "afs/afs_stats.h"     /* afs statistics */
 
 
 
@@ -24,21 +24,24 @@ static int osi_TimedSleep(char *event, afs_int32 ams, int aintok);
 static char waitV;
 
 
-void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
+void
+afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
 {
     AFS_STATCNT(osi_InitWaitHandle);
     achandle->proc = (caddr_t) 0;
 }
 
 /* cancel osi_Wait */
-void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
+void
+afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
 {
     caddr_t proc;
 
     AFS_STATCNT(osi_CancelWait);
     proc = achandle->proc;
-    if (proc == 0) return;
-    achandle->proc = (caddr_t) 0;   /* so dude can figure out he was signalled */
+    if (proc == 0)
+       return;
+    achandle->proc = (caddr_t) 0;      /* so dude can figure out he was signalled */
     afs_osi_Wakeup(&waitV);
 }
 
@@ -46,21 +49,23 @@ void afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
  * Waits for data on ahandle, or ams ms later.  ahandle may be null.
  * Returns 0 if timeout and EINTR if signalled.
  */
-int afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
+int
+afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
 {
     int code;
-    afs_int32 endTime, tid;
+    afs_int32 endTime;
 
     AFS_STATCNT(osi_Wait);
-    endTime = osi_Time() + (ams/1000);
+    endTime = osi_Time() + (ams / 1000);
     if (ahandle)
-      ahandle->proc = (caddr_t) curproc;
+       ahandle->proc = (caddr_t) curproc;
     do {
        AFS_ASSERT_GLOCK();
        code = 0;
        code = osi_TimedSleep(&waitV, ams, aintok);
 
-       if (code) break;        /* if something happened, quit now */
+       if (code)
+           break;              /* if something happened, quit now */
        /* if we we're cancelled, quit now */
        if (ahandle && (ahandle->proc == (caddr_t) 0)) {
            /* we've been signalled */
@@ -78,19 +83,20 @@ typedef struct afs_event {
     char *event;               /* lwp event: an address */
     int refcount;              /* Is it in use? */
     int seq;                   /* Sequence number: this is incremented
-                                  by wakeup calls; wait will not return until
-                                  it changes */
+                                * by wakeup calls; wait will not return until
+                                * it changes */
     int cond;
 } afs_event_t;
 
 #define HASHSIZE 128
-afs_event_t *afs_evhasht[HASHSIZE];/* Hash table for events */
+afs_event_t *afs_evhasht[HASHSIZE];    /* Hash table for events */
 #define afs_evhash(event)      (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1));
 int afs_evhashcnt = 0;
 
 /* Get and initialize event structure corresponding to lwp event (i.e. address)
  * */
-static afs_event_t *afs_getevent(char *event)
+static afs_event_t *
+afs_getevent(char *event)
 {
     afs_event_t *evp, *newp = 0;
     int hashcode;
@@ -108,7 +114,7 @@ static afs_event_t *afs_getevent(char *event)
        evp = evp->next;
     }
     if (!newp) {
-       newp = (afs_event_t *) osi_AllocSmallSpace(sizeof (afs_event_t));
+       newp = (afs_event_t *) osi_AllocSmallSpace(sizeof(afs_event_t));
        afs_evhashcnt++;
        newp->next = afs_evhasht[hashcode];
        afs_evhasht[hashcode] = newp;
@@ -123,7 +129,8 @@ static afs_event_t *afs_getevent(char *event)
 #define relevent(evp) ((evp)->refcount--)
 
 
-void afs_osi_Sleep(void *event)
+void
+afs_osi_Sleep(void *event)
 {
     struct afs_event *evp;
     int seq;
@@ -133,13 +140,14 @@ void afs_osi_Sleep(void *event)
     while (seq == evp->seq) {
        AFS_ASSERT_GLOCK();
        AFS_GUNLOCK();
-        tsleep(event, PVFS, "afs_osi_Sleep", 0);
+       tsleep(event, PVFS, "afs_osi_Sleep", 0);
        AFS_GLOCK();
     }
     relevent(evp);
 }
 
-int afs_osi_SleepSig(void *event)
+int
+afs_osi_SleepSig(void *event)
 {
     afs_osi_Sleep(event);
     return 0;
@@ -154,42 +162,44 @@ int afs_osi_SleepSig(void *event)
  *
  * Returns 0 if timeout and EINTR if signalled.
  */
-static int osi_TimedSleep(char *event, afs_int32 ams, int aintok)
+static int
+osi_TimedSleep(char *event, afs_int32 ams, int aintok)
 {
     int code = 0;
     struct afs_event *evp;
     int ticks;
-    int seq,prio;
-    ticks = ( ams * afs_hz )/1000;
+    int seq, prio;
+
+    ticks = (ams * afs_hz) / 1000;
 
 
     evp = afs_getevent(event);
-    seq=evp->seq;
+    seq = evp->seq;
     AFS_GUNLOCK();
     if (aintok)
-       prio=PCATCH|PPAUSE;
+       prio = PCATCH | PPAUSE;
     else
-       prio=PVFS;
-    code=tsleep(event, prio, "afs_osi_TimedSleep", ticks);
+       prio = PVFS;
+    code = tsleep(event, prio, "afs_osi_TimedSleep", ticks);
     AFS_GLOCK();
     if (seq == evp->seq)
-       code=EINTR;
+       code = EINTR;
     relevent(evp);
     return code;
 }
 
 
-int afs_osi_Wakeup(void *event)
+int
+afs_osi_Wakeup(void *event)
 {
-    int ret=1;
+    int ret = 1;
     struct afs_event *evp;
 
     evp = afs_getevent(event);
     if (evp->refcount > 1) {
-       evp->seq++;    
+       evp->seq++;
        wakeup(event);
-       ret=0;
+       ret = 0;
     }
     relevent(evp);
     return ret;
index 5820173..46ba345 100644 (file)
@@ -3,9 +3,9 @@
 
 RCSID("$Header$");
 
-#include <afs/sysincludes.h>            /* Standard vendor system headers */
-#include <afsincludes.h>            /* Afs-based standard headers */
-#include <afs/afs_stats.h>              /* statistics */
+#include <afs/sysincludes.h>   /* Standard vendor system headers */
+#include <afsincludes.h>       /* Afs-based standard headers */
+#include <afs/afs_stats.h>     /* statistics */
 #include <sys/malloc.h>
 #include <sys/namei.h>
 #include <sys/conf.h>
@@ -13,52 +13,53 @@ RCSID("$Header$");
 
 struct vcache *afs_globalVp = 0;
 struct mount *afs_globalVFS = 0;
-int afs_pbuf_freecnt=-1;
+int afs_pbuf_freecnt = -1;
+
 int
 afs_quotactl()
 {
-       return EOPNOTSUPP;
+    return EOPNOTSUPP;
 }
 
 int
 afs_fhtovp(mp, fhp, vpp)
-struct mount *mp;
-struct fid *fhp;
-struct vnode **vpp;
+     struct mount *mp;
+     struct fid *fhp;
+     struct vnode **vpp;
 {
 
-       return (EINVAL);
+    return (EINVAL);
 }
 
 int
 afs_vptofh(vp, fhp)
-struct vnode *vp;
-struct fid *fhp;
+     struct vnode *vp;
+     struct fid *fhp;
 {
 
-       return (EINVAL);
+    return (EINVAL);
 }
 
 int
 afs_start(mp, flags, p)
-struct mount *mp;
-int flags;
-struct proc *p;
+     struct mount *mp;
+     int flags;
+     struct proc *p;
 {
     afs_pbuf_freecnt = nswbuf / 2 + 1;
-    return (0);                         /* nothing to do. ? */
+    return (0);                        /* nothing to do. ? */
 }
 
 int
 afs_mount(mp, path, data, ndp, p)
-register struct mount *mp;
-char *path;
-caddr_t data;
-struct nameidata *ndp;
-struct proc *p;
+     register struct mount *mp;
+     char *path;
+     caddr_t data;
+     struct nameidata *ndp;
+     struct proc *p;
 {
     /* ndp contains the mounted-from device.  Just ignore it.
-       we also don't care about our proc struct. */
+     * we also don't care about our proc struct. */
     size_t size;
 
     if (mp->mnt_flag & MNT_UPDATE)
@@ -67,7 +68,7 @@ struct proc *p;
     AFS_GLOCK();
     AFS_STATCNT(afs_mount);
 
-    if (afs_globalVFS) { /* Don't allow remounts. */
+    if (afs_globalVFS) {       /* Don't allow remounts. */
        AFS_GUNLOCK();
        return (EBUSY);
     }
@@ -75,26 +76,26 @@ struct proc *p;
     afs_globalVFS = mp;
     mp->vfs_bsize = 8192;
     vfs_getnewfsid(mp);
-    mp->mnt_stat.f_iosize=8192;
-    
-    (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN-1, &size);
+    mp->mnt_stat.f_iosize = 8192;
+
+    (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
     memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
     memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
     strcpy(mp->mnt_stat.f_mntfromname, "AFS");
     /* null terminated string "AFS" will fit, just leave it be. */
     strcpy(mp->mnt_stat.f_fstypename, "afs");
     AFS_GUNLOCK();
-    (void) afs_statfs(mp, &mp->mnt_stat, p);
+    (void)afs_statfs(mp, &mp->mnt_stat, p);
     return 0;
 }
 
 int
 afs_unmount(mp, flags, p)
-struct mount *mp;
-int flags;
-struct proc *p;
+     struct mount *mp;
+     int flags;
+     struct proc *p;
 {
-    
+
     AFS_GLOCK();
     AFS_STATCNT(afs_unmount);
     afs_globalVFS = 0;
@@ -105,8 +106,7 @@ struct proc *p;
 }
 
 int
-afs_root(struct mount *mp,
-             struct vnode **vpp)
+afs_root(struct mount *mp, struct vnode **vpp)
 {
     int error;
     struct vrequest treq;
@@ -123,35 +123,34 @@ afs_root(struct mount *mp,
     AFS_STATCNT(afs_root);
     if (afs_globalVp && (afs_globalVp->states & CStatd)) {
        tvp = afs_globalVp;
-        error=0;
+       error = 0;
     } else {
        if (afs_globalVp) {
            afs_PutVCache(afs_globalVp);
            afs_globalVp = NULL;
        }
 
-       if (!(error = afs_InitReq(&treq, &cr)) &&
-           !(error = afs_CheckInit())) {
+       if (!(error = afs_InitReq(&treq, &cr)) && !(error = afs_CheckInit())) {
            tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
            /* we really want this to stay around */
-           if (tvp) {
-               afs_globalVp = tvp;
-           } else
-               error = ENOENT;
+           if (tvp)
+               afs_globalVp = tvp;
+           else
+               error = ENOENT;
        }
     }
     if (tvp) {
-        osi_vnhold(tvp,0);
-    AFS_GUNLOCK();
+       osi_vnhold(tvp, 0);
+       AFS_GUNLOCK();
 #ifdef AFS_FBSD50_ENV
-        vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, td);
+       vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, td);
 #else
-        vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
+       vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
 #endif
-    AFS_GLOCK();
+       AFS_GLOCK();
        afs_globalVFS = mp;
        *vpp = AFSTOV(tvp);
-        tvp->v.v_flag |= VROOT;
+       tvp->v.v_flag |= VROOT;
     }
 
     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
@@ -162,10 +161,13 @@ afs_root(struct mount *mp,
 
 int
 afs_vget(mp, lfl, vp)
-struct mount *mp;
-struct vnode *vp;
-int lfl;
+     struct mount *mp;
+     struct vnode *vp;
+     int lfl;
 {
+#ifdef AFS_FBSD50_ENV
+    return EOPNOTSUPP;
+#else
     int error;
 
     printf("vget called. help!\n");
@@ -173,17 +175,16 @@ int lfl;
        vprint("bad usecount", vp);
        panic("afs_vget");
     }
-#ifdef AFS_FBSD50_ENV
     error = vget(vp, lfl, curthread);
-#else
     error = vget(vp, lfl, curproc);
-#endif
     if (!error)
-       insmntque(vp, afs_globalVFS);   /* take off free list */
+       insmntque(vp, afs_globalVFS);   /* take off free list */
     return error;
+#endif
 }
 
-int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
+int
+afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
 {
     AFS_GLOCK();
     AFS_STATCNT(afs_statfs);
@@ -199,55 +200,62 @@ int afs_statfs(struct mount *mp, struct statfs *abp, struct proc *p)
      * storing something there.
      */
     abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
-       abp->f_ffree  = 2000000;
+       abp->f_ffree = 2000000;
 
     abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
     abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
     if (abp != &mp->mnt_stat) {
        abp->f_type = mp->mnt_vfc->vfc_typenum;
-       memcpy((caddr_t)&abp->f_mntonname[0], (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN);
-       memcpy((caddr_t)&abp->f_mntfromname[0], (caddr_t)mp->mnt_stat.f_mntfromname, MNAMELEN);
+       memcpy((caddr_t) & abp->f_mntonname[0],
+              (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
+       memcpy((caddr_t) & abp->f_mntfromname[0],
+              (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
     }
 
     AFS_GUNLOCK();
     return 0;
 }
 
-int afs_sync(mp, waitfor, cred, p) 
-struct mount *mp;
-int waitfor;
-struct ucred *cred;
-struct prioc *p;
+int
+afs_sync(mp, waitfor, cred, p)
+     struct mount *mp;
+     int waitfor;
+     struct ucred *cred;
+     struct prioc *p;
 {
-return 0;
+    return 0;
 }
 
-int afs_sysctl() {
-   return EOPNOTSUPP;
+int
+afs_sysctl()
+{
+    return EOPNOTSUPP;
 }
 
 
-int afs_init(struct vfsconf *vfc) {
-   return 0;
+int
+afs_init(struct vfsconf *vfc)
+{
+    return 0;
 }
 
 struct vfsops afs_vfsops = {
-  afs_mount,
-  afs_start,
-  afs_unmount,
-  afs_root,
-  afs_quotactl,
-  afs_statfs,
-  afs_sync,
-  afs_vget,
-  afs_fhtovp,
+    afs_mount,
+    afs_start,
+    afs_unmount,
+    afs_root,
+    afs_quotactl,
+    afs_statfs,
+    afs_sync,
+    afs_vget,
+    afs_fhtovp,
 #ifdef AFS_FBSD50_ENV
-  vfs_stdcheckexp,
+    vfs_stdcheckexp,
 #endif
-  afs_vptofh,
-  afs_init,
+    afs_vptofh,
+    afs_init,
 #ifdef AFS_FBSD50_ENV
-  vfs_stduninit,
+    vfs_stduninit,
 #endif
-  afs_sysctl
+    afs_sysctl
 };
index c782058..a2bbedd 100644 (file)
@@ -3,9 +3,9 @@
 
 RCSID("$Header$");
 
-#include <afs/sysincludes.h>            /* Standard vendor system headers */
-#include <afsincludes.h>            /* Afs-based standard headers */
-#include <afs/afs_stats.h>              /* statistics */
+#include <afs/sysincludes.h>           /* Standard vendor system headers */
+#include <afsincludes.h>               /* Afs-based standard headers */
+#include <afs/afs_stats.h>             /* statistics */
 #include <sys/malloc.h>
 #include <sys/namei.h>
 #ifndef AFS_FBSD50_ENV
@@ -125,12 +125,12 @@ struct vnodeopv_desc afs_vnodeop_opv_desc =
 
 int
 afs_vop_lookup(ap)
-struct vop_lookup_args /* {
-                         struct vnodeop_desc * a_desc;
-                         struct vnode *a_dvp;
-                         struct vnode **a_vpp;
-                         struct componentname *a_cnp;
-                         } */ *ap;
+       struct vop_lookup_args /* {
+               struct vnodeop_desc * a_desc;
+               struct vnode *a_dvp;
+               struct vnode **a_vpp;
+               struct componentname *a_cnp;
+       } */ *ap;
 {
     int error;
     struct vcache *vcp;
@@ -1122,6 +1122,7 @@ afs_vop_bmap(ap)
  
     return 0;
 }
+
 int
 afs_vop_strategy(ap)
        struct vop_strategy_args /* {
@@ -1134,6 +1135,7 @@ afs_vop_strategy(ap)
     AFS_GUNLOCK();
     return error;
 }
+
 int
 afs_vop_print(ap)
        struct vop_print_args /* {
@@ -1143,8 +1145,9 @@ afs_vop_print(ap)
     register struct vnode *vp = ap->a_vp;
     register struct vcache *vc = VTOAFS(ap->a_vp);
     int s = vc->states;
+
 #ifdef AFS_FBSD50_ENV
-    printf("tag %s, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
+    printf("tag %s, fid: %d.%x.%x.%x, opens %d, writers %d", vp->v_tag, (int) vc->fid.Cell,
           (u_int) vc->fid.Fid.Volume, (u_int) vc->fid.Fid.Vnode, (u_int) vc->fid.Fid.Unique,
           vc->opens, vc->execsOrWriters);
 #else
index b4c8458..51c39d6 100644 (file)
@@ -316,21 +316,19 @@ void afs_osi_Invisible(void)
 }
 
 
-#ifndef AFS_LINUX20_ENV /* Linux version in osi_misc.c */
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
 /* set the real time */
 void afs_osi_SetTime(osi_timeval_t *atv)
 {
-#ifdef AFS_AIX32_ENV
+#if defined(AFS_AIX32_ENV)
     struct timestruc_t t;
 
     t.tv_sec  = atv->tv_sec;
     t.tv_nsec = atv->tv_usec * 1000;
     ksettimer(&t);             /*  Was -> settimer(TIMEOFDAY, &t); */
-#else
-#ifdef AFS_SUN55_ENV
+#elif defined(AFS_SUN55_ENV)
     stime(atv->tv_sec);
-#else
-#ifdef AFS_SUN5_ENV
+#elif defined(AFS_SUN5_ENV)
     /*
      * To get more than second resolution we can use adjtime. The problem
      * is that the usecs from the server are wrong (by now) so it isn't
@@ -343,8 +341,7 @@ void afs_osi_SetTime(osi_timeval_t *atv)
     sta.time = atv->tv_sec;
 
     stime(&sta, NULL);
-#else
-#if defined(AFS_SGI_ENV)
+#elif defined(AFS_SGI_ENV)
     struct stimea {
        sysarg_t time;
     } sta;
@@ -353,27 +350,7 @@ void afs_osi_SetTime(osi_timeval_t *atv)
     sta.time = atv->tv_sec;
     stime(&sta);
     AFS_GLOCK();
-#else
-#if defined(AFS_FBSD_ENV)
-    /* does not impliment security features of kern_time.c:settime() */
-    struct timespec ts;
-    struct timeval tv,delta;
-    int s;
-    AFS_GUNLOCK();
-    s=splclock();
-    microtime(&tv);
-    delta=*atv;
-    timevalsub(&delta, &tv);
-    ts.tv_sec=atv->tv_sec;
-    ts.tv_nsec=atv->tv_usec * 1000;
-    set_timecounter(&ts);
-    (void) splsoftclock();
-    lease_updatetime(delta.tv_sec);
-    splx(s);
-    resettodr();
-    AFS_GLOCK();
-#else
-#if defined(AFS_DARWIN_ENV)
+#elif defined(AFS_DARWIN_ENV)
     AFS_GUNLOCK();
     setthetime(atv);
     AFS_GLOCK();
@@ -407,11 +384,6 @@ void afs_osi_SetTime(osi_timeval_t *atv)
     logtchg(atv->tv_sec);
 #endif
 #endif  /* AFS_DARWIN_ENV */
-#endif  /* AFS_FBSD_ENV */
-#endif /* AFS_SGI_ENV */
-#endif /* AFS_SUN55_ENV */
-#endif /* AFS_SUN5_ENV */
-#endif /* AFS_AIX32_ENV */
     AFS_STATCNT(osi_SetTime);
 }
 #endif /* AFS_LINUX20_ENV */
index 27a7953..7e21e9d 100644 (file)
@@ -771,8 +771,22 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp)
                    continue;   /* start over - may have raced. */
                }
             }
-#endif
-#if defined(AFS_FBSD_ENV)
+#elif defined(AFS_FBSD50_ENV)
+           if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
+               && (tvc->states & CUnlinkedDel) == 0) {
+               if (!(VOP_LOCK(&tvc->v, LK_EXCLUSIVE, curthread))) {
+                   if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
+                       && (tvc->states & CUnlinkedDel) == 0) {
+                       VREFCOUNT_DEC(tvc);
+                       AFS_GUNLOCK(); /* perhaps inline inactive for locking */
+                       VOP_INACTIVE(&tvc->v, curthread);
+                       AFS_GLOCK();
+                   } else {
+                       VOP_UNLOCK(&tvc->v, 0, curthread);
+                   }
+               }
+           }
+#elif defined(AFS_FBSD_ENV) && !defined(AFS_FBSD50_ENV)
            if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
                && (tvc->states & CUnlinkedDel) == 0) {
                if (!(VOP_LOCK(&tvc->v, LK_EXCLUSIVE, curproc))) {
@@ -787,8 +801,7 @@ struct vcache *afs_NewVCache(struct VenusFid *afid, struct server *serverp)
                    }
                }
            }
-#endif
-#if defined(AFS_LINUX22_ENV)
+#elif defined(AFS_LINUX22_ENV)
            if (tvc != afs_globalVp && VREFCOUNT(tvc) && tvc->opens == 0)
                afs_TryFlushDcacheChildren(tvc);
 #endif
index 87669d3..60afea7 100644 (file)
@@ -29,8 +29,13 @@ AFS_OS_NONFSOBJS = \
 
 # System specific build commands and flags
 KSRC = @BSD_KERNEL_PATH@
-KDEFS=-Wall -fformat-extensions -ansi -nostdinc -I/usr/include -D_KERNEL \
-       -DKLD_MODULE -elf -mpreferred-stack-boundary=2
+KDEFS=-Wall -ansi -nostdinc -I/usr/include -D_KERNEL -DKLD_MODULE \
+       -elf -mpreferred-stack-boundary=2 \
+<i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>
+       -fformat-extensions
+<all -i386_fbsd_42 -i386_fbsd_43 -i386_fbsd_44 -i386_fbsd_45 -i386_fbsd_46 -i386_fbsd_47>
+       -mno-align-long-strings -fformat-extensions -fno-common -ffreestanding
+<all>
 DBUG = -O2
 DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
 OPTF=${OPT}