From 5de282f23da3bf379edbf238f017a8d0682cc278 Mon Sep 17 00:00:00 2001 From: grog Date: Fri, 16 Nov 2012 03:33:34 +0000 Subject: Update man pages and clarify a number of options. Rework block count calculations to work correctly with small "block" sizes. MFC after: 14 days --- bin/df/df.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'bin/df/df.c') diff --git a/bin/df/df.c b/bin/df/df.c index 851c758..3058da0 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -393,16 +393,11 @@ prthumanvalinode(int64_t bytes) /* * Convert statfs returned file system size into BLOCKSIZE units. - * Attempts to avoid overflow for large file systems. */ static intmax_t fsbtoblk(int64_t num, uint64_t fsbs, u_long bs) { - - if (fsbs != 0 && fsbs < bs) - return (num / (intmax_t)(bs / fsbs)); - else - return (num * (intmax_t)(fsbs / bs)); + return (num * (intmax_t) fsbs / bs); } /* @@ -453,6 +448,12 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp) } (void)printf(" Mounted on\n"); } + /* Check for 0 block size. Can this happen? */ + if (sfsp->f_bsize == 0) { + warnx ("File system %s does not have a block size, assuming 512.", + sfsp->f_mntonname); + sfsp->f_bsize = 512; + } (void)printf("%-*s", mwp->mntfrom, sfsp->f_mntfromname); if (Tflag) (void)printf(" %-*s", mwp->fstype, sfsp->f_fstypename); -- cgit v1.1