NetBSD Problem Report #58718
From www@netbsd.org Sat Oct 5 19:35:58 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id B94C31A923D
for <gnats-bugs@gnats.NetBSD.org>; Sat, 5 Oct 2024 19:35:58 +0000 (UTC)
Message-Id: <20241005193557.24D8D1A923E@mollari.NetBSD.org>
Date: Sat, 5 Oct 2024 19:35:57 +0000 (UTC)
From: cmeerw@cmeerw.org
Reply-To: cmeerw@cmeerw.org
To: gnats-bugs@NetBSD.org
Subject: df: "total files" and "free files" values swapped in df -G output
X-Send-Pr-Version: www-1.0
>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: needs-pullups
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 05 19:40:00 +0000 2024
>Closed-Date:
>Last-Modified: Sun Oct 06 23:43:28 +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:/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);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58718 CVS commit: src/bin/df
Date: Sun, 6 Oct 2024 13:03:28 -0400
Module Name: src
Committed By: christos
Date: Sun Oct 6 17:03:28 UTC 2024
Modified Files:
src/bin/df: df.c
Log Message:
PR/58718: Christof Meerwald: "total files" and "free files" values swapped
in df -G output
To generate a diff of this commit:
cvs rdiff -u -r1.103 -r1.104 src/bin/df/df.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sun, 06 Oct 2024 23:43:28 +0000
State-Changed-Why:
Looks like this has been fixed in HEAD, yes? Probably needs pullup-10
and pullup-9 now.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.