From c63b8853fea10332bbebd6d10f1a03105b48387a Mon Sep 17 00:00:00 2001 From: ad Date: Wed, 24 Sep 2008 10:07:19 +0000 Subject: [PATCH] PR kern/30525 remounting ffs read-only (mount -ur) does not sync metadata Prevent r/w to r/o downgrade until such time as someone has verified all the relevant file system code. --- sys/kern/vfs_syscalls.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 7fd90fb5960a..ce0570279e24 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.372 2008/09/24 09:44:09 ad Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.373 2008/09/24 10:07:19 ad Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.372 2008/09/24 09:44:09 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.373 2008/09/24 10:07:19 ad Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_43.h" @@ -171,9 +171,11 @@ mount_update(struct lwp *l, struct vnode *vp, const char *path, int flags, /* * We only allow the filesystem to be reloaded if it - * is currently mounted read-only. + * is currently mounted read-only. Additionally, we + * prevent read-write to read-only downgrades. */ - if (flags & MNT_RELOAD && !(mp->mnt_flag & MNT_RDONLY)) { + if ((flags & (MNT_RELOAD | MNT_RDONLY)) != 0 && + (mp->mnt_flag & MNT_RDONLY) == 0) { error = EOPNOTSUPP; /* Needs translation */ goto out; }