MCPcopy Create free account
hub / github.com/F-Stack/f-stack / setutimes

Function setutimes

freebsd/kern/vfs_syscalls.c:3123–3156  ·  view source on GitHub ↗

* Common implementation code for utimes(), lutimes(), futimes(), futimens(), * and utimensat(). */

Source from the content-addressed store, hash-verified

3121 * and utimensat().
3122 */
3123static int
3124setutimes(struct thread *td, struct vnode *vp, const struct timespec *ts,
3125 int numtimes, int nullflag)
3126{
3127 struct mount *mp;
3128 struct vattr vattr;
3129 int error, setbirthtime;
3130
3131 if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
3132 return (error);
3133 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
3134 setbirthtime = 0;
3135 if (numtimes < 3 && !VOP_GETATTR(vp, &vattr, td->td_ucred) &&
3136 timespeccmp(&ts[1], &vattr.va_birthtime, < ))
3137 setbirthtime = 1;
3138 VATTR_NULL(&vattr);
3139 vattr.va_atime = ts[0];
3140 vattr.va_mtime = ts[1];
3141 if (setbirthtime)
3142 vattr.va_birthtime = ts[1];
3143 if (numtimes > 2)
3144 vattr.va_birthtime = ts[2];
3145 if (nullflag)
3146 vattr.va_vaflags |= VA_UTIMES_NULL;
3147#ifdef MAC
3148 error = mac_vnode_check_setutimes(td->td_ucred, vp, vattr.va_atime,
3149 vattr.va_mtime);
3150#endif
3151 if (error == 0)
3152 error = VOP_SETATTR(vp, &vattr, td->td_ucred);
3153 VOP_UNLOCK(vp);
3154 vn_finished_write(mp);
3155 return (error);
3156}
3157
3158/*
3159 * Set the access and modification times of a file.

Callers 5

kern_utimesatFunction · 0.85
kern_lutimesFunction · 0.85
kern_futimesFunction · 0.85
kern_futimensFunction · 0.85
kern_utimensatFunction · 0.85

Calls 5

vn_start_writeFunction · 0.85
vn_lockFunction · 0.85
VOP_GETATTRFunction · 0.85
vn_finished_writeFunction · 0.85

Tested by

no test coverage detected