aboutsummaryrefslogtreecommitdiff
path: root/uts
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-03-10 21:37:07 +0000
committerXin LI <delphij@FreeBSD.org>2014-03-10 21:37:07 +0000
commit4d386a222c27084b5ddaf13d2b9dd7f879038525 (patch)
tree086419f6d173728c244bbb4be3177e7358bd480f /uts
parent6ae71ff4dbd0820eaa831169444be9e6c8814fe2 (diff)
downloadsrc-4d386a222c27084b5ddaf13d2b9dd7f879038525.tar.gz
src-4d386a222c27084b5ddaf13d2b9dd7f879038525.zip
Notes
Diffstat (limited to 'uts')
-rw-r--r--uts/common/fs/zfs/zfs_vnops.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/uts/common/fs/zfs/zfs_vnops.c b/uts/common/fs/zfs/zfs_vnops.c
index 6b5c6f852cc2..767d3f765d07 100644
--- a/uts/common/fs/zfs/zfs_vnops.c
+++ b/uts/common/fs/zfs/zfs_vnops.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/* Portions Copyright 2007 Jeremy Teo */
@@ -644,6 +644,16 @@ zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
&zp->z_pflags, 8);
/*
+ * In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our
+ * callers might not be able to detect properly that we are read-only,
+ * so check it explicitly here.
+ */
+ if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
+ ZFS_EXIT(zfsvfs);
+ return (SET_ERROR(EROFS));
+ }
+
+ /*
* If immutable or not appending then return EPERM
*/
if ((zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY)) ||
@@ -4750,6 +4760,16 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
return (SET_ERROR(EINVAL));
}
+ /*
+ * In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our
+ * callers might not be able to detect properly that we are read-only,
+ * so check it explicitly here.
+ */
+ if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) {
+ ZFS_EXIT(zfsvfs);
+ return (SET_ERROR(EROFS));
+ }
+
if (error = convoff(vp, bfp, 0, offset)) {
ZFS_EXIT(zfsvfs);
return (error);