Subject: Re: df output with a really large filesystems
To: None <itojun@iijlab.net>
From: enami tsugutomo <enami@but-b.or.jp>
List: tech-userlevel
Date: 03/25/2004 21:53:47
> 	the issue was addressed fairly reently - what is the revisions you are
> 	using?

Actually, this issue is slightly different than the previous one.  If
we don't touch any kernel code, the following patch may help some
cases (but not all case. e.g., when # of reserved blocks + total
blocks doesn't fit in 32 bit value and disk is nearly full).

enami.

Index: df.c
===================================================================
RCS file: /cvsroot/src/bin/df/df.c,v
retrieving revision 1.56
diff -c -r1.56 df.c
*** df.c	7 Mar 2004 01:12:08 -0000	1.56
--- df.c	25 Mar 2004 11:11:19 -0000
***************
*** 305,313 ****
  void
  prthuman(struct statfs *sfsp, long used)
  {
!        prthumanval((int64_t)(sfsp->f_blocks) * (int64_t)(sfsp->f_bsize), "");
!        prthumanval((int64_t)(used) * (int64_t)(sfsp->f_bsize), "  ");
!        prthumanval((int64_t)(sfsp->f_bavail) * (int64_t)(sfsp->f_bsize), "   ");
  }
  
  
--- 305,318 ----
  void
  prthuman(struct statfs *sfsp, long used)
  {
! 
! 	prthumanval((int64_t)(u_long)sfsp->f_blocks * sfsp->f_bsize, "");
! 	prthumanval((int64_t)(u_long)used * sfsp->f_bsize, "  ");
! 	if (sfsp->f_blocks < 0 && sfsp->f_bavail < sfsp->f_blocks)
! 		prthumanval((int64_t)(u_long)sfsp->f_bavail * sfsp->f_bsize,
! 		    "   ");
! 	else
! 		prthumanval((int64_t)sfsp->f_bavail * sfsp->f_bsize, "   ");
  }
  
  
***************
*** 365,375 ****
  	availblks = sfsp->f_bavail + used;
  	if (hflag)
  		prthuman(sfsp, used);
! 	else
! 		(void)printf(" %*" PRId64 " %8" PRId64 " %9" PRId64, headerlen,
! 		    fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
! 		    fsbtoblk(used, sfsp->f_bsize, blocksize),
! 		    fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
  	(void)printf("%7s",
  	    availblks == 0 ? full : strpct((u_long)used, (u_long)availblks, 0));
  	if (iflag) {
--- 370,387 ----
  	availblks = sfsp->f_bavail + used;
  	if (hflag)
  		prthuman(sfsp, used);
! 	else {
! 		(void)printf(" %*" PRId64 " %8" PRId64, headerlen,
! 		    fsbtoblk((u_long)sfsp->f_blocks, sfsp->f_bsize, blocksize),
! 		    fsbtoblk((u_long)used, sfsp->f_bsize, blocksize));
! 		if (sfsp->f_blocks < 0 && sfsp->f_bavail < sfsp->f_blocks)
! 			(void)printf(" %9" PRId64,
! 			    fsbtoblk((u_long)sfsp->f_bavail,
! 			    sfsp->f_bsize, blocksize));
! 		else
! 			(void)printf(" %9" PRId64, fsbtoblk(sfsp->f_bavail,
! 			    sfsp->f_bsize, blocksize));
! 	}
  	(void)printf("%7s",
  	    availblks == 0 ? full : strpct((u_long)used, (u_long)availblks, 0));
  	if (iflag) {