The branch main has been updated by mckusick:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2e4da012d57edab9d71dc7a67dc706b6a9b7800d

commit 2e4da012d57edab9d71dc7a67dc706b6a9b7800d
Author:     Kirk McKusick <[email protected]>
AuthorDate: 2022-08-29 06:08:49 +0000
Commit:     Kirk McKusick <[email protected]>
CommitDate: 2022-08-29 06:09:29 +0000

    Correct calculation of inode location in getnextino cache.
    
    Fix for 345bfec.
    
    Reported by:  Peter Holm
    Sponsored by: The FreeBSD Foundation
---
 sbin/fsck_ffs/fsutil.c | 2 +-
 sbin/fsck_ffs/inode.c  | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 6b4cdc146def..aa1bfb32ab5b 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -465,7 +465,7 @@ flush(int fd, struct bufarea *bp)
                        struct ufs2_dinode *dp = bp->b_un.b_dinode2;
                        int i;
 
-                       for (i = 0; i < INOPB(&sblock); dp++, i++) {
+                       for (i = 0; i < bp->b_size; dp++, i += sizeof(*dp)) {
                                if (ffs_verify_dinode_ckhash(&sblock, dp) == 0)
                                        continue;
                                pwarn("flush: INODE CHECK-HASH FAILED");
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index ae7124784415..1d65ec667d44 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -425,7 +425,6 @@ void
 ginode(ino_t inumber, struct inode *ip)
 {
        ufs2_daddr_t iblk;
-       ino_t numinodes;
 
        if (inumber < UFS_ROOTINO || inumber > maxino)
                errx(EEXIT, "bad inode number %ju to ginode",
@@ -436,14 +435,12 @@ ginode(ino_t inumber, struct inode *ip)
                ip->i_bp = &inobuf;
                inobuf.b_refcnt++;
                inobuf.b_index = firstinum;
-               numinodes = lastinum - firstinum;
        } else if (icachebp != NULL &&
            inumber >= icachebp->b_index &&
            inumber < icachebp->b_index + INOPB(&sblock)) {
                /* take an additional reference for the returned inode */
                icachebp->b_refcnt++;
                ip->i_bp = icachebp;
-               numinodes = INOPB(&sblock);
        } else {
                iblk = ino_to_fsba(&sblock, inumber);
                /* release our cache-hold reference on old icachebp */
@@ -460,15 +457,14 @@ ginode(ino_t inumber, struct inode *ip)
                icachebp->b_refcnt++;
                icachebp->b_index = rounddown(inumber, INOPB(&sblock));
                ip->i_bp = icachebp;
-               numinodes = INOPB(&sblock);
        }
        if (sblock.fs_magic == FS_UFS1_MAGIC) {
                ip->i_dp = (union dinode *)
-                   &ip->i_bp->b_un.b_dinode1[inumber % numinodes];
+                   &ip->i_bp->b_un.b_dinode1[inumber - firstinum];
                return;
        }
        ip->i_dp = (union dinode *)
-           &ip->i_bp->b_un.b_dinode2[inumber % numinodes];
+           &ip->i_bp->b_un.b_dinode2[inumber - firstinum];
        if (ffs_verify_dinode_ckhash(&sblock, (struct ufs2_dinode *)ip->i_dp)) {
                pwarn("INODE CHECK-HASH FAILED");
                prtinode(ip);

Reply via email to