Subject: df: text formatting issues when kernel uses devfs

From: Eric Yagerlener <[email-masked]>
Date: Mon, 26 Jul 2004 13:23:38 -0400 (EDT)

Subject: df: text formatting issues when kernel uses devfs
Package: coreutils
Version: 5.0.91-2
Severity: normal

Unlike the command ps which will adjust its text formatting for the width 
of the terminal, and will not truncate or otherwise add extra linefeeds to 
its output if stdout is directed to a pipe or file, df always formats the 
text for an 80 column terminal regardless of actual terminal width or if 
stdout is a pipe or a file.

The linefeed after the device name breaks perl and shell scripts that 
parse df's output.  df should never attempt to split lines if it's 
outputing to a pipe or a file.  Even if the terminal is wide enough to 
display the data in one line, the extra linefeed is still inserted 
regardless.  The text formatting should be changed to be more 
concise when dealing with kernels that use devfs.

Sample Ugly Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/ide/host0/bus1/target0/lun0/part3
                       14259064  11277248   2836952  80% /
tmpfs                   128404         0    128404   0% /dev/shm
/dev/ide/host0/bus1/target0/lun0/part1
                          29737      1776     27347   7% /boot
/dev/ide/host0/bus0/target0/lun0/part3
                       79723696  32051984  43684784  43% /video

With more space efficient text formatting, the output will almost fit an 
80 column display.

Filesystem           		       1K-blocks      Used Available Use% Mounted on
/dev/ide/host0/bus1/target0/lun0/part3  14259064  11277248   2836952  80% / 
tmpfs                                     128404         0    128404   0% /dev/shm
/dev/ide/host0/bus1/target0/lun0/part1     29737      1776     27347   7% /boot
/dev/ide/host0/bus0/target0/lun0/part3  79723696  32051984  43684784  43% /video

df -h is even uglier.

Filesystem            Size  Used Avail Use% Mounted on
/dev/ide/host0/bus1/target0/lun0/part3
                        14G   11G  2.8G  80% /
tmpfs                 126M     0  126M   0% /dev/shm
/dev/ide/host0/bus1/target0/lun0/part1
                        30M  1.8M   27M   7% /boot
/dev/ide/host0/bus0/target0/lun0/part3
                        77G   31G   42G  43% /video

With some reformatting it WILL fit an 80 column display properly!

Filesystem            			Size  Used Avail Use% Mounted on
/dev/ide/host0/bus1/target0/lun0/part3   14G   11G  2.8G  80% /
tmpfs                 			126M     0  126M   0% /dev/shm
/dev/ide/host0/bus1/target0/lun0/part1	 30M  1.8M   27M   7% /boot
/dev/ide/host0/bus0/target0/lun0/part3   77G   31G   42G  43% /video

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux athlon-xp 2.4.26 #1 Sat Jul 24 11:22:24 EDT 2004 i686
Locale: LANG=en_US, LC_CTYPE=en_US

Versions of packages coreutils depends on:
ii  libacl1                     2.2.23-1     Access control list shared library
ii  libattr1                    2.4.16-1     Extended attribute shared library
ii  libc6                       2.3.2.ds1-13 GNU C Library: Shared libraries an

---
Eric Yagerlener