From 3ce7e41622175cf73ef129426880e77969efe7f3 Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Thu, 10 Oct 2002 23:45:14 +0000 Subject: [PATCH] openbsd-20021010 More OpenBSD merge. --- src/afs/afs_osi.c | 16 +++++++-- src/afs/afs_pioctl.c | 73 +++++++++++++++++++--------------------- src/afs/afs_prototypes.h | 12 ++++++- src/afs/sysincludes.h | 1 - 4 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 6f2d54fd8..f9d36a96e 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -441,13 +441,17 @@ void *afs_osi_Alloc(size_t x) return osi_linux_alloc(x, 1); #else size = x; +#ifdef AFS_OBSD_ENV + MALLOC(tm, struct osimem *, size, M_AFSGENERIC, M_WAITOK); +#else tm = (struct osimem *) AFS_KALLOC(size); +#endif #ifdef AFS_SUN_ENV if (!tm) osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out of memory!\n", size); #endif - return (char *) tm; + return (void *) tm; #endif } @@ -466,8 +470,12 @@ void *afs_osi_Alloc_NoSleep(size_t x) size = x; AFS_STATS(afs_stats_cmperf.OutStandingAllocs++); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x); +#ifdef AFS_OBSD_ENV + MALLOC(tm, struct osimem *, size, M_AFSGENERIC, 0); +#else tm = (struct osimem *) AFS_KALLOC_NOSLEEP(size); - return (char *) tm; +#endif + return (void *) tm; } #endif /* SUN || SGI */ @@ -479,8 +487,10 @@ void afs_osi_Free(void *x, size_t asize) AFS_STATS(afs_stats_cmperf.OutStandingAllocs--); AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize); -#ifdef AFS_LINUX20_ENV +#if defined(AFS_LINUX20_ENV) osi_linux_free(x); +#elif defined(AFS_OBSD_ENV) + FREE(x, M_AFSGENERIC); #else AFS_KFREE((struct osimem *)x, asize); #endif diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 3e0f23aae..2b105a25f 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -516,7 +516,7 @@ int afs_xioctl (void) #endif #else fd = getf(uap->fd); - if (!fd) return; + if (!fd) return(EBADF); #endif #endif #endif @@ -1126,14 +1126,12 @@ int afs_HandlePioctl(struct vcache *avc, afs_int32 acom, DECL_PIOCTL(PGetFID) { - register afs_int32 code; - AFS_STATCNT(PGetFID); if (!avc) return EINVAL; memcpy(aout, (char *)&avc->fid, sizeof(struct VenusFid)); *aoutSize = sizeof(struct VenusFid); return 0; - } +} DECL_PIOCTL(PSetAcl) { @@ -1401,12 +1399,12 @@ DECL_PIOCTL(PSetTokens) i = tcell->cellNum; afs_PutCell(tcell, READ_LOCK); if (set_parent_pag) { - int pag; -#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) + afs_int32 pag; +#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) #if defined(AFS_DARWIN_ENV) - struct proc *p=current_proc(); /* XXX */ + struct proc *p = current_proc(); /* XXX */ #else - struct proc *p=curproc; /* XXX */ + struct proc *p = curproc; /* XXX */ #endif uprintf("Process %d (%s) tried to change pags in PSetTokens\n", p->p_pid, p->p_comm); @@ -2077,7 +2075,7 @@ DECL_PIOCTL(PGetCacheSize) DECL_PIOCTL(PRemoveCallBack) { register struct conn *tc; - register afs_int32 code; + register afs_int32 code = 0; struct AFSCallBack CallBacks_Array[1]; struct AFSCBFids theFids; struct AFSCBs theCBs; @@ -2124,7 +2122,6 @@ DECL_PIOCTL(PNewCell) { /* create a new cell */ afs_int32 cellHosts[MAXCELLHOSTS], *lp, magic=0; - register struct cell *tcell; char *newcell=0, *linkedcell=0, *tp= ain; register afs_int32 code, linkedstate=0, ls; u_short fsport = 0, vlport = 0; @@ -2693,7 +2690,7 @@ DECL_PIOCTL(PSetSysName) * l - array of cell ids which have volumes that need to be sorted * vlonly - sort vl servers or file servers? */ -static void *ReSortCells_cb(struct cell *cell, void *arg) +static void ReSortCells_cb(struct cell *cell, void *arg) { afs_int32 *p = (afs_int32 *) arg; afs_int32 *l = p + 1; @@ -2710,33 +2707,33 @@ static void *ReSortCells_cb(struct cell *cell, void *arg) static void ReSortCells(int s, afs_int32 *l, int vlonly) { - int i; - struct volume *j; - register int k; - - if (vlonly) { - afs_int32 *p; - p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s+1)); - p[0] = s; - memcpy(p+1, l, s * sizeof(afs_int32)); - afs_TraverseCells(&ReSortCells_cb, p); - afs_osi_Free(p, sizeof(afs_int32) * (s+1)); - return; - } + int i; + struct volume *j; + register int k; - ObtainReadLock(&afs_xvolume); - for (i= 0; i< NVOLS; i++) { - for (j=afs_volumes[i];j;j=j->next) { - for (k=0;kcell == l[k]) { - ObtainWriteLock(&j->lock,233); - afs_SortServers(j->serverHost, MAXHOSTS); - ReleaseWriteLock(&j->lock); - break; - } - } - } - ReleaseReadLock(&afs_xvolume); + if (vlonly) { + afs_int32 *p; + p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s+1)); + p[0] = s; + memcpy(p+1, l, s * sizeof(afs_int32)); + afs_TraverseCells(&ReSortCells_cb, p); + afs_osi_Free(p, sizeof(afs_int32) * (s+1)); + return; + } + + ObtainReadLock(&afs_xvolume); + for (i= 0; i< NVOLS; i++) { + for (j=afs_volumes[i];j;j=j->next) { + for (k=0;kcell == l[k]) { + ObtainWriteLock(&j->lock,233); + afs_SortServers(j->serverHost, MAXHOSTS); + ReleaseWriteLock(&j->lock); + break; + } + } + } + ReleaseReadLock(&afs_xvolume); } @@ -2868,7 +2865,6 @@ DECL_PIOCTL(PGetSPrefs) int i,j; /* counters for hash table traversal */ struct server *srvr; /* one of CM's server structs */ struct srvAddr *sa; - afs_uint32 prevh; int vlonly; /* just return vlservers ? */ int isfs; @@ -3491,7 +3487,6 @@ DECL_PIOCTL(PPrefetchFromTape) struct VenusFid tfid; struct AFSFid *Fid; struct vcache *tvc; - XSTATS_DECLS; AFS_STATCNT(PSetAcl); if (!avc) diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 1b42071f9..567e6572f 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -173,6 +173,7 @@ extern int afs_CellOrAliasExists(char *aname); extern int afs_CellNumValid(afs_int32 cellnum); extern afs_int32 afs_NewCellAlias(char *alias, char *cell); extern struct cell_alias *afs_GetCellAlias(int index); +extern void afs_PutCellAlias(struct cell_alias *a); extern int afs_AFSDBHandler(char *acellName, int acellNameLen, afs_int32 *kernelMsg); extern void afs_LookupAFSDB(char *acellName); @@ -436,7 +437,8 @@ extern void osi_iput(struct inode *ip); extern void afs_osi_SetTime(osi_timeval_t *atv); /* LINUX/osi_misc.c */ -#if AFS_LINUX24_ENV +#ifdef AFS_LINUX_ENV +#ifdef AFS_LINUX24_ENV extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink, vnode_t **dirvpp, struct dentry **dpp); extern int osi_InitCacheInfo(char *aname); @@ -454,7 +456,15 @@ extern void check_bad_parent(struct dentry *dp); extern void osi_linux_mask(void); extern void osi_linux_unmask(void); extern void osi_linux_rxkreg(void); +extern int setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag, int change_parent); +#endif + +/* OBSD/osi_misc.c */ +#ifdef AFS_OBSD_ENV +extern int setpag(struct proc *proc, struct ucred **cred, afs_uint32 pagvalue, + afs_uint32 *newpag, int change_parent); +#endif /* ARCH/osi_sleep.c */ extern void afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle); diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h index 043c76d13..1806ad921 100644 --- a/src/afs/sysincludes.h +++ b/src/afs/sysincludes.h @@ -42,7 +42,6 @@ #include #include #include -#include #else /* AFS_OBSD_ENV */ #ifdef AFS_LINUX22_ENV #include -- 2.39.5