From b20f428bf36ab0b3fddb4733759e212248a8daf3 Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 5 Apr 2002 15:16:08 +0000 Subject: [PATCH] Fixed assorted bugs in setting of timestamps in devfs_setattr(). Setting of timestamps on devices had no effect visible to userland because timestamps for devices were set in places that are never used. This broke: - update of file change time after a change of an attribute - setting of file access and modification times. The VA_UTIMES_NULL case did not work. Revs 1.31-1.32 were supposed to fix this by copying correct bits from ufs, but had little or no effect because the old checks were not removed. --- sys/fs/devfs/devfs_vnops.c | 45 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index c0a8098fd006..d5bd3eabcade 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -725,14 +725,6 @@ devfs_setattr(ap) c = 1; } - if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { - /* see comment in ufs_vnops::ufs_setattr() */ - if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, ap->a_td)) && - ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || - (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, ap->a_td)))) - return (error); - } - if (vap->va_mode != (mode_t)VNOVAL) { if ((ap->a_cred->cr_uid != de->de_uid) && (error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT))) @@ -740,23 +732,34 @@ devfs_setattr(ap) de->de_mode = vap->va_mode; c = 1; } - if (vap->va_atime.tv_sec != VNOVAL) { - if ((ap->a_cred->cr_uid != de->de_uid) && - (error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT))) + + if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { + /* See the comment in ufs_vnops::ufs_setattr(). */ + if ((error = VOP_ACCESS(vp, VADMIN, ap->a_cred, ap->a_td)) && + ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || + (error = VOP_ACCESS(vp, VWRITE, ap->a_cred, ap->a_td)))) return (error); - de->de_atime = vap->va_atime; - c = 1; - } - if (vap->va_mtime.tv_sec != VNOVAL) { - if ((ap->a_cred->cr_uid != de->de_uid) && - (error = suser_cred(ap->a_td->td_ucred, PRISON_ROOT))) - return (error); - de->de_mtime = vap->va_mtime; + if (vap->va_atime.tv_sec != VNOVAL) { + if (vp->v_type == VCHR) + vp->v_rdev->si_atime = vap->va_atime; + else + de->de_atime = vap->va_atime; + } + if (vap->va_mtime.tv_sec != VNOVAL) { + if (vp->v_type == VCHR) + vp->v_rdev->si_mtime = vap->va_mtime; + else + de->de_mtime = vap->va_mtime; + } c = 1; } - if (c) - vfs_timestamp(&de->de_ctime); + if (c) { + if (vp->v_type == VCHR) + vfs_timestamp(&vp->v_rdev->si_ctime); + else + vfs_timestamp(&de->de_mtime); + } return (0); }