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
This commit is contained in:
Kirk McKusick 2020-10-25 21:04:07 +00:00
parent 8836496815
commit 2d34afcd04
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=367045

View File

@ -63,6 +63,7 @@ pass5(void)
struct fs *fs = &sblock;
ufs2_daddr_t d, dbase, dmax, start;
int rewritecg = 0;
ino_t inum;
struct csum *cs;
struct csum_total cstotal;
struct inodesc idesc[3];
@ -238,9 +239,9 @@ pass5(void)
}
memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
memset(cg_inosused(newcg), 0, (size_t)(mapsize));
j = fs->fs_ipg * c;
for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
switch (inoinfo(j)->ino_state) {
inum = fs->fs_ipg * c;
for (i = 0; i < inostathead[c].il_numalloced; inum++, i++) {
switch (inoinfo(inum)->ino_state) {
case USTATE:
break;
@ -260,10 +261,10 @@ pass5(void)
break;
default:
if (j < (int)UFS_ROOTINO)
if (inum < UFS_ROOTINO)
break;
errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
inoinfo(j)->ino_state, j);
errx(EEXIT, "BAD STATE %d FOR INODE I=%ju",
inoinfo(inum)->ino_state, (uintmax_t)inum);
}
}
if (c == 0)