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
This commit is contained in:
Conrad Meyer 2017-11-20 21:38:24 +00:00
parent 5f8eed2f42
commit 60965b7606

View File

@ -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;