Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/fsck_ffs ufs: more signed/unsigned fixes
details: https://anonhg.NetBSD.org/src/rev/270c6e06dd5b
branches: trunk
changeset: 372956:270c6e06dd5b
user: chs <chs%NetBSD.org@localhost>
date: Sun Jan 08 05:25:24 2023 +0000
description:
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 2a72939843af -r 270c6e06dd5b sbin/fsck_ffs/pass5.c
--- a/sbin/fsck_ffs/pass5.c Sun Jan 08 00:25:44 2023 +0000
+++ b/sbin/fsck_ffs/pass5.c Sun Jan 08 05:25:24 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass5.c,v 1.56 2023/01/07 19:41:29 chs Exp $ */
+/* $NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs 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.56 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs Exp $");
#endif
#endif /* not lint */
@@ -60,12 +60,15 @@
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 @@
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 @@
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 @@
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 @@
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 2a72939843af -r 270c6e06dd5b sbin/fsck_ffs/setup.c
--- a/sbin/fsck_ffs/setup.c Sun Jan 08 00:25:44 2023 +0000
+++ b/sbin/fsck_ffs/setup.c Sun Jan 08 05:25:24 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: setup.c,v 1.105 2023/01/07 19:41:29 chs Exp $ */
+/* $NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs 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.105 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $");
#endif
#endif /* not lint */
@@ -85,7 +85,8 @@
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