aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2017-11-20 21:38:24 +0000
committerConrad Meyer <cem@FreeBSD.org>2017-11-20 21:38:24 +0000
commit60965b7606bcb194c87043d83ad62589b7e72d7f (patch)
treeff705f168d605d39c74706cab49cc6bd77ee1ce8 /sys
parent5f8eed2f4230a16279dd6034af5009ac5febae9d (diff)
downloadsrc-60965b7606bcb194c87043d83ad62589b7e72d7f.tar.gz
src-60965b7606bcb194c87043d83ad62589b7e72d7f.zip
msdosfs(5): Reflect READONLY attribute in file mode
Msdosfs allows setting READONLY by clearing the owner write bit of the file mode. (While here, correct the misspelling of S_IWUSR as VWRITE. No functional change.) In msdosfs_getattr, intuitively reflect that READONLY attribute to userspace in the file mode. Reported by: Karl Denninger <karl AT denninger.net> Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=326031
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
index 1a3b8bbc10dc..cbe24abf89db 100644
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ b/sys/fs/msdosfs/msdosfs_vnops.c
@@ -287,6 +287,8 @@ msdosfs_getattr(struct vop_getattr_args *ap)
vap->va_fileid = fileid;
mode = S_IRWXU|S_IRWXG|S_IRWXO;
+ if (dep->de_Attributes & ATTR_READONLY)
+ mode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
vap->va_mode = mode &
(ap->a_vp->v_type == VDIR ? pmp->pm_dirmask : pmp->pm_mask);
vap->va_uid = pmp->pm_uid;
@@ -502,7 +504,7 @@ msdosfs_setattr(struct vop_setattr_args *ap)
}
if (vp->v_type != VDIR) {
/* We ignore the read and execute bits. */
- if (vap->va_mode & VWRITE)
+ if (vap->va_mode & S_IWUSR)
dep->de_Attributes &= ~ATTR_READONLY;
else
dep->de_Attributes |= ATTR_READONLY;