Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Sep 2022 23:17:34 GMT
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2ddf8cdbe085 - main - Clarify error messages about bad inodes.
Message-ID:  <202209062317.286NHYW5019642@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mckusick:

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

commit 2ddf8cdbe085fb72ba68643709bf01d6fcc079dc
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-09-06 23:16:24 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-09-06 23:17:11 +0000

    Clarify error messages about bad inodes.
    
    When something was found wrong with an inode the error message
    was always "UNKNOWN FILE TYPE". This error is now used only when
    the file type field is wrong. Other errors have their own messages:
    "BAD FILE SIZE", "NEGATIVE FILE SIZE", "BAD SPECIAL-FILE RDEV",
    "INVALID DIRECT BLOCK", and "INVALID INDIRECT BLOCK".
    
    More complete information about the inode is also provided.
    
    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?202209062317.286NHYW5019642>