supergroup-cleanup-20070516

FIXES 60809

Problems fixed with this patch:
/1/ supergroup bug: when updating an entry in prdb, the logic in
pt_mywrite is supposed to unset flagged & found bitmap entries.
This failed on little-endian architecture machines.

/2/ warnings; a few fixes to eliminate some compiler noise.
This commit is contained in:
Marcus Watts 2007-05-16 20:54:42 +00:00 committed by Derrick Brashear
parent 62dc197541
commit d608809c24

View File

@ -113,71 +113,52 @@ pt_mywrite(struct ubik_dbase *tdb, afs_int32 fno, char *bp, afs_int32 pos, afs_i
c = ENTRYSIZE - o;
if (c > l)
c = l;
#define xPT(p,x) ((((struct prentry *)(p))->flags & htonl(PRTYPE)) == htonl(x))
#if DEBUG_SG_MAP
if (o)
fprintf(stderr, "Writing %d bytes of entry @ %#lx(+%d)\n", c,
p - o, o);
else if (c == ENTRYSIZE)
fprintf(stderr,
"Writing %d bytes of entry @ %#lx (%d<%s>,%d)\n", c,
p, ((struct prentry *)cp)->flags,
(((struct prentry *)cp)->flags & PRTYPE) ==
PRUSER ? "user" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRFREE ? "free" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRGRP ? "group" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRCONT ? "cont" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRCELL ? "cell" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRFOREIGN ? "foreign" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRINST ? "sub/super instance" : "?",
((struct prentry *)cp)->id);
"Writing %d bytes of entry @ %#lx (%d<%s>,%d)\n",
c, p, ntohl(((struct prentry *)cp)->flags),
xPT(cp,PRUSER) ? "user" : xPT(cp,PRFREE) ? "free" :
xPT(cp,PRGRP) ? "group" : xPT(cp,PRCONT) ? "cont" :
xPT(cp,PRCELL) ? "cell" : xPT(cp,PRFOREIGN) ? "foreign" :
xPT(cp,PRINST) ? "sub/super instance" : "?",
ntohl(((struct prentry *)cp)->id));
else if (c >= 8)
fprintf(stderr,
"Writing first %d bytes of entry @ %#lx (%d<%s>,%d)\n",
c, p, ((struct prentry *)cp)->flags,
(((struct prentry *)cp)->flags & PRTYPE) ==
PRUSER ? "user" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRFREE ? "free" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRGRP ? "group" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRCONT ? "cont" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRCELL ? "cell" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRFOREIGN ? "foreign" : (((struct prentry *)cp)->
flags & PRTYPE) ==
PRINST ? "sub/super instance" : "?",
((struct prentry *)cp)->id);
c, p, ntohl(((struct prentry *)cp)->flags),
xPT(cp,PRUSER) ? "user" : xPT(cp,PRFREE) ? "free" :
xPT(cp,PRGRP) ? "group" : xPT(cp,PRCONT) ? "cont" :
xPT(cp,PRCELL) ? "cell" : xPT(cp,PRFOREIGN) ? "foreign" :
xPT(cp,PRINST) ? "sub/super instance" : "?",
ntohl(((struct prentry *)cp)->id));
else
fprintf(stderr, "Writing %d bytes of entry @ %#lx\n", c, p);
#endif
if (!o && c >= 8
&& (((struct prentry *)cp)->flags & PRTYPE) == PRGRP) {
if (!o && c >= 8 && xPT(cp,PRGRP)) {
#if DEBUG_SG_MAP
if (in_map(sg_found, -((struct prentry *)cp)->id))
if (in_map(sg_found, -ntohl(((struct prentry *)cp)->id)))
fprintf(stderr, "Unfound: Removing group %d\n",
((struct prentry *)cp)->id);
if (in_map(sg_flagged, -((struct prentry *)cp)->id))
ntohl(((struct prentry *)cp)->id));
if (in_map(sg_flagged, -ntohl(((struct prentry *)cp)->id)))
fprintf(stderr, "Unflag: Removing group %d\n",
((struct prentry *)cp)->id);
ntohl(((struct prentry *)cp)->id));
#endif
sg_found =
bic_map(sg_found,
add_map(NIL_MAP, -((struct prentry *)cp)->id));
add_map(NIL_MAP, -ntohl(((struct prentry *)cp)->id)));
sg_flagged =
bic_map(sg_flagged,
add_map(NIL_MAP, -((struct prentry *)cp)->id));
add_map(NIL_MAP, -ntohl(((struct prentry *)cp)->id)));
}
cp += c;
p += c;
l -= c;
#undef xPT
}
}
return (*pt_save_dbase_write) (tdb, fno, bp, pos, count);
@ -744,7 +725,7 @@ ChangeIDEntry(register struct ubik_trans *at, register afs_int32 aid, afs_int32
}
nptr = tentry.next;
while (nptr != NULL) {
while (nptr) {
code = pr_ReadCoEntry(at, 0, nptr, &centry);
if (code != 0)
return code;
@ -803,7 +784,7 @@ RemoveFromSGEntry(register struct ubik_trans *at, register afs_int32 aid, regist
if (code != 0)
return code;
#ifdef PR_REMEMBER_TIMES
tentry.removeTime = time((afs_int32 *) 0);
tentry.removeTime = time(NULL);
#endif
tentryg = (struct prentryg *)&tentry;
for (i = 0; i < SGSIZE; i++) {
@ -821,7 +802,7 @@ RemoveFromSGEntry(register struct ubik_trans *at, register afs_int32 aid, regist
}
hloc = 0;
nptr = tentryg->nextsg;
while (nptr != NULL) {
while (nptr) {
code = pr_ReadCoEntry(at, 0, nptr, &centry);
if (code != 0)
return code;
@ -1158,7 +1139,7 @@ AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_in
if (entry->id == aid)
return PRINCONSISTENT;
#ifdef PR_REMEMBER_TIMES
entry->addTime = time((afs_int32 *) 0);
entry->addTime = time(NULL);
#endif
entryg = (struct prentryg *)entry;
for (i = 0; i < SGSIZE; i++) {
@ -1177,7 +1158,7 @@ AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_in
}
last = 0;
nptr = entryg->nextsg;
while (nptr != NULL) {
while (nptr) {
code = pr_ReadCoEntry(tt, 0, nptr, &nentry);
if (code != 0)
return code;
@ -1237,7 +1218,7 @@ AddToSGEntry(struct ubik_trans *tt, struct prentry *entry, afs_int32 loc, afs_in
memset(&aentry, 0, sizeof(aentry));
aentry.flags |= PRCONT;
aentry.id = entry->id;
aentry.next = NULL;
aentry.next = 0;
aentry.entries[0] = aid;
code = pr_WriteCoEntry(tt, 0, nptr, &aentry);
if (code != 0)
@ -1531,7 +1512,7 @@ GetListSG2(struct ubik_trans *at, afs_int32 gid, prlist *alist, afs_int32 *sizeP
}
nptr = tentryg->nextsg;
while (nptr != NULL) {
while (nptr) {
didsomething = 1;
/* look through cont entries */
code = pr_ReadCoEntry(at, 0, nptr, &centry);
@ -1599,7 +1580,7 @@ GetSGList(struct ubik_trans *at, struct prentry *tentry, prlist *alist)
}
nptr = tentryg->nextsg;
while (nptr != NULL) {
while (nptr) {
/* look through cont entries */
code = pr_ReadCoEntry(at, 0, nptr, &centry);
if (code != 0)
@ -1942,7 +1923,7 @@ ChangeEntry(struct ubik_trans *at, afs_int32 aid, afs_int32 cid, char *name, afs
break;
}
pos = tentry.next;
while (pos != NULL) {
while (pos) {
#define centry (*(struct contentry*)&tent)
code = pr_ReadCoEntry(at, 0, pos, &centry);
if ((centry.id != aid)