diff options
author | Chuck Silvers <chs@FreeBSD.org> | 2021-06-29 21:29:15 +0000 |
---|---|---|
committer | Chuck Silvers <chs@FreeBSD.org> | 2021-06-29 21:29:15 +0000 |
commit | ed1a156b038dee0e7a02c2935186ad5d8f4c36c1 (patch) | |
tree | b0f0fd8a1d6f57609f3c6618588e56f19efb895f | |
parent | 2ef5995f49c9558ddad4d50810d4528b79afff4a (diff) | |
download | src-ed1a156b038dee0e7a02c2935186ad5d8f4c36c1.tar.gz src-ed1a156b038dee0e7a02c2935186ad5d8f4c36c1.zip |
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
-rw-r--r-- | sbin/fsck_ffs/main.c | 24 |
1 files 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 |