From nobody Wed Oct 12 09:20:40 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MnRvr6pNRz4fqkX; Wed, 12 Oct 2022 09:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MnRvr6JHlz3dp8; Wed, 12 Oct 2022 09:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665566440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M3VlCeCumc9xXUivMI+RN0tn5pvt1jZFfcHf7f7aFPk=; b=yMAino1wa+Fej/Ye29+v+WjXLAGVz32bQWArISzrrVmstgcXRHGRw8AvdJ+XBFwoD5yoq+ MmfuPzK8GjzovKFijvjnGYz2+GWUjQGrPn/+vfKpLHuNIR6uTSydCEsU0Of8zCwKD3MN5F 9icur39FVfZaEKamw58j6p2vygXratX3NtKs5IyJyiS3At+1W4ahUB+IMhF7/dSeWkNNZq wGGFlm+I7O13z3PZmTKjgSHX1nNmXecInFOPnqzEJoCD1KtjSGcFUS333ZE/TeB2RYPUsR 0Wxrnw1BElAGjtNZr0QvjveY+Djn59GgPyNawJyMvhUW7Qwtev2cA92k4dbS5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MnRvr4v3Vz1GJd; Wed, 12 Oct 2022 09:20:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29C9KeHE053329; Wed, 12 Oct 2022 09:20:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29C9Keau053328; Wed, 12 Oct 2022 09:20:40 GMT (envelope-from git) Date: Wed, 12 Oct 2022 09:20:40 GMT Message-Id: <202210120920.29C9Keau053328@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: 1a566dd6a480 - stable/13 - df: do not report a 100% full inode usage on fs without inodes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1a566dd6a48067b0bf93ef813e01a515be4997ce Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665566440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M3VlCeCumc9xXUivMI+RN0tn5pvt1jZFfcHf7f7aFPk=; b=po50O5hH/AiSRt6iT4padEhDB4hx+vbhPhNqNJFyzcAn122aq6+RlSzkGWlekqPBamxmQa Nj6amQqDE/V+2zTusYv4L7eTNmaU1qI965vaTLzvnO/OSNYqmWXGfnYAHQ4srqYb5IipZd ISVH1sr01FN4blHNEK5MgIg7FCZoCsCt6enz6oSYhEEFz6P6rnViBWYsN94iEfVOwg8NDo lNDjWcvVrVvuFiszF0glQO1RZyBJTNJI4c8hJyLgrn9SJcWOFIo5Li4NMx8Mff89ssq8+W 9CeEJxNOBXfXJj/WEWcB5TRs0T5wZsteAY5SeurIUUvI5tH5DqGex2aqcuUSeA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665566440; a=rsa-sha256; cv=none; b=x+Xd4Yl414wR5bfU3TgpXpfZjhA6j1VHinIWGCv0XODfEOg9/HfRWCJff4aMwNHRZNGHCx 9lrTUhDkVGIKlCGW5GeHxyjIV/5mTbLdxQzLSN6M4MbzRaVTS3UUEScWneLr0xd0qCPUYH BYXpQION2vKp26PnshUcShXN+U6h9wLJfFXzQa7295j3d0MpMEuNArue6sMk8NTqEZQD6X m4iCWK0ddvMfoTUJfiMhfg2qvtis6/GaayxprsHhB00f4jPf4pKxh5aHg8RYfXFi/ToK6P yERkEGL+ll6ZabfU4iyGAgcxBbstMas5nFKEbT3b7yA65a09JkhjhH9e/W996w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=1a566dd6a48067b0bf93ef813e01a515be4997ce commit 1a566dd6a48067b0bf93ef813e01a515be4997ce Author: Baptiste Daroussin AuthorDate: 2022-03-10 14:28:50 +0000 Commit: Baptiste Daroussin CommitDate: 2022-10-12 09:20:09 +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 (cherry picked from commit 2eee44bd5ebcb88bf304215be1b0c68b6802a924) --- 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)