Skip to content

Commit

Permalink
fsck_ffs: fix background fsck in preen mode
Browse files Browse the repository at this point in the history
Background checks are only allowed for mounted filesystems - don't try
to open the device for writing when performing a background check.

While here, remove a debugging printf that's commented out.

PR:             256746
Fixes:          5cc5263
Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D30880

(cherry picked from commit 0c5a592)
  • Loading branch information
rob-wing committed Jul 19, 2021
1 parent a54e547 commit fb2fece
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sbin/fsck_ffs/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,14 @@ checkfilesys(char *filesys)
*/
if ((fsreadfd = open(filesys, O_RDONLY)) < 0 || readsb(0) == 0)
exit(3); /* Cannot read superblock */
if (nflag || (fswritefd = open(filesys, O_WRONLY)) < 0) {
if (bkgrdflag == 0 &&
(nflag || (fswritefd = open(filesys, O_WRONLY)) < 0)) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
printf(" (NO WRITE)");
}
if ((sblock.fs_flags & FS_GJOURNAL) != 0) {
//printf("GJournaled file system detected on %s.\n",
// filesys);
if (sblock.fs_clean == 1) {
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
exit(0);
Expand All @@ -317,10 +316,10 @@ checkfilesys(char *filesys)
} else {
pfatal(
"UNEXPECTED INCONSISTENCY, CANNOT RUN FAST FSCK\n");
close(fsreadfd);
close(fswritefd);
}
}
close(fsreadfd);
close(fswritefd);
}
/*
* If we are to do a background check:
Expand Down

0 comments on commit fb2fece

Please sign in to comment.