Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jul 2021 18:17:39 GMT
From:      Robert Wing <rew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: fb2feceac34c - stable/13 - fsck_ffs: fix background fsck in preen mode
Message-ID:  <202107191817.16JIHdZx096146@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by rew:

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

commit fb2feceac34cc9c3fb47ba4a7b0ca31637f8fdf0
Author:     Robert Wing <rew@FreeBSD.org>
AuthorDate: 2021-07-11 20:47:27 +0000
Commit:     Robert Wing <rew@FreeBSD.org>
CommitDate: 2021-07-19 18:06:53 +0000

    fsck_ffs: fix background fsck in preen mode
    
    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:          5cc52631b3b88dfc36d8049dc8bece8573c5f9af
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D30880
    
    (cherry picked from commit 0c5a59252c8e7b80b98521ebc23a415a05ff9594)
---
 sbin/fsck_ffs/main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 67aff2dde73c..2c6c93dce5dc 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -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);
@@ -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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107191817.16JIHdZx096146>