diff options
author | bde <bde@FreeBSD.org> | 2002-04-05 15:16:08 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2002-04-05 15:16:08 +0000 |
commit | b20f428bf36ab0b3fddb4733759e212248a8daf3 (patch) | |
tree | 04c390415e897eba82d3a22ec11353ab066996de /sys/fs/devfs | |
parent | 8e0b36fd312ffc9761418e00078f3ec47dac8cb3 (diff) | |
download | FreeBSD-src-b20f428bf36ab0b3fddb4733759e212248a8daf3.zip FreeBSD-src-b20f428bf36ab0b3fddb4733759e212248a8daf3.tar.gz |
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.
Diffstat (limited to 'sys/fs/devfs')
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index c0a8098..d5bd3ea 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))) - 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))) + + 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_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); } |