Date: Sun, 11 Dec 2022 00:38:22 GMT From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 8dda7177f964 - stable/13 - Clarify error messages about bad inodes. Message-ID: <202212110038.2BB0cMGY004032@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=8dda7177f96438f19a068d8c48ae7c8554efef23 commit 8dda7177f96438f19a068d8c48ae7c8554efef23 Author: Kirk McKusick <mckusick@FreeBSD.org> AuthorDate: 2022-09-06 23:16:24 +0000 Commit: Kirk McKusick <mckusick@FreeBSD.org> CommitDate: 2022-12-11 00:37:17 +0000 Clarify error messages about bad inodes. (cherry picked from commit 2ddf8cdbe085fb72ba68643709bf01d6fcc079dc) Sponsored by: The FreeBSD Foundation --- sbin/fsck_ffs/pass1.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c index 319a324cc070..49418ec38e4b 100644 --- a/sbin/fsck_ffs/pass1.c +++ b/sbin/fsck_ffs/pass1.c @@ -251,8 +251,10 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) intmax_t size, fixsize; int j, ret, offset; - if ((dp = getnextinode(inumber, rebuildcg)) == NULL) + if ((dp = getnextinode(inumber, rebuildcg)) == NULL) { + pfatal("INVALID INODE"); goto unknown; + } mode = DIP(dp, di_mode) & IFMT; if (mode == 0) { if ((sblock.fs_magic == FS_UFS1_MAGIC && @@ -290,6 +292,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) (mode == IFDIR && DIP(dp, di_size) > MAXDIRSIZE)) { if (debug) printf("bad size %ju:", (uintmax_t)DIP(dp, di_size)); + pfatal("BAD FILE SIZE"); goto unknown; } if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) { @@ -305,19 +308,22 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) if (debug) printf("bad special-file size %ju:", (uintmax_t)DIP(dp, di_size)); + pfatal("BAD SPECIAL-FILE SIZE"); goto unknown; } if ((mode == IFBLK || mode == IFCHR) && (dev_t)DIP(dp, di_rdev) == NODEV) { if (debug) printf("bad special-file rdev NODEV:"); + pfatal("BAD SPECIAL-FILE RDEV"); goto unknown; } ndb = howmany(DIP(dp, di_size), sblock.fs_bsize); if (ndb < 0) { if (debug) - printf("bad size %ju ndb %ju:", + printf("negative size %ju ndb %ju:", (uintmax_t)DIP(dp, di_size), (uintmax_t)ndb); + pfatal("NEGATIVE FILE SIZE"); goto unknown; } if (mode == IFBLK || mode == IFCHR) @@ -345,8 +351,9 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) for (j = ndb; ndb < UFS_NDADDR && j < UFS_NDADDR; j++) if (DIP(dp, di_db[j]) != 0) { if (debug) - printf("bad direct addr[%d]: %ju\n", j, + printf("invalid direct addr[%d]: %ju\n", j, (uintmax_t)DIP(dp, di_db[j])); + pfatal("INVALID DIRECT BLOCK"); goto unknown; } for (j = 0, ndb -= UFS_NDADDR; ndb > 0; j++) @@ -354,12 +361,15 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) for (; j < UFS_NIADDR; j++) if (DIP(dp, di_ib[j]) != 0) { if (debug) - printf("bad indirect addr: %ju\n", + printf("invalid indirect addr: %ju\n", (uintmax_t)DIP(dp, di_ib[j])); + pfatal("INVALID INDIRECT BLOCK"); goto unknown; } - if (ftypeok(dp) == 0) + if (ftypeok(dp) == 0) { + pfatal("UNKNOWN FILE TYPE"); goto unknown; + } n_files++; inoinfo(inumber)->ino_linkcnt = DIP(dp, di_nlink); if (mode == IFDIR) { @@ -483,15 +493,14 @@ checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) } return (1); unknown: - pfatal("UNKNOWN FILE TYPE I=%lu", (u_long)inumber); - inoinfo(inumber)->ino_state = FCLEAR; + ginode(inumber, &ip); + prtinode(&ip); + inoinfo(inumber)->ino_state = USTATE; if (reply("CLEAR") == 1) { - inoinfo(inumber)->ino_state = USTATE; - ginode(inumber, &ip); clearinode(ip.i_dp); inodirty(&ip); - irelse(&ip); } + irelse(&ip); return (1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202212110038.2BB0cMGY004032>