summaryrefslogtreecommitdiffstats
path: root/sys/fs/tmpfs
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
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')
-rw-r--r--sys/fs/tmpfs/tmpfs.h4
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c28
-rw-r--r--sys/fs/tmpfs/tmpfs_vnops.c7
3 files changed, 15 insertions, 24 deletions
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h
index 196749b..8c618e0 100644
--- a/sys/fs/tmpfs/tmpfs.h
+++ b/sys/fs/tmpfs/tmpfs.h
@@ -425,8 +425,8 @@ int tmpfs_chmod(struct vnode *, mode_t, struct ucred *, struct thread *);
int tmpfs_chown(struct vnode *, uid_t, gid_t, struct ucred *,
struct thread *);
int tmpfs_chsize(struct vnode *, u_quad_t, struct ucred *, struct thread *);
-int tmpfs_chtimes(struct vnode *, struct timespec *, struct timespec *,
- struct timespec *, int, struct ucred *, struct thread *);
+int tmpfs_chtimes(struct vnode *, struct vattr *, struct ucred *cred,
+ struct thread *);
void tmpfs_itimes(struct vnode *, const struct timespec *,
const struct timespec *);
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;
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
index 7f74f20..8af7755 100644
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -378,10 +378,6 @@ tmpfs_getattr(struct vop_getattr_args *v)
return 0;
}
-/* --------------------------------------------------------------------- */
-
-/* XXX Should this operation be atomic? I think it should, but code in
- * XXX other places (e.g., ufs) doesn't seem to be... */
int
tmpfs_setattr(struct vop_setattr_args *v)
{
@@ -425,8 +421,7 @@ tmpfs_setattr(struct vop_setattr_args *v)
vap->va_mtime.tv_nsec != VNOVAL) ||
(vap->va_birthtime.tv_sec != VNOVAL &&
vap->va_birthtime.tv_nsec != VNOVAL)))
- error = tmpfs_chtimes(vp, &vap->va_atime, &vap->va_mtime,
- &vap->va_birthtime, vap->va_vaflags, cred, td);
+ error = tmpfs_chtimes(vp, vap, cred, td);
/* Update the node times. We give preference to the error codes
* generated by this function rather than the ones that may arise
OpenPOWER on IntegriCloud