git: 595746df6fe9 - main - Additional diagnostic output when running fsck_ffs with debugging flag (-d)

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sun, 30 Oct 2022 22:01:00 UTC
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=595746df6fe946363233bd3eb73abe34e4457359

commit 595746df6fe946363233bd3eb73abe34e4457359
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-10-30 21:59:44 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-10-30 22:00:20 +0000

    Additional diagnostic output when running fsck_ffs with debugging flag (-d)
    
    MFC after:    1 week
    Sponsored by: The FreeBSD Foundation
---
 sbin/fsck_ffs/pass5.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
index 324e725929f6..61be54ed54ed 100644
--- a/sbin/fsck_ffs/pass5.c
+++ b/sbin/fsck_ffs/pass5.c
@@ -375,6 +375,22 @@ pass5(void)
 	if (cursnapshot == 0 &&
 	    memcmp(&cstotal, &fs->fs_cstotal, sizeof cstotal) != 0
 	    && dofix(&idesc[0], "SUMMARY BLK COUNT(S) WRONG IN SUPERBLK")) {
+		if (debug) {
+			printf("cstotal is currently: %jd dirs, %jd blks free, "
+			    "%jd frags free, %jd inos free, %jd clusters\n",
+			    (intmax_t)fs->fs_cstotal.cs_ndir,
+			    (intmax_t)fs->fs_cstotal.cs_nbfree,
+			    (intmax_t)fs->fs_cstotal.cs_nffree,
+			    (intmax_t)fs->fs_cstotal.cs_nifree,
+			    (intmax_t)fs->fs_cstotal.cs_numclusters);
+			printf("cstotal ought to be:  %jd dirs, %jd blks free, "
+			    "%jd frags free, %jd inos free, %jd clusters\n",
+			    (intmax_t)cstotal.cs_ndir,
+			    (intmax_t)cstotal.cs_nbfree,
+			    (intmax_t)cstotal.cs_nffree,
+			    (intmax_t)cstotal.cs_nifree,
+			    (intmax_t)cstotal.cs_numclusters);
+		}
 		memmove(&fs->fs_cstotal, &cstotal, sizeof cstotal);
 		fs->fs_ronly = 0;
 		fs->fs_fmod = 0;