Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jun 2021 21:29:37 GMT
From:      Chuck Silvers <chs@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ed1a156b038d - main - fsck_ffs: don't try to write in read-only mode
Message-ID:  <202106292129.15TLTbrR087764@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by chs:

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

commit ed1a156b038dee0e7a02c2935186ad5d8f4c36c1
Author:     Chuck Silvers <chs@FreeBSD.org>
AuthorDate: 2021-06-29 21:29:15 +0000
Commit:     Chuck Silvers <chs@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



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