Subject: Re: Odd LFS problems in syslog
To: Sean Davis <dive-nb@endersgame.net>
From: Konrad Schroder <perseant@hhhh.org>
List: current-users
Date: 04/25/2002 21:49:57
On Thu, 25 Apr 2002, Sean Davis wrote:
> Apr 25 18:52:21 eros lfs_cleanerd[29507]: add_segment: lfs_segmapv failed
> for segment 98
> Apr 25 18:52:21 eros lfs_cleanerd[29507]: add_segment failed segment 98:
> Cannot allocate memory
Oops, yet another thing I missed when I brought in lfsv2. Please try the
attached patch to print.c (also rev 1.11) and see if that makes things any
better.
Konrad Schroder
perseant@hhhh.org
Index: print.c
===================================================================
RCS file: /cvsroot/basesrc/libexec/lfs_cleanerd/print.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- print.c 2001/07/13 20:30:22 1.10
+++ print.c 2002/04/26 04:34:41 1.11
@@ -71,18 +71,23 @@
{
int i, j, blk, numblocks, accino=0;
daddr_t *dp, ddp, *idp;
- u_long *datap;
+ u_int32_t *datap;
int size;
FINFO *fp;
- u_long ck;
+ u_int32_t ck;
blk=0;
- datap = (u_long *)malloc((lfsp->lfs_ssize*lfsp->lfs_frag) * sizeof(u_long));
- if(datap==NULL)
+ datap = (u_int32_t *)malloc((lfsp->lfs_ssize / lfsp->lfs_fsize) * sizeof(u_int32_t));
+ if(datap==NULL) {
+ syslog(LOG_WARNING, "cannot allocate %d in dump_summary",
+ (int)((lfsp->lfs_ssize / lfsp->lfs_fsize) * sizeof(u_int32_t)));
return(-1);
+ }
if (sp->ss_sumsum != (ck = cksum(&sp->ss_datasum,
lfsp->lfs_sumsize - sizeof(sp->ss_sumsum)))) {
+ syslog(LOG_WARNING, "sumsum checksum mismatch: should be %d, found %d\n",
+ (int) sp->ss_sumsum, (int) ck);
free(datap);
return(-1);
}
@@ -126,7 +131,7 @@
/* printf("finfo %d: ddp=%lx, *idp=%lx\n",i,ddp,*idp); */
while(ddp == *idp) {
/* printf(" [ino %lx]",ddp); */
- datap[blk++] = *(u_long*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
+ datap[blk++] = *(u_int32_t*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
--idp;
ddp += btofsb(lfsp, lfsp->lfs_ibsize);
accino++;
@@ -139,7 +144,7 @@
size = btofsb(lfsp, lfsp->lfs_bsize);
/* printf(" %lx/%d",ddp,size); */
}
- datap[blk++] = *(u_long*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
+ datap[blk++] = *(u_int32_t*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
ddp += size;
}
numblocks += fp->fi_nblocks;
@@ -161,7 +166,7 @@
while(*idp >= ddp && accino < howmany(sp->ss_ninos,INOPB(lfsp))) {
ddp = *idp;
/* printf(" [ino %lx]",ddp); */
- datap[blk++] = *(u_long*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
+ datap[blk++] = *(u_int32_t*)((caddr_t)sp + fsbtob(lfsp, ddp-addr));
--idp;
accino++;
}
@@ -174,9 +179,9 @@
syslog(LOG_DEBUG,"Oops, blk=%d numblocks=%d\n",blk,numblocks);
}
/* check data/inode block(s) checksum too */
- if ((ck=cksum ((void *)datap, numblocks * sizeof(u_long))) != sp->ss_datasum) {
+ if ((ck=cksum ((void *)datap, numblocks * sizeof(u_int32_t))) != sp->ss_datasum) {
syslog(LOG_DEBUG, "Bad data checksum: given %lu, got %lu",
- (unsigned long)sp->ss_datasum, ck);
+ (unsigned long)sp->ss_datasum, (unsigned long)ck);
free(datap);
return 0;
}