aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Silvers <chs@FreeBSD.org>2021-06-29 21:29:15 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2022-02-28 05:36:06 +0000
commita0c3799828e52151560e37855f14ee39a3e8aca0 (patch)
tree2888f7702cc14b6e236dbf08a4920b7f984bce0b
parent11045f1b7365eb00bfd9f1da71dd65da450fd413 (diff)
downloadsrc-a0c3799828e52151560e37855f14ee39a3e8aca0.tar.gz
src-a0c3799828e52151560e37855f14ee39a3e8aca0.zip
fsck_ffs: don't try to write in read-only mode
(cherry picked from commit ed1a156b038dee0e7a02c2935186ad5d8f4c36c1) Sponsored by: Netflix
-rw-r--r--sbin/fsck_ffs/main.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
index 45bb279ce374..2724893a5b9a 100644
--- a/sbin/fsck_ffs/main.c
+++ b/sbin/fsck_ffs/main.c
@@ -364,17 +364,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