From owner-dev-commits-src-all@freebsd.org Tue Jun 29 21:29:38 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 232E565317E; Tue, 29 Jun 2021 21:29:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GDyKt0SDrz4WPL; Tue, 29 Jun 2021 21:29:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EBDCA20904; Tue, 29 Jun 2021 21:29:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15TLTb07087765; Tue, 29 Jun 2021 21:29:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15TLTbrR087764; Tue, 29 Jun 2021 21:29:37 GMT (envelope-from git) Date: Tue, 29 Jun 2021 21:29:37 GMT Message-Id: <202106292129.15TLTbrR087764@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Chuck Silvers Subject: git: ed1a156b038d - main - fsck_ffs: don't try to write in read-only mode MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: chs X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ed1a156b038dee0e7a02c2935186ad5d8f4c36c1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jun 2021 21:29:38 -0000 The branch main has been updated by chs: URL: https://cgit.FreeBSD.org/src/commit/?id=ed1a156b038dee0e7a02c2935186ad5d8f4c36c1 commit ed1a156b038dee0e7a02c2935186ad5d8f4c36c1 Author: Chuck Silvers AuthorDate: 2021-06-29 21:29:15 +0000 Commit: Chuck Silvers 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