git: 2eee44bd5ebc - main - df: do not report a 100% full inode usage on fs without inodes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Mar 2022 07:49:49 UTC
The branch main has been updated by bapt:
URL: https://cgit.FreeBSD.org/src/commit/?id=2eee44bd5ebcb88bf304215be1b0c68b6802a924
commit 2eee44bd5ebcb88bf304215be1b0c68b6802a924
Author: Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-03-10 14:28:50 +0000
Commit: Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-03-11 07:49:44 +0000
df: do not report a 100% full inode usage on fs without inodes
Before:
devfs 2 2 0 100% 0 0 100% /dev
After:
devfs 2 2 0 100% 0 0 - /dev
The previous behaviour was confusing for end users and many monitoring tools
Note the linux df tools is also using the same syntax '-' for such filesystem
MFC After: 2 weeks
Reviewed by: manu, emaste, imp
Differential Revision: https://reviews.freebsd.org/D34515
---
bin/df/df.1 | 5 ++++-
bin/df/df.c | 9 ++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/bin/df/df.1 b/bin/df/df.1
index d542dbde8067..64e471fedc42 100644
--- a/bin/df/df.1
+++ b/bin/df/df.1
@@ -29,7 +29,7 @@
.\" @(#)df.1 8.3 (Berkeley) 5/8/95
.\" $FreeBSD$
.\"
-.Dd October 5, 2020
+.Dd March 11, 2022
.Dt DF 1
.Os
.Sh NAME
@@ -109,6 +109,9 @@ In conjunction with the
or
.Fl H
options, the number of inodes is scaled by powers of 1000.
+In case the filesystem has no inodes then
+.Sq -
+is displayed instead of the usage percentage.
.It Fl k
Use 1024 byte (1 Kibibyte) blocks rather than the default.
This overrides the
diff --git a/bin/df/df.c b/bin/df/df.c
index 63c37de92d62..627d8b1c861d 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -561,9 +561,12 @@ prtstat(struct statfs *sfsp, struct maxwidths *mwp)
xo_emit(format, mwp->iused, (intmax_t)used,
mwp->ifree, (intmax_t)sfsp->f_ffree);
}
- xo_emit(" {:inodes-used-percent/%4.0f}{U:%%} ",
- inodes == 0 ? 100.0 :
- (double)used / (double)inodes * 100.0);
+ if (inodes == 0)
+ xo_emit(" {:inodes-used-percent/ -}{U:} ");
+ else {
+ xo_emit(" {:inodes-used-percent/%4.0f}{U:%%} ",
+ (double)used / (double)inodes * 100.0);
+ }
} else
xo_emit(" ");
if (strncmp(sfsp->f_mntfromname, "total", MNAMELEN) != 0)