Subject: bin/2893: Prettier df listings with long nfs mounts.
To: None <gnats-bugs@gnats.netbsd.org>
From: Anders Magnusson <ragge@my40.sm.luth.se>
List: netbsd-bugs
Date: 10/26/1996 13:19:13
>Number: 2893
>Category: bin
>Synopsis: Prettier df listings with long nfs mounts.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Oct 26 04:35:00 1996
>Last-Modified:
>Originator: Anders Magnusson
>Organization:
>Release: Any version...
>Environment:
System: NetBSD my40 1.2A NetBSD 1.2A (MY40) #8: Sun Oct 13 20:19:17 CEST 1996 ragge@my40:/usr/src/sys/arch/sparc/compile/MY40 sparc
>Description:
When mounting nfs filesystems, the long pathnames causes df listings
to look real ugly and are difficult to read. Example:
my40:/usr/src/bin/df >df
Filesystem 512-blocks Used Avail Capacity Mounted on
/dev/sd0a 56542 27424 23462 54% /
/dev/sd0d 56542 12 50874 0% /tmp
/dev/sd0e 56542 2408 48478 5% /var
/dev/sd0g 835166 598568 194838 75% /usr
my28:/e/local 1168204 904378 147006 86% /usr/local
my28:/var/spool/mail 576030 209786 308642 40% /var/spool/mail
my3:/SunOS4/usr/local 3846624 2405638 1056326 69% /emul/sunos/usr/local
my3:/SunOS4/usr/local 3846624 2405638 1056326 69% /tomat
basil.cdt:/usr/local 3936132 3387828 154704 96% /emul/svr4/usr/local
my21:/export/u20 1763038 1271548 315188 80% /amd/my21/export/u20
ftp.luth.se:/pub/FreeBSD/distfiles 1635228 1252988 382240 77% /mnt
This looks nicer if the lines splits when long mounts (as SunOS):
my40:/usr/src/bin/df >./df
Filesystem 512-blocks Used Avail Capacity Mounted on
/dev/sd0a 56542 27424 23462 54% /
/dev/sd0d 56542 12 50874 0% /tmp
/dev/sd0e 56542 2408 48478 5% /var
/dev/sd0g 835166 598568 194838 75% /usr
my28:/e/local 1168204 904378 147006 86% /usr/local
my28:/var/spool/mail 576030 209562 308866 40% /var/spool/mail
my3:/SunOS4/usr/local 3846624 2405640 1056324 69% /emul/sunos/usr/local
my3:/SunOS4/usr/local 3846624 2405640 1056324 69% /tomat
basil.cdt:/usr/local 3936132 3387828 154704 96% /emul/svr4/usr/local
my21:/export/u20 1763038 1271788 314948 80% /amd/my21/export/u20
ftp.luth.se:/pub/FreeBSD/distfiles
1635228 1252988 382240 77% /mnt
>How-To-Repeat:
Mount a long directory from somewhere and type df :-)
>Fix:
This will fix parts of it; but it is ugly and could be done cleaner:
*** df.c.orig Sat Oct 26 13:01:17 1996
--- df.c Sat Oct 26 12:59:04 1996
***************
*** 307,312 ****
--- 307,314 ----
if (maxwidth < 11)
maxwidth = 11;
+ #define PRETTYWIDTH 18
+ #define PRINTWIDTH (maxwidth > PRETTYWIDTH ? PRETTYWIDTH : maxwidth)
if (++timesthrough == 1) {
if (kflag) {
blocksize = 1024;
***************
*** 315,326 ****
} else
header = getbsize(&headerlen, &blocksize);
(void)printf("%-*.*s %s Used Avail Capacity",
! maxwidth, maxwidth, "Filesystem", header);
if (iflag)
(void)printf(" iused ifree %%iused");
(void)printf(" Mounted on\n");
}
! (void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
used = sfsp->f_blocks - sfsp->f_bfree;
availblks = sfsp->f_bavail + used;
(void)printf(" %*ld %8ld %8ld", headerlen,
--- 317,329 ----
} else
header = getbsize(&headerlen, &blocksize);
(void)printf("%-*.*s %s Used Avail Capacity",
! PRINTWIDTH, maxwidth, "Filesystem", header);
if (iflag)
(void)printf(" iused ifree %%iused");
(void)printf(" Mounted on\n");
}
! (void)printf("%-*.*s%s", PRINTWIDTH, maxwidth, sfsp->f_mntfromname,
! strlen(sfsp->f_mntfromname) >= PRETTYWIDTH ? "\n\t\t " : "");
used = sfsp->f_blocks - sfsp->f_bfree;
availblks = sfsp->f_bavail + used;
(void)printf(" %*ld %8ld %8ld", headerlen,
>Audit-Trail:
>Unformatted: