Actually, use FWRITE for device open only if we aren't doing MNT_RDONLY.

This still allows to mount read-only images with -o ro.
This commit is contained in:
pooka 2008-09-04 12:28:14 +00:00
parent 795cda8d6a
commit 811ee024bf
1 changed files with 7 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysvbfs_vfsops.c,v 1.25 2008/09/04 12:02:10 pooka Exp $ */ /* $NetBSD: sysvbfs_vfsops.c,v 1.26 2008/09/04 12:28:14 pooka Exp $ */
/*- /*-
* Copyright (c) 2004 The NetBSD Foundation, Inc. * Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.25 2008/09/04 12:02:10 pooka Exp $"); __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.26 2008/09/04 12:28:14 pooka Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -163,7 +163,7 @@ sysvbfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
kauth_cred_t cred = l->l_cred; kauth_cred_t cred = l->l_cred;
struct sysvbfs_mount *bmp; struct sysvbfs_mount *bmp;
struct partinfo dpart; struct partinfo dpart;
int error; int error, oflags;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0); error = vinvalbuf(devvp, V_SAVE, cred, l, 0, 0);
@ -172,7 +172,10 @@ sysvbfs_mountfs(struct vnode *devvp, struct mount *mp, struct lwp *l)
return error; return error;
/* Open block device */ /* Open block device */
if ((error = VOP_OPEN(devvp, FREAD | FWRITE, NOCRED)) != 0) oflags = FREAD;
if ((mp->mnt_flag & MNT_RDONLY) == 0)
oflags |= FWRITE;
if ((error = VOP_OPEN(devvp, oflags, NOCRED)) != 0)
return error; return error;
/* Get partition information */ /* Get partition information */