/*
* 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 <assert.h>
#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
+#include <roken.h>
-#include <sys/types.h>
+#include <afs/opr.h>
#include <lock.h>
#include <ubik.h>
-#include <stdio.h>
-#ifdef AFS_NT40_ENV
-#include <winsock2.h>
-#else
-#include <netinet/in.h>
-#include <netdb.h>
-#endif
-#include <string.h>
+
#include "ptserver.h"
#include "pterror.h"
afs_int32 depth);
#endif
-afs_int32
+static afs_int32
IDHash(afs_int32 x)
{
/* returns hash bucket for x */
}
afs_int32
-NameHash(register unsigned char *aname)
+NameHash(char *aname)
{
/* returns hash bucket for aname */
- register unsigned int hash = 0;
- register int i;
+ unsigned int hash = 0;
+ size_t i;
/* stolen directly from the HashString function in the vol package */
for (i = strlen(aname), aname += i - 1; i--; aname--)
- hash = (hash * 31) + (*aname - 31);
+ hash = (hash * 31) + (*(unsigned char *)aname - 31);
return (hash % HASHSIZE);
}
afs_int32
-pr_Write(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, char *buff, afs_int32 len)
+pr_Write(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, void *buff, afs_int32 len)
{
/* package up seek and write into one procedure for ease of use */
afs_int32 code;
}
afs_int32
-pr_Read(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, char *buff, afs_int32 len)
+pr_Read(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, void *buff, afs_int32 len)
{
/* same thing for read */
afs_int32 code;
pr_WriteEntry(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, struct prentry *tentry)
{
afs_int32 code;
- register afs_int32 i;
+ afs_int32 i;
struct prentry nentry;
if (ntohl(1) != 1) { /* Need to swap bytes. */
nentry.sibling = htonl(tentry->sibling);
nentry.child = htonl(tentry->child);
strncpy(nentry.name, tentry->name, PR_MAXNAMELEN);
-#ifdef PR_REMEMBER_TIMES
nentry.createTime = htonl(tentry->createTime);
nentry.addTime = htonl(tentry->addTime);
nentry.removeTime = htonl(tentry->removeTime);
nentry.changeTime = htonl(tentry->changeTime);
-#endif
for (i = 0; i < PRSIZE; i++)
nentry.entries[i] = htonl(tentry->entries[i]);
tentry = &nentry;
pr_ReadEntry(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, struct prentry *tentry)
{
afs_int32 code;
- register afs_int32 i;
+ afs_int32 i;
struct prentry nentry;
code = ubik_Seek(tt, afd, pos);
if (code)
tentry->sibling = ntohl(nentry.sibling);
tentry->child = ntohl(nentry.child);
strncpy(tentry->name, nentry.name, PR_MAXNAMELEN);
-#ifdef PR_REMEMBER_TIMES
tentry->createTime = ntohl(nentry.createTime);
tentry->addTime = ntohl(nentry.addTime);
tentry->removeTime = ntohl(nentry.removeTime);
tentry->changeTime = ntohl(nentry.changeTime);
-#endif
for (i = 0; i < PRSIZE; i++)
tentry->entries[i] = ntohl(nentry.entries[i]);
return (code);
pr_WriteCoEntry(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, struct contentry *tentry)
{
afs_int32 code;
- register afs_int32 i;
+ afs_int32 i;
struct contentry nentry;
if (ntohl(1) != 1) { /* No need to swap */
pr_ReadCoEntry(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos, struct contentry *tentry)
{
afs_int32 code;
- register afs_int32 i;
+ afs_int32 i;
struct contentry nentry;
code = ubik_Seek(tt, afd, pos);
if (code)
* new entry */
afs_int32
-AllocBlock(register struct ubik_trans *at)
+AllocBlock(struct ubik_trans *at)
{
- register afs_int32 code;
+ afs_int32 code;
afs_int32 temp;
struct prentry tentry;
}
afs_int32
-FreeBlock(register struct ubik_trans *at, afs_int32 pos)
+FreeBlock(struct ubik_trans *at, afs_int32 pos)
{
/* add a block of storage to the free list */
- register afs_int32 code;
+ afs_int32 code;
struct prentry tentry;
memset(&tentry, 0, sizeof(tentry));
}
afs_int32
-FindByID(register struct ubik_trans *at, afs_int32 aid)
+FindByID(struct ubik_trans *at, afs_int32 aid)
{
/* returns address of entry if found, 0 otherwise */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
struct prentry tentry;
afs_int32 entry;
return 0;
if (aid == tentry.id)
return entry;
- assert(entry != tentry.nextID);
+ opr_Assert(entry != tentry.nextID);
entry = tentry.nextID;
while (entry != 0) {
memset(&tentry, 0, sizeof(tentry));
return 0;
if (aid == tentry.id)
return entry;
- assert(entry != tentry.nextID);
+ opr_Assert(entry != tentry.nextID);
entry = tentry.nextID;
}
return 0;
}
afs_int32
-FindByName(register struct ubik_trans *at, char aname[PR_MAXNAMELEN], struct prentry *tentryp)
+FindByName(struct ubik_trans *at, char aname[PR_MAXNAMELEN], struct prentry *tentryp)
{
/* ditto */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
afs_int32 entry;
return 0;
if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0)
return entry;
- assert(entry != tentryp->nextName);
+ opr_Assert(entry != tentryp->nextName);
entry = tentryp->nextName;
while (entry != 0) {
memset(tentryp, 0, sizeof(struct prentry));
return 0;
if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0)
return entry;
- assert(entry != tentryp->nextName);
+ opr_Assert(entry != tentryp->nextName);
entry = tentryp->nextName;
}
return 0;
}
afs_int32
-AllocID(register struct ubik_trans *at, afs_int32 flag, afs_int32 *aid)
+AllocID(struct ubik_trans *at, afs_int32 flag, afs_int32 *aid)
{
/* allocs an id from the proper area of address space, based on flag */
- register afs_int32 code = 1;
- register afs_int32 i = 0;
- register maxcount = 50; /* to prevent infinite loops */
+ afs_int32 code = 1;
+ afs_int32 i = 0;
+ int maxcount = 50; /* to prevent infinite loops */
if (flag & PRGRP) {
*aid = ntohl(cheader.maxGroup);
- while (code && i < maxcount) {
+ /* Check for PRBADID to avoid wrap-around. */
+ while (code && i < maxcount && *aid != PRBADID) {
--(*aid);
code = FindByID(at, *aid);
i++;
return PRSUCCESS;
} else {
*aid = ntohl(cheader.maxID);
- while (code && i < maxcount) {
+ while (code && i < maxcount && *aid != 0x7fffffff) {
++(*aid);
code = FindByID(at, *aid);
i++;
}
}
-afs_int32
-IDToName(register struct ubik_trans *at, afs_int32 aid, char aname[PR_MAXNAMELEN])
-{
- afs_int32 temp;
- struct prentry tentry;
- register afs_int32 code;
-
- temp = FindByID(at, aid);
- if (temp == 0)
- return PRNOENT;
- code = pr_Read(at, 0, temp, (char *)&tentry, sizeof(tentry));
- if (code)
- return code;
- strncpy(aname, tentry.name, PR_MAXNAMELEN);
- return PRSUCCESS;
-}
-
-afs_int32
-NameToID(register struct ubik_trans *at, char aname[PR_MAXNAMELEN], afs_int32 *aid)
-{
- afs_int32 temp;
- struct prentry tentry;
-
- temp = FindByName(at, aname, &tentry);
- if (!temp)
- return PRNOENT;
- *aid = tentry.id;
- return PRSUCCESS;
-}
-
int
-IDCmp(afs_int32 *a, afs_int32 *b)
+IDCmp(const void *a, const void *b)
{
/* used to sort CPS's so that comparison with acl's is easier */
- if (*a > *b) {
+ if (*(afs_int32 *)a > *(afs_int32 *)b) {
return 1;
- } else if (*a == *b) {
+ } else if (*(afs_int32 *)a == *(afs_int32 *)b) {
return 0;
} else /* (*a < *b) */ {
return -1;
RemoveFromIDHash(struct ubik_trans *tt, afs_int32 aid, afs_int32 *loc) /* ??? in case ID hashed twice ??? */
{
/* remove entry designated by aid from id hash table */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 current, trail, i;
struct prentry tentry;
struct prentry bentry;
if (code)
return PRDBFAIL;
while (aid != tentry.id) {
- assert(trail != current);
+ opr_Assert(trail != current);
trail = current;
current = tentry.nextID;
if (current == 0)
return PRDBFAIL;
bentry.nextID = tentry.nextID;
code = pr_WriteEntry(tt, 0, trail, &bentry);
+ if (code)
+ return PRDBFAIL;
}
*loc = current;
return PRSUCCESS;
AddToIDHash(struct ubik_trans *tt, afs_int32 aid, afs_int32 loc)
{
/* add entry at loc designated by aid to id hash table */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
struct prentry tentry;
RemoveFromNameHash(struct ubik_trans *tt, char *aname, afs_int32 *loc)
{
/* remove from name hash */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 current, trail, i;
struct prentry tentry;
struct prentry bentry;
if (code)
return PRDBFAIL;
while (strcmp(aname, tentry.name)) {
- assert(trail != current);
+ opr_Assert(trail != current);
trail = current;
current = tentry.nextName;
if (current == 0)
return PRDBFAIL;
bentry.nextName = tentry.nextName;
code = pr_WriteEntry(tt, 0, trail, &bentry);
+ if (code)
+ return PRDBFAIL;
}
*loc = current;
return PRSUCCESS;
AddToNameHash(struct ubik_trans *tt, char *aname, afs_int32 loc)
{
/* add to name hash */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
struct prentry tentry;
AddToOwnerChain(struct ubik_trans *at, afs_int32 gid, afs_int32 oid)
{
/* add entry designated by gid to owner chain of entry designated by oid */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 loc;
struct prentry tentry;
struct prentry gentry;
afs_int32
RemoveFromOwnerChain(struct ubik_trans *at, afs_int32 gid, afs_int32 oid)
{
- register afs_int32 code;
+ afs_int32 code;
afs_int32 nptr;
struct prentry thisEntry;
struct prentry thatEntry;
afs_int32
AddToOrphan(struct ubik_trans *at, afs_int32 gid)
{
- register afs_int32 code;
+ afs_int32 code;
afs_int32 loc;
struct prentry tentry;
RemoveFromOrphan(struct ubik_trans *at, afs_int32 gid)
{
/* remove gid from the orphan list */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 loc;
afs_int32 nptr;
struct prentry tentry;
IsOwnerOf(struct ubik_trans *at, afs_int32 aid, afs_int32 gid)
{
/* returns 1 if aid is the owner of gid, 0 otherwise */
- register afs_int32 code;
+ afs_int32 code;
struct prentry tentry;
afs_int32 loc;
OwnerOf(struct ubik_trans *at, afs_int32 gid)
{
/* returns the owner of gid */
- register afs_int32 code;
+ afs_int32 code;
afs_int32 loc;
struct prentry tentry;
#if !defined(SUPERGROUPS)
struct prentry tentry;
struct contentry centry;
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
afs_int32 loc;
#endif
#if defined(SUPERGROUPS)
afs_int32
-IsAMemberOfSG(struct ubik_trans *at, afs_int32 aid, afs_int32 gid, afs_int32 depth)
+IsAMemberOfSG(struct ubik_trans *at, afs_int32 aid, afs_int32 gid, afs_int32 depth)
{
/* returns true if aid is a member of gid */
struct prentry tentry;
struct contentry centry;
- register afs_int32 code;
+ afs_int32 code;
afs_int32 i;
afs_int32 loc;