NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/58718: df: "total files" and "free files" values swapped in df -G output



>Number:         58718
>Category:       bin
>Synopsis:       df: "total files" and "free files" values swapped in df -G output
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 05 19:40:00 +0000 2024
>Originator:     Christof Meerwald
>Release:        10.0
>Organization:
>Environment:
NetBSD linveo.cmeerw.net 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
The values for "total files" and "free files" seem to be swapped in the output of "df -G", e.g. "df -G /"

         / (/dev/dk0    ):   16384 block size         2048 frag size
  12321342 total blocks   10206984 free blocks     9590917 available
   2918296 total files     3084478 free files         a800 filesys id
       ffs fstype        0x2005000 flag                255 filename length
         0 owner                 2 syncwrites          392 asyncwrites

Surely, "total files" should be greater than "free files" here.

Looking at the source code for df.c I see:

		(void)printf("%10" PRId64 " total files  %10" PRId64
		    " free files %12lx filesys id\n",
		    (uint64_t)sfsp->f_ffree, (uint64_t)sfsp->f_files,
		    sfsp->f_fsid);

So it's using "f_ffree" for "total files" and "f_files" for "free files".

That's obviously swapped around, but to be absolutely sure, looking at the statvfs.5 man page:

         fsfilcnt_t  f_files;        /* total file nodes in file system */
         fsfilcnt_t  f_ffree;        /* free file nodes in file system */
>How-To-Repeat:
Run "df -G /" and look at the values for "total files" and "free files"
>Fix:
change the code as follows:

		(void)printf("%10" PRId64 " total files  %10" PRId64
		    " free files %12lx filesys id\n",
		    (uint64_t)sfsp->f_files, (uint64_t)sfsp->f_ffree,
		    sfsp->f_fsid);



Home | Main Index | Thread Index | Old Index