Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-10]: src/sbin/fsck_ffs Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/cf10ae387c97
branches:  netbsd-10
changeset: 374810:cf10ae387c97
user:      martin <martin%NetBSD.org@localhost>
date:      Sat May 13 11:54:17 2023 +0000

description:
Pull up following revision(s) (requested by chs in ticket #161):

        sbin/fsck_ffs/setup.c: revision 1.106
        sbin/fsck_ffs/pass5.c: revision 1.57

ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick <mckusick%FreeBSD.org@localhost>
  Date:   Sun Oct 25 21:04:07 2020 +0000
    Use proper type (ino_t) for inode numbers to avoid improper sign extention
    in the Pass 5 checks. The manifestation was fsck_ffs exiting with this error:
      ** Phase 5 - Check Cyl groups
      fsck_ffs: inoinfo: inumber 18446744071562087424 out of range
    The error only manifests itself for filesystems bigger than about 100Tb.
    Reported by:  Nikita Grechikhin <ngrechikhin at yandex.ru>
    MFC after:    2 weeks
    Sponsored by: Netflix

diffstat:

 sbin/fsck_ffs/pass5.c |  29 ++++++++++++++++-------------
 sbin/fsck_ffs/setup.c |   7 ++++---
 2 files changed, 20 insertions(+), 16 deletions(-)

diffs (114 lines):

diff -r 92cd07809a58 -r cf10ae387c97 sbin/fsck_ffs/pass5.c
--- a/sbin/fsck_ffs/pass5.c     Sat May 13 11:51:13 2023 +0000
+++ b/sbin/fsck_ffs/pass5.c     Sat May 13 11:54:17 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pass5.c,v 1.55.2.1 2023/05/13 11:51:14 martin Exp $    */
+/*     $NetBSD: pass5.c,v 1.55.2.2 2023/05/13 11:54:17 martin Exp $    */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass5.c    8.9 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass5.c,v 1.55.2.1 2023/05/13 11:51:14 martin Exp $");
+__RCSID("$NetBSD: pass5.c,v 1.55.2.2 2023/05/13 11:54:17 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,12 +60,15 @@ void
 pass5(void)
 {
        int blk, frags, basesize, sumsize, mapsize, cssize;
-       int inomapsize, blkmapsize;
+       uint32_t inomapsize, blkmapsize;
        uint32_t c;
        struct fs *fs = sblock;
        daddr_t dbase, dmax;
        daddr_t d;
-       long i, j, k;
+       uint32_t i;
+       int32_t j;
+       int k;
+       ino_t inum;
        struct csum *cs;
        struct csum_total cstotal;
        struct inodesc idesc[4];
@@ -317,9 +320,9 @@ pass5(void)
                if (!is_ufs2 && ((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
                    fs->fs_old_postblformat == FS_42POSTBLFMT)
                        ocg->cg_magic = CG_MAGIC;
-               j = fs->fs_ipg * c;
-               for (i = 0; i < fs->fs_ipg; j++, i++) {
-                       info = inoinfo(j);
+               inum = fs->fs_ipg * c;
+               for (i = 0; i < fs->fs_ipg; inum++, i++) {
+                       info = inoinfo(inum);
                        switch (info->ino_state) {
 
                        case USTATE:
@@ -338,14 +341,14 @@ pass5(void)
                                break;
 
                        default:
-                               if ((ino_t)j < UFS_ROOTINO)
+                               if (inum < UFS_ROOTINO)
                                        break;
-                               errexit("BAD STATE %d FOR INODE I=%ld",
-                                   info->ino_state, (long)j);
+                               errexit("BAD STATE %d FOR INODE I=%ju",
+                                   info->ino_state, (uintmax_t)inum);
                        }
                }
                if (c == 0)
-                       for (i = 0; i < (long)UFS_ROOTINO; i++) {
+                       for (i = 0; i < UFS_ROOTINO; i++) {
                                setbit(cg_inosused(newcg, 0), i);
                                newcg->cg_cs.cs_nifree--;
                        }
@@ -450,7 +453,7 @@ pass5(void)
                                                continue;
                                        if (cg_inosused(cg, 0)[i] & (1 << k))
                                                continue;
-                                       pwarn("ALLOCATED INODE %ld "
+                                       pwarn("ALLOCATED INODE %u "
                                            "MARKED FREE\n",
                                            c * fs->fs_ipg + i * 8 + k);
                                }
@@ -464,7 +467,7 @@ pass5(void)
                                                continue;
                                        if (cg_inosused(cg, 0)[i] & (1 << k))
                                                continue;
-                                       pwarn("ALLOCATED FRAG %ld "
+                                       pwarn("ALLOCATED FRAG %u "
                                            "MARKED FREE\n",
                                            c * fs->fs_fpg + i * 8 + k);
                                }
diff -r 92cd07809a58 -r cf10ae387c97 sbin/fsck_ffs/setup.c
--- a/sbin/fsck_ffs/setup.c     Sat May 13 11:51:13 2023 +0000
+++ b/sbin/fsck_ffs/setup.c     Sat May 13 11:54:17 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setup.c,v 1.104.2.1 2023/05/13 11:51:14 martin Exp $   */
+/*     $NetBSD: setup.c,v 1.104.2.2 2023/05/13 11:54:17 martin Exp $   */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c    8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.104.2.1 2023/05/13 11:51:14 martin Exp $");
+__RCSID("$NetBSD: setup.c,v 1.104.2.2 2023/05/13 11:54:17 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,8 @@ int16_t sblkpostbl[256];
 int
 setup(const char *dev, const char *origdev)
 {
-       long cg, size, asked, i, j;
+       uint32_t cg;
+       long size, asked, i, j;
        long bmapsize;
        struct disk_geom geo;
        struct dkwedge_info dkw;



Home | Main Index | Thread Index | Old Index