Module Name:    src
Committed By:   hannken
Date:           Tue Mar  7 11:54:17 UTC 2017

Modified Files:
        src/sys/kern: vfs_syscalls.c

Log Message:
Fix a logic error introduced with Rev. 1.507: defer setting MNT_RDONLY
only if going from read-write to read-only.

Should fix PR kern/52045 (panic: ffs_sync: rofs mod, fs=/ after fsck)


To generate a diff of this commit:
cvs rdiff -u -r1.508 -r1.509 src/sys/kern/vfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.508 src/sys/kern/vfs_syscalls.c:1.509
--- src/sys/kern/vfs_syscalls.c:1.508	Wed Mar  1 10:45:24 2017
+++ src/sys/kern/vfs_syscalls.c	Tue Mar  7 11:54:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $	*/
+/*	$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_fileassoc.h"
@@ -306,7 +306,10 @@ mount_update(struct lwp *l, struct vnode
 			mp->mnt_iflag |= IMNT_WANTRDWR;
 	}
 	mp->mnt_flag &= ~MNT_BASIC_FLAGS;
-	mp->mnt_flag |= (flags & ~MNT_RDONLY) & MNT_BASIC_FLAGS;
+	mp->mnt_flag |= flags & MNT_BASIC_FLAGS;
+	if ((mp->mnt_iflag & IMNT_WANTRDONLY))
+		mp->mnt_flag &= ~MNT_RDONLY;
+
 	error = VFS_MOUNT(mp, path, data, data_len);
 
 	if (error && data != NULL) {
@@ -329,8 +332,6 @@ mount_update(struct lwp *l, struct vnode
 
 	if (error == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY))
 		mp->mnt_flag |= MNT_RDONLY;
-	else if (error == 0 && (mp->mnt_iflag & IMNT_WANTRDWR))
-		mp->mnt_flag &= ~MNT_RDONLY;
 	if (error)
 		mp->mnt_flag = saved_flags;
 	mp->mnt_flag &= ~MNT_OP_FLAGS;

Reply via email to