Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.

PR:          262580
Approved by: re (gjb, early MFC)

(cherry picked from commit 2983ec0a87)
(cherry picked from commit 934ba51bc9)
This commit is contained in:
Kirk McKusick 2022-03-16 11:37:15 -07:00
parent 942b5e156d
commit 47b50c2318

View File

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