git: ed1a156b038d - main - fsck_ffs: don't try to write in read-only mode

Chuck Silvers chs at FreeBSD.org
Tue Jun 29 21:29:38 UTC 2021


The branch main has been updated by chs:

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

commit ed1a156b038dee0e7a02c2935186ad5d8f4c36c1
Author:     Chuck Silvers <chs at FreeBSD.org>
AuthorDate: 2021-06-29 21:29:15 +0000
Commit:     Chuck Silvers <chs at FreeBSD.org>
CommitDate: 2021-06-29 21:29:15 +0000

    fsck_ffs: don't try to write in read-only mode
    
    Skip trying to change fs_mtime for SU+J if we are running read-only.
    
    Reviewed by:    mckusick
    Sponsored by:   Netflix
---
 sbin/fsck_ffs/main.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 67aff2dde73c..edda3d785f09 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -441,17 +441,19 @@ checkfilesys(char *filesys)
 			sujrecovery = 0;
 			printf("** Skipping journal, falling through to full fsck\n\n");
 		}
-		/*
-		 * Write the superblock so we don't try to recover the
-		 * journal on another pass. If this is the only change
-		 * to the filesystem, we do not want it to be called
-		 * out as modified.
-		 */
-		sblock.fs_mtime = time(NULL);
-		sbdirty();
-		ofsmodified = fsmodified;
-		flush(fswritefd, &sblk);
-		fsmodified = ofsmodified;
+		if (fswritefd != -1) {
+			/*
+			 * Write the superblock so we don't try to recover the
+			 * journal on another pass. If this is the only change
+			 * to the filesystem, we do not want it to be called
+			 * out as modified.
+			 */
+			sblock.fs_mtime = time(NULL);
+			sbdirty();
+			ofsmodified = fsmodified;
+			flush(fswritefd, &sblk);
+			fsmodified = ofsmodified;
+		}
 	}
 	/*
 	 * If the filesystem was run on an old kernel that did not


More information about the dev-commits-src-main mailing list