]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-obsd-44-20090327
authorMatt Benjamin <matt@linuxbox.com>
Fri, 27 Mar 2009 15:55:43 +0000 (15:55 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 27 Mar 2009 15:55:43 +0000 (15:55 +0000)
LICENSE IPL10
FIXES 124541

update openbsd support

src/afs/OBSD/osi_groups.c
src/afs/OBSD/osi_machdep.h
src/afs/OBSD/osi_misc.c
src/afs/OBSD/osi_vnodeops.c
src/afs/afs_osi.c
src/config/afs_sysnames.h
src/rx/rx_kcommon.c
src/rx/xdr.h
src/rx/xdr_arrayn.c

index 96335118c914f516eb8e9fff2605750b858a214a..5ccbf779fe9fd7555297a8cb975ceab2c7d64215 100644 (file)
@@ -47,10 +47,12 @@ Afs_xsetgroups(p, args, retval)
     struct vrequest treq;
 
     AFS_STATCNT(afs_xsetgroups);
-    AFS_GLOCKP(p);
+    AFS_GLOCK();
+
+    p = osi_curproc();
 
     code = afs_InitReq(&treq, p->p_rcred);
-    AFS_GUNLOCKP(p);
+    AFS_GUNLOCK();
     if (code)
        return code;
 
@@ -61,10 +63,10 @@ Afs_xsetgroups(p, args, retval)
      */
     if (PagInCred(p->p_rcred) == NOPAG) {
        if (((treq.uid >> 24) & 0xff) == 'A') {
-           AFS_GLOCKP(p);
+           AFS_GLOCK();
            /* we've already done a setpag, so now we redo it */
            AddPag(p, treq.uid, &p->p_rcred);
-           AFS_GUNLOCKP(p);
+           AFS_GUNLOCK();
        }
     }
     return code;
index 576facfed2c03363640e5656b3ebc15902358b6c..f50241f5158beef72351ab8375cf31b32f5b4727 100644 (file)
 #define AFS_UIOUSER    UIO_USERSPACE
 
 /* malloc */
-#define AFS_KALLOC(s)  afs_nbsd_Alloc(s)
-#define AFS_KFREE(p, s)        afs_nbsd_Free((p), (s))
+extern void *osi_obsd_Alloc(size_t asize, int cansleep);
+extern void osi_obsd_Free(void *p, size_t asize);
+
+#ifdef afs_osi_Alloc_NoSleep
+#undef afs_osi_Alloc_NoSleep
+#define afs_osi_Alloc_NoSleep(asize) osi_obsd_Alloc((asize), 0)
+#endif
+
+#ifdef AFS_KALLOC
+#undef AFS_KALLOC
+#define AFS_KALLOC(s) osi_obsd_Alloc((s), 1 /* cansleep */)
+#endif
+
+#ifdef AFS_KFREE
+#undef AFS_KFREE
+#define AFS_KFREE(p, s) (osi_obsd_Free((p), (s)))
+#endif
+
+#ifdef AFS_OBSD42_ENV
+/* removed, live with it */
+#define BSD_KMALLOC(p, ptype, msize, mtype, mflags)     \
+  (p) = malloc((msize), (mtype), (mflags))
+
+#define BSD_KFREE(p, mflags) \
+  free((p), (mflags))
+#else
+#define BSD_KMALLOC MALLOC
+#define BSD_KFREE KFREE
+#endif /* AFS_OBSD42_ENV */
 
 /* proc, cred */
 #define        AFS_PROC        struct proc
@@ -92,11 +119,11 @@ extern time_t osi_Time();
 /* This is not always in scope yet */
 struct vcache;
 
-extern int afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg,
+extern int afs_obsd_lookupname(char *fnamep, enum uio_seg segflg,
                               int followlink, struct vnode **compvpp);
-extern void afs_nbsd_getnewvnode(struct vcache *tvc);
-extern void *afs_nbsd_Alloc(size_t asize);
-extern void afs_nbsd_Free(void *p, size_t asize);
+extern void afs_obsd_getnewvnode(struct vcache *tvc);
+extern void *afs_obsd_Alloc(size_t asize);
+extern void afs_obsd_Free(void *p, size_t asize);
 extern int afs_vget();
 
 #undef gop_lookupname
@@ -111,6 +138,49 @@ extern int afs_vget();
 
 #ifdef KERNEL
 
+#ifdef AFS_OBSD44_ENV
+/* Revert to classical, BSD locks */
+
+extern struct lock afs_global_lock;
+extern struct proc *afs_global_owner;
+
+#ifdef AFS_GLOBAL_SUNLOCK
+
+#if defined(LOCKDEBUG)
+
+#define AFS_GLOCK() \
+  do { \
+  _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
+  } while(0);
+#define AFS_GUNLOCK() \
+  do { \
+  _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
+  } while(0);
+
+#else
+
+#define AFS_GLOCK() \
+  do { \
+  lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
+  } while(0);
+#define AFS_GUNLOCK() \
+  do { \
+  lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
+  } while(0);
+#endif /* LOCKDEBUG */
+#define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
+#else
+extern struct lock afs_global_lock;
+#define AFS_GLOCKP(p)
+#define AFS_GUNLOCKP(p)
+#define AFS_ASSERT_GLOCK()
+#define ISAFS_GLOCK() 1
+#endif
+
+#else
+/* I don't see doing locks this way for older kernels, either,
+ * but, smart folks wrote this
+ */
 #define AFS_GLOCK() AFS_GLOCKP(curproc)
 #define AFS_GUNLOCK() AFS_GUNLOCKP(curproc)
 #ifdef AFS_GLOBAL_SUNLOCK
@@ -139,6 +209,8 @@ extern struct lock afs_global_lock;
 #define ISAFS_GLOCK() 1
 #endif
 
+#endif /* AFS_OBSD44_ENV */
+
 #undef SPLVAR
 #define SPLVAR int splvar
 #undef NETPRI
index 8bbcf559eedd3a4d8bc67412334458242579f260..4449ca4ff35b01e88f42a77a59d4bed7da6bfe04 100644 (file)
@@ -51,6 +51,8 @@ RCSID
 
 #include "afs/sysincludes.h"   /* Standard vendor system headers */
 #include "afs/afsincludes.h"   /* Afs-based standard headers */
+#include <sys/types.h>
+#include <sys/malloc.h>
 
 /*
  * afs_suser() returns true if the caller is superuser, false otherwise.
@@ -74,20 +76,94 @@ afs_osi_suser(void *credp)
 #endif
 }
 
+/*
+ * reworked for netbsd and openbsd at 4.0/4.4
+ */
+
+#if defined(AFS_OBSD42_ENV)
+/* ripped out MALLOC/FREE */
+
 void *
-afs_nbsd_Alloc(size_t asize)
+osi_obsd_Alloc(size_t asize, int cansleep)
 {
-    void *p;
+  void *p;
+  int glocked;
+
+  if (cansleep) {
+    glocked = ISAFS_GLOCK();
+    if (glocked)
+      AFS_GUNLOCK();
+    p = malloc(asize, M_AFSGENERIC, M_WAITOK);
+    if (glocked)
+      AFS_GLOCK();
+  } else {
+    p = malloc(asize, M_AFSGENERIC, M_NOWAIT);
+  }
+
+  return (p);
+}
 
+void
+osi_obsd_Free(void *p, size_t asize)
+{
+  free(p, M_AFSGENERIC);
+}
+
+#else
+void *
+osi_obsd_Alloc(size_t asize, int cansleep)
+{
+  void *p;
+  int glocked;
+
+  if (cansleep) {
+    glocked = ISAFS_GLOCK();
+    if (glocked)
+      AFS_GUNLOCK();
     MALLOC(p, void *, asize, M_AFSGENERIC, M_WAITOK);
-    return p;
+    if (glocked)
+      AFS_GLOCK();
+  } else {
+    MALLOC(p, void *, asize, M_AFSGENERIC, M_NOWAIT);
+  }
+
+  return (p);
 }
 
 void
-afs_nbsd_Free(void *p, size_t asize)
+osi_obsd_Free(void *p, size_t asize)
 {
-    FREE(p, M_AFSGENERIC);
+  FREE(p, M_AFSGENERIC);
 }
+#endif
+
+#if 0 /* XXX */
+/* I speculate this usage may be more correct than definitions
+ * in afs_osi_alloc.c, which I discarded successfully for FreeBSD 7+,
+ * and am trying to discard for NetBSD 4.x, but until tested, I'm
+ * not rocking the boat.  Matt.
+ */
+   
+void
+osi_FreeLargeSpace(void *p)
+{
+  osi_obsd_Free(p, 0);
+}
+
+void
+osi_FreeSmallSpace(void *p)
+{
+  osi_obsd_Free(p, 0);
+}
+
+void *
+osi_AllocLargeSpace(size_t size)
+{
+  AFS_ASSERT_GLOCK();
+  AFS_STATCNT(osi_AllocLargeSpace);
+  return (osi_obsd_Alloc(size, 1));
+}
+#endif
 
 int
 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
index 92279d281580792116a5f6c60a1c30c9f3375c75..e01b1bfe0a952f021e050379ed523d25df8fbae5 100644 (file)
@@ -160,7 +160,11 @@ int afs_nbsd_advlock(void *);
 /* Global vfs data structures for AFS. */
 int (**afs_vnodeop_p) __P((void *));
 struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
+#ifdef AFS_OBSD44_ENV /* feel free to zero in on this */
+  {&vop_default_desc, eopnotsupp},
+#else
     {&vop_default_desc, vn_default_error},
+#endif
     {&vop_lookup_desc, afs_nbsd_lookup},       /* lookup */
     {&vop_create_desc, afs_nbsd_create},       /* create */
     {&vop_mknod_desc, afs_nbsd_mknod},         /* mknod */
@@ -207,11 +211,11 @@ struct vnodeopv_desc afs_vnodeop_opv_desc =
 #define GETNAME()      \
     struct componentname *cnp = ap->a_cnp; \
     char *name; \
-    MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
+    BSD_KMALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
     bcopy(cnp->cn_nameptr, name, cnp->cn_namelen); \
     name[cnp->cn_namelen] = '\0'
 
-#define DROPNAME() FREE(name, M_TEMP)
+#define DROPNAME() BSD_KFREE(name, M_TEMP)
 
 #ifdef AFS_OBSD36_ENV
 #define DROPCNP(cnp) pool_put(&namei_pool, (cnp)->cn_pnbuf)
@@ -687,10 +691,10 @@ afs_nbsd_rename(void *v)
     if ((code = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc)))
        goto abortit;
 
-    MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
+    BSD_KMALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
     bcopy(fcnp->cn_nameptr, fname, fcnp->cn_namelen);
     fname[fcnp->cn_namelen] = '\0';
-    MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
+    BSD_KMALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
     bcopy(tcnp->cn_nameptr, tname, tcnp->cn_namelen);
     tname[tcnp->cn_namelen] = '\0';
 
@@ -702,8 +706,8 @@ afs_nbsd_rename(void *v)
     AFS_GUNLOCK();
 
     VOP_UNLOCK(fvp, 0, curproc);
-    FREE(fname, M_TEMP);
-    FREE(tname, M_TEMP);
+    BSD_KFREE(fname, M_TEMP);
+    BSD_KFREE(tname, M_TEMP);
     if (code)
        goto abortit;           /* XXX */
     if (tdvp == tvp)
index cc5990f6b29f720b4edde4be3e4da1849a4ae001..1986c6d40959bf1bbaf381b02dd1f418725aae23 100644 (file)
@@ -435,6 +435,8 @@ afs_osi_Alloc(size_t x)
     return osi_linux_alloc(x, 1);
 #elif defined(AFS_FBSD_ENV)
     return osi_fbsd_alloc(x, 1);
+#elif defined(AFS_OBSD_ENV)
+    return osi_obsd_Alloc(x, 1);
 #else
     size = x;
     tm = (struct osimem *)AFS_KALLOC(size);
index 77f16d924c0fe3cbc71b3557f85c4042a39c254e..09961fd84361ae07747ec9505f0a3a80f702a0c5 100644 (file)
 #define SYS_NAME_ID_i386_obsd39                2608
 #define SYS_NAME_ID_i386_obsd40         2609
 #define SYS_NAME_ID_i386_obsd41         2610
+#define SYS_NAME_ID_i386_obsd42         2611
+#define SYS_NAME_ID_i386_obsd43         2612
+#define SYS_NAME_ID_i386_obsd44         2613
 
 #define SYS_NAME_ID_amd64_linux2        2700
 #define SYS_NAME_ID_amd64_linux22       2701
index 7fa0e630bb14843f0287705196e63e4c1e775fd8..2382467d8c049fb6b26bb79f99d9f02e02219433 100644 (file)
@@ -996,10 +996,12 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
     }
     nam->m_len = sizeof(myaddr);
     memcpy(mtod(nam, caddr_t), &myaddr, sizeof(myaddr));
-#ifdef AFS_SGI65_ENV
+#if defined(AFS_SGI65_ENV)
     BHV_PDATA(&bhv) = (void *)newSocket;
     code = sobind(&bhv, nam);
     m_freem(nam);
+#elif defined(AFS_OBSD44_ENV)
+    code = sobind(newSocket, nam, osi_curproc());
 #else
     code = sobind(newSocket, nam);
 #endif
index d28a17ef71c9cde698e2aa228030d0ca2d527a13..8de3ffd14b772bcd94f09485d4c18894aa75b002 100644 (file)
 #define        osi_free                afs_osi_Free
 
 /* keep here for now, 64 bit issues */
+#ifndef AFS_OBSD44_ENV
 extern void *afs_osi_Alloc(size_t x);
 #ifndef afs_osi_Alloc_NoSleep
 extern void *afs_osi_Alloc_NoSleep(size_t x);
 #endif
 extern void afs_osi_Free(void *x, size_t asize);
+#endif
 
 #endif
 #ifndef major                  /* ouch! */
index 1b9e06ee212f3a4b9d051e8cfe330e674ffa89fd..ea7da048c031e379c033b521eac1c3bc96e67b36 100644 (file)
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
+
 #include <afsconfig.h>
 #include <afs/param.h>
 
 RCSID
     ("$Header$");
 
+#if defined(AFS_OBSD44_ENV) && defined(KERNEL) && !defined(UKERNEL)
+/* XXX osi_alloc, please find and fix */
+#include "osi_machdep.h"
+#endif
+
 #if !defined(NeXT)
 
 /*
@@ -44,6 +50,7 @@ RCSID
  */
 
 #if defined(KERNEL) && !defined(UKERNEL)
+
 #include <sys/param.h>
 #ifdef AFS_LINUX20_ENV
 #include "h/string.h"