From nobody Sun Dec 11 00:38:22 2022 X-Original-To: dev-commits-src-branches@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 4NV5TW14Gkz4jgsK; Sun, 11 Dec 2022 00:38:23 +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 4NV5TW0KVCz4Hpc; Sun, 11 Dec 2022 00:38:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670719103; 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=1X3KkfLHeTiJRou0wanz3BUnlNCBepowXibtnQkALpM=; b=L/BgwIo1xtlW7V4ULgsLK33gJviVTglOYhOdqAjEVHnbUEsTxzsq29kboOZO7jVYstyvGb ULZ+CrIGqCqbuqdGX1i4mmCykTFd+SLCyalL/kVc3PJN3lZ1f6ZHTAFSGG1eykr/A+3K99 0rcuqUmgRThiwIXS/PQ6/fiYSrGuOBmKSEqh9amV8Rh18//RjaAayazrALg3wwcPZ3aURa 04o/hx8JAZ77iyFIUCEeENRR1mH7kiBtkeOkCeQG2thNXgsQZcKNGZy/Ks8+exqxHBr2XW dO+H0NAmyiFGSDx37s+MQzHbOk1Qnt6pWx463EJO2xBUqcPHoDSRtgPb0teQ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670719103; 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=1X3KkfLHeTiJRou0wanz3BUnlNCBepowXibtnQkALpM=; b=IXKknIzMQpRnze4zHYr+0hXgBnONkdc/jdHEjetPy+M3z84z8BlJsXypVssDuFpZvc+bHa Hu25oDBv6MMOVRFZIhZdz7Goev250+wuCyuqnEtL30iMQrrOnhQZP22xdksAsubS4p8MWX 4oURH7wKwRijflfZBJOId93b2CFnog2paPz0F3B97m3Nm1ozuHth+nEuwSUFmFAsqqAsSh HGXVnLuJTqgUJT94JihflcwKTzMBrEbtdJs+CKYWRhpNwfwbEGY0rAS0aXLZX4GIx6KHnF mPFF+Z+kCdBWqvPs2SxOoH+voBoXwPY+IYfL4dgDX9nFc3GGUYhX7QQdrUEN0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670719103; a=rsa-sha256; cv=none; b=LSNLKmrrgF+ih9pauMeDNbUqL30dXMypGv3xaDcDitc6ff39DRDE4/TxfzRPkHlBrXih5A nzgcU4649tEReh+8TE0nrAySrmczEJHCfTP19ya8NBguFwml0yKEGVo/x1JWlFHDQaNH3l +oyE46ZE82lKFOyqxFQxtcHMQjtOBQ0oL/xyhQxens5NJmJeFhs+fE6k1UQWJG3tl2mmJJ 08ZKCZfXLTKrjEVPOQt2tqg5gO3Z9pDo0k/gkDyaUhIsShgHGSxbvKt3c0EE00GQG1LaU8 CH8kkuQF0SxEYL/gBaHBOnUGShwY60MXeCVnT5DH6lbBQvxGcQUuR+ZQr+7LWg== 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 4NV5TV6Njmzbgk; Sun, 11 Dec 2022 00:38:22 +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 2BB0cMBi004033; Sun, 11 Dec 2022 00:38:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BB0cMGY004032; Sun, 11 Dec 2022 00:38:22 GMT (envelope-from git) Date: Sun, 11 Dec 2022 00:38:22 GMT Message-Id: <202212110038.2BB0cMGY004032@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kirk McKusick Subject: git: 8dda7177f964 - stable/13 - Clarify error messages about bad inodes. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 8dda7177f96438f19a068d8c48ae7c8554efef23 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=8dda7177f96438f19a068d8c48ae7c8554efef23 commit 8dda7177f96438f19a068d8c48ae7c8554efef23 Author: Kirk McKusick AuthorDate: 2022-09-06 23:16:24 +0000 Commit: Kirk McKusick 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); }