Subject: Re: Odd LFS problems in syslog
To: Konrad Schroder <perseant@hhhh.org>
From: Sean Davis <dive@endersgame.net>
List: current-users
Date: 04/26/2002 09:23:13
Okay, I updated lfs_cleanerd, got rev 1.11 of print.c in it now. So far so
good - none of those messages in syslog yet. I'll let you know if anything
else weird happens.

One question re: the difference between 1.10 and 1.11: Is the main effect of
the change increased verbosity of syslogged stuff, or was the problem with
it not being able to allocate memory due to it using u_long instead of
u_int32_t?

-Sean

On Thu, Apr 25, 2002 at 09:49:57PM -0700, Konrad Schroder wrote:
> 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;
>          }
> 

-- 
/~\ The ASCII                         Sean Davis
\ / Ribbon Campaign                    aka dive
 X  Against HTML
/ \ Email!               http://eros.endersgame.net:8000/~dive