From nobody Tue Sep 06 23:17:34 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MMhB718lLz4bvcC; Tue, 6 Sep 2022 23:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MMhB70g6Gz43by; Tue, 6 Sep 2022 23:17:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662506255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oVQsSO7jbMuZOyY6JdKd6ZsVKEdSn3WzHGKWCgPnlp4=; b=NyaUAMbxAbPtJcPuR5yLywT7KcsemK7DLwAnoMykzARtA1m4oi1pk9wKIlfCsB7SsT/hV9 RKj9nYOEk8L19RRBtkfK+rMIPGUPfZTw7rijMWtybDV0IbSioJ9Omxb8wj/DVYtTJueLC4 U+CK0JPREoJoJpDHo7oW1zJ/EmT/0amorbns2P5yr+GpHBJo7TDjPmh0ChRmIrjY4/tU1d xyZbmnt0UR8nGvpLtLo6lGMmtdgPdrgCYr9gBLPKjEsRbXLp6o0D7TsamFNWZzQ98G9uDk VGs9tKI1eocJ64Q294UWyXmklihzeyzKgYompbyWM/TrwXRdV7gikMUVrJfW4A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MMhB66psQzKvV; Tue, 6 Sep 2022 23:17:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 286NHYHt019643; Tue, 6 Sep 2022 23:17:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 286NHYW5019642; Tue, 6 Sep 2022 23:17:34 GMT (envelope-from git) Date: Tue, 6 Sep 2022 23:17:34 GMT Message-Id: <202209062317.286NHYW5019642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 2ddf8cdbe085 - main - Clarify error messages about bad inodes. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2ddf8cdbe085fb72ba68643709bf01d6fcc079dc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662506255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oVQsSO7jbMuZOyY6JdKd6ZsVKEdSn3WzHGKWCgPnlp4=; b=g8qF37GwO+fUKKqb5+kVHxzEV+pWKkO8030tMeDsijzH3lQmAgDFFE3xqy6/almtgUlpnH ZDtTD/UyKmvfczF9QbhBLbhma3k51SlFdVHcleXrloUbw0CWqNGKkhflSugT0zhlmgIOM3 qfPefRxZrjI3/i2PXxnccSuHWNSDsfbePKT4QrkrdaGVvB1oF8Cx62YFMsJMkKjF9/RLIQ DG18ruzMOVYtHJ8OJhm5bhlhmFs/kFK1fvG/2bmspK8DH8nl5nRpZEMEzRryZIT/wgaFXa kQ5Ugv38qZlCe1EcswZMT5mjeaEOjIATn5MxJpCEhO+XweSGhZRF+1+dhhgC2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662506255; a=rsa-sha256; cv=none; b=hV3e/ZgvuM5/WgAACfzRm54NpRHEb1h65gtLg1tsVLmSxRUkiJjuVRezQVB5ppRky6KJMb 7GShp0eWgKcLiAzBB88UnLF5/kxOTzR9/QcPn6jWVWk16WoIMufsxnV44udKrQiepHADfe bCfPSMZUD4GuDuPCwATzwgDU54h+CqCzadUoPk7pp6SLe/0noRAm/jRff2FjOoLdi1+Zvc KvQtz0Ue48GvrtGC5kKNPayQbc5OkM+ZBxTPCRc+tcDkGEGJg8mz0uDhpwWOsTab1cNq9K oRe0YoISbCG/f6F9Yz2JUkAFiC1UcQHaDz1Wu3uktVPyVhZdgeYHyAmDqcywzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=2ddf8cdbe085fb72ba68643709bf01d6fcc079dc commit 2ddf8cdbe085fb72ba68643709bf01d6fcc079dc Author: Kirk McKusick AuthorDate: 2022-09-06 23:16:24 +0000 Commit: Kirk McKusick 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); }