summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs/tmpfs_subr.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-06-24 08:21:43 +0000
committerkib <kib@FreeBSD.org>2014-06-24 08:21:43 +0000
commit3b207676966493f5897b60f1575ca81297373eb4 (patch)
tree245675f195f5eed0fb417672371ef12b73f813c6 /sys/fs/tmpfs/tmpfs_subr.c
parentcf140f008f5d28d6463422c17af1c4a6013dd0d6 (diff)
downloadFreeBSD-src-3b207676966493f5897b60f1575ca81297373eb4.zip
FreeBSD-src-3b207676966493f5897b60f1575ca81297373eb4.tar.gz
MFC r267564:
In msdosfs_setattr(), add a check for result of the utimes(2) permissions test. Refactor the permission checks for utimes(2).
Diffstat (limited to 'sys/fs/tmpfs/tmpfs_subr.c')
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 4d9b71d..a113d40 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -1677,8 +1677,8 @@ tmpfs_chsize(struct vnode *vp, u_quad_t size, struct ucred *cred,
* The vnode must be locked on entry and remain locked on exit.
*/
int
-tmpfs_chtimes(struct vnode *vp, struct timespec *atime, struct timespec *mtime,
- struct timespec *birthtime, int vaflags, struct ucred *cred, struct thread *l)
+tmpfs_chtimes(struct vnode *vp, struct vattr *vap,
+ struct ucred *cred, struct thread *l)
{
int error;
struct tmpfs_node *node;
@@ -1695,29 +1695,25 @@ tmpfs_chtimes(struct vnode *vp, struct timespec *atime, struct timespec *mtime,
if (node->tn_flags & (IMMUTABLE | APPEND))
return EPERM;
- /* Determine if the user have proper privilege to update time. */
- if (vaflags & VA_UTIMES_NULL) {
- error = VOP_ACCESS(vp, VADMIN, cred, l);
- if (error)
- error = VOP_ACCESS(vp, VWRITE, cred, l);
- } else
- error = VOP_ACCESS(vp, VADMIN, cred, l);
- if (error)
+ error = vn_utimes_perm(vp, vap, cred, l);
+ if (error != 0)
return (error);
- if (atime->tv_sec != VNOVAL && atime->tv_nsec != VNOVAL)
+ if (vap->va_atime.tv_sec != VNOVAL && vap->va_atime.tv_nsec != VNOVAL)
node->tn_status |= TMPFS_NODE_ACCESSED;
- if (mtime->tv_sec != VNOVAL && mtime->tv_nsec != VNOVAL)
+ if (vap->va_mtime.tv_sec != VNOVAL && vap->va_mtime.tv_nsec != VNOVAL)
node->tn_status |= TMPFS_NODE_MODIFIED;
- if (birthtime->tv_nsec != VNOVAL && birthtime->tv_nsec != VNOVAL)
+ if (vap->va_birthtime.tv_nsec != VNOVAL &&
+ vap->va_birthtime.tv_nsec != VNOVAL)
node->tn_status |= TMPFS_NODE_MODIFIED;
- tmpfs_itimes(vp, atime, mtime);
+ tmpfs_itimes(vp, &vap->va_atime, &vap->va_mtime);
- if (birthtime->tv_nsec != VNOVAL && birthtime->tv_nsec != VNOVAL)
- node->tn_birthtime = *birthtime;
+ if (vap->va_birthtime.tv_nsec != VNOVAL &&
+ vap->va_birthtime.tv_nsec != VNOVAL)
+ node->tn_birthtime = vap->va_birthtime;
MPASS(VOP_ISLOCKED(vp));
return 0;
OpenPOWER on IntegriCloud