git: 2983ec0a87a1 - main - Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Wed, 16 Mar 2022 18:39:14 UTC
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=2983ec0a87a18943564548c5c00c879c8db83edf

commit 2983ec0a87a18943564548c5c00c879c8db83edf
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-03-16 18:37:15 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
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)