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
This commit is contained in:
Kirk McKusick 2022-09-06 16:16:24 -07:00
parent d49ad20625
commit 2ddf8cdbe0

View File

@ -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);
}