From nobody Wed Mar 16 18:39:14 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 D260C1A2C217; Wed, 16 Mar 2022 18:39:14 +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 4KJfFG5ZTzz4rpT; Wed, 16 Mar 2022 18:39:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647455954; 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=SJVOVJxDQIo0tp7/Pi3umn/W9q5qBBlckmIxTSKKOro=; b=WoURU595pDqHVzHFoQUOkONecbc2/swHfMg4XDGnXRo6GzJUWSS6KW+/Q9QhkUGzLj2xOS A0OYN/NGztA1Z+d481a27fNFAb8BDvYB8EuMlz2Ck0Bo45SfrWh0vMdgtoRAspca2sbgWP fTwIIS5TvhGg/Fk8wk+2AMQDTGkfOYnX6rfOdMUnUk27OYKh9/vqn+9yuJt+GA4XGJKAVO kf5aYah9I2z4IfcOEM0lRDXLob6k/aARhdQl9Zp6sliUks3VA7LtrsQVySX/fM7kKC43i5 FyLj4mbQY24IfTtGjQEmxcqg3nnwk+NaVbOGD0e26n59tTNRDTDSa5M6bF6QBg== 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 9F7031B0F0; Wed, 16 Mar 2022 18:39:14 +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 22GIdErO040987; Wed, 16 Mar 2022 18:39:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22GIdEEQ040986; Wed, 16 Mar 2022 18:39:14 GMT (envelope-from git) Date: Wed, 16 Mar 2022 18:39:14 GMT Message-Id: <202203161839.22GIdEEQ040986@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: 2983ec0a87a1 - main - Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices. 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: 2983ec0a87a18943564548c5c00c879c8db83edf Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647455954; 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=SJVOVJxDQIo0tp7/Pi3umn/W9q5qBBlckmIxTSKKOro=; b=PYu+IBGzJiBv1nHH63H4ERjW7nebQuHM4hHJ/LfWtvcNyJaK3Mk3aS3B3Fw3QZxMuW3Kdn DkxEYg5ZbwRLEtQwSlQZmv3MUdK77DHy83bx0uJEOu2n4j2U4mcIssCXl2T+AB8ITqRVxC 0LsUtQXOCb/6EzGH6BU0ffE4MiCLn77YZUemC7Uop4+Xu5XzR38sdpkdF40GIabjJMEZCg YwJXdx9fqRD0uekyQ/NMic/fHWWlO3vfmy3kxttPhVtttgbqE1SxAYx5ny2Juo8UPO+FKI a0mid6EewaqDbSEtxUPzgYYBa1GukogZm4QFjXNlx7FlLP/rT2rqHwNXCxbVBA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647455954; a=rsa-sha256; cv=none; b=MT6s7VWAj9oMRw2Yrj+5kxSnN3b2Yu1KTwszilicnHrgSl8TEjvhRvY9k8e6V/Ly2HJ5Nm Pt5XoKFuIqHKOp96gFrqv2ZYm0zIBnAMglFdt7bGLAGX/485zArZgNUMWeCGIn3e9lOVTQ bieQoiVu4Ao4F6zX3GaM7uar14HBVwZh0jOT9jgSVs8IF6HhZr+mA642dIEVzbKBJKS313 +ycF0ug1p7jS5OpB9pAG2fmXJKWstbY8f+K4UqQ/cTYCC95T1xv9i895ht85l7jldhtjLk N65CYvHEcfcMSmgkp4SbyNssOWb0DqalWE2I69YblnN1BN+jTOofncR8g119Aw== 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=2983ec0a87a18943564548c5c00c879c8db83edf commit 2983ec0a87a18943564548c5c00c879c8db83edf Author: Kirk McKusick AuthorDate: 2022-03-16 18:37:15 +0000 Commit: Kirk McKusick CommitDate: 2022-03-16 18:37:15 +0000 Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices. The fsck_ffs(8) utility uses its internal function openfilesys() when opening a disk to be checked. This change avoids the use of pfatal() in openfilesys() which always exits with failure (exit value 8) so that the caller can choose the correct exit value. In the case of a non-existent device it should exit with value 3 which allows the startup system to wait for drives (such as those attached by USB) to come online. Reported by: karels Tested by: karels PR: 262580 MFC after: 3 days --- sbin/fsck_ffs/setup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 66f4f59004cb..0f0d9b61a076 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -219,10 +219,8 @@ openfilesys(char *dev) struct stat statb; int saved_fsreadfd; - if (stat(dev, &statb) < 0) { - pfatal("CANNOT STAT %s: %s\n", dev, strerror(errno)); + if (stat(dev, &statb) < 0) return (0); - } if ((statb.st_mode & S_IFMT) != S_IFCHR && (statb.st_mode & S_IFMT) != S_IFBLK) { if (bkgrdflag != 0 && (statb.st_flags & SF_SNAPSHOT) == 0) { @@ -240,7 +238,6 @@ openfilesys(char *dev) saved_fsreadfd = fsreadfd; if ((fsreadfd = open(dev, O_RDONLY)) < 0) { fsreadfd = saved_fsreadfd; - pfatal("CANNOT OPEN %s: %s\n", dev, strerror(errno)); return (0); } if (saved_fsreadfd != -1)