git: 157a960058c2 - stable/13 - fsck_ffs(8): fix divide by zero when debug messages are enabled

Robert Wing rew at FreeBSD.org
Fri Jun 11 16:53:59 UTC 2021


The branch stable/13 has been updated by rew:

URL: https://cgit.FreeBSD.org/src/commit/?id=157a960058c221bda068c902ba9ccf216fa2fbaa

commit 157a960058c221bda068c902ba9ccf216fa2fbaa
Author:     Robert Wing <rew at FreeBSD.org>
AuthorDate: 2021-05-20 20:53:52 +0000
Commit:     Robert Wing <rew at FreeBSD.org>
CommitDate: 2021-06-11 16:44:29 +0000

    fsck_ffs(8): fix divide by zero when debug messages are enabled
    
    Only print buffer cache debug message when a cache lookup has been done.
    
    When running `fsck_ffs -d` on a gjournal'ed filesystem, it's possible
    that totalreads is greater than zero when no cache lookup has been
    done - causing a divide by zero. This commit fixes the following error:
    
        Floating point exception (core dumped)
    
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D30370
    
    (cherry picked from commit 20123b25ee51e9b122676a30d45c21a506bf1461)
---
 sbin/fsck_ffs/fsutil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index b13ba4c54bde..db22ee5b20cf 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -576,7 +576,7 @@ ckfini(int markclean)
 			rerun = 1;
 		}
 	}
-	if (debug && totalreads > 0)
+	if (debug && cachelookups > 0)
 		printf("cache with %d buffers missed %d of %d (%d%%)\n",
 		    numbufs, cachereads, cachelookups,
 		    (int)(cachereads * 100 / cachelookups));


More information about the dev-commits-src-all mailing list