From 4a92140584d2a52ab6c0d3a71975c8f235712c94 Mon Sep 17 00:00:00 2001 From: pooka Date: Thu, 13 Jan 2011 07:25:50 +0000 Subject: [PATCH] allow file system to decide if it can be downgraded from r/w to r/o --- sys/kern/vfs_syscalls.c | 7 ++++--- sys/sys/fstypes.h | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 396b8c275300..7abe8c5c8a1d 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.413 2011/01/02 05:12:33 dholland Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.414 2011/01/13 07:25:50 pooka Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.413 2011/01/02 05:12:33 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.414 2011/01/13 07:25:50 pooka Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -169,7 +169,8 @@ mount_update(struct lwp *l, struct vnode *vp, const char *path, int flags, * prevent read-write to read-only downgrades. */ if ((flags & (MNT_RELOAD | MNT_RDONLY)) != 0 && - (mp->mnt_flag & MNT_RDONLY) == 0) { + (mp->mnt_flag & MNT_RDONLY) == 0 && + (mp->mnt_iflag & IMNT_CAN_RWTORO) == 0) { error = EOPNOTSUPP; /* Needs translation */ goto out; } diff --git a/sys/sys/fstypes.h b/sys/sys/fstypes.h index 7f9f6299eded..f8e540d8cb5e 100644 --- a/sys/sys/fstypes.h +++ b/sys/sys/fstypes.h @@ -1,4 +1,4 @@ -/* $NetBSD: fstypes.h,v 1.27 2011/01/13 07:23:39 pooka Exp $ */ +/* $NetBSD: fstypes.h,v 1.28 2011/01/13 07:25:50 pooka Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -210,6 +210,7 @@ typedef struct fhandle fhandle_t; #define IMNT_DTYPE 0x00000040 /* returns d_type fields */ #define IMNT_HAS_TRANS 0x00000080 /* supports transactions */ #define IMNT_MPSAFE 0x00000100 /* file system code MP safe */ +#define IMNT_CAN_RWTORO 0x00000200 /* can downgrade fs to from rw to r/o */ #define __MNT_FLAGS \ __MNT_BASIC_FLAGS \ @@ -254,6 +255,7 @@ typedef struct fhandle fhandle_t; #define __IMNT_FLAG_BITS \ "\20" \ + "\12IMNT_CAN_RWTORO" \ "\11IMNT_MPSAFE" \ "\10IMNT_HAS_TRANS" \ "\07IMNT_DTYPE" \