diff options
author | trasz <trasz@FreeBSD.org> | 2009-05-30 13:59:05 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2009-05-30 13:59:05 +0000 |
commit | 0c63bcbfa4fb9f208ea176334478d17cafd66eac (patch) | |
tree | 9fe18e8e703d17defbd688d53ac96d8a33a828de /sys/fs | |
parent | 3b6c3312d5f59aa27a7bb6530afb6f2546934c5f (diff) | |
download | FreeBSD-src-0c63bcbfa4fb9f208ea176334478d17cafd66eac.zip FreeBSD-src-0c63bcbfa4fb9f208ea176334478d17cafd66eac.tar.gz |
Add VOP_ACCESSX, which can be used to query for newly added V*
permissions, such as VWRITE_ACL. For a filsystems that don't
implement it, there is a default implementation, which works
as a wrapper around VOP_ACCESS.
Reviewed by: rwatson@
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/nullfs/null_vnops.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 3434deb..fd421e4 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -472,6 +472,32 @@ null_access(struct vop_access_args *ap) return (null_bypass((struct vop_generic_args *)ap)); } +static int +null_accessx(struct vop_accessx_args *ap) +{ + struct vnode *vp = ap->a_vp; + accmode_t accmode = ap->a_accmode; + + /* + * Disallow write attempts on read-only layers; + * unless the file is a socket, fifo, or a block or + * character device resident on the filesystem. + */ + if (accmode & VWRITE) { + switch (vp->v_type) { + case VDIR: + case VLNK: + case VREG: + if (vp->v_mount->mnt_flag & MNT_RDONLY) + return (EROFS); + break; + default: + break; + } + } + return (null_bypass((struct vop_generic_args *)ap)); +} + /* * We handle this to eliminate null FS to lower FS * file moving. Don't know why we don't allow this, @@ -720,6 +746,7 @@ null_vptofh(struct vop_vptofh_args *ap) struct vop_vector null_vnodeops = { .vop_bypass = null_bypass, .vop_access = null_access, + .vop_accessx = null_accessx, .vop_bmap = VOP_EOPNOTSUPP, .vop_getattr = null_getattr, .vop_getwritemount = null_getwritemount, |