From owner-freebsd-current Wed Oct 16 10:01:21 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id KAA15647 for current-outgoing; Wed, 16 Oct 1996 10:01:21 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id KAA15635 for ; Wed, 16 Oct 1996 10:01:11 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.7.6/8.6.9) id CAA25825; Thu, 17 Oct 1996 02:59:26 +1000 Date: Thu, 17 Oct 1996 02:59:26 +1000 From: Bruce Evans Message-Id: <199610161659.CAA25825@godzilla.zeta.org.au> To: current@FreeBSD.org, james@miller.cs.uwm.edu Subject: Re: Devfs update time Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk >When using the devfs filesystem, the times for the inode don't >get updated. I beleive atime, ctime, and mtime need to be >enabled for things in the devfs. > >The following example illustrates the problem: > % touch `tty` > touch: /dev/ttyp0: Inappropriate file type or format There are several problems: utimes() (which is used by `touch') doesn't work, i/o timestamps don't work, and inode change timestamps (e.g. for link and unlink) don't work. The enclosed patch is supposed to fix utimes(). The utimes(path, NULL) case is broken by an earlier check for (cred->cr_uid != file_node->uid). Write permission is supposed to be sufficient in this case. Hmm, the suser() check seems to be too early here, as it is in ufs where this patch was mostly copied from. I think the VA_UTIMES_NULL check should be before the suser() check. Bruce diff -c2 devfs_vnops.c~ devfs_vnops.c *** devfs_vnops.c~ Sun Oct 13 04:40:25 1996 --- devfs_vnops.c Sun Oct 13 04:41:45 1996 *************** *** 603,606 **** --- 600,604 ---- int error = 0; dn_p file_node; + struct timeval tv; if (error = devfs_vntodn(vp,&file_node)) *************** *** 617,622 **** (vap->va_rdev != VNOVAL) || (vap->va_bytes != VNOVAL) || ! (vap->va_gen != VNOVAL) || ! (vap->va_atime.tv_sec != VNOVAL)) { return EINVAL; --- 615,619 ---- (vap->va_rdev != VNOVAL) || (vap->va_bytes != VNOVAL) || ! (vap->va_gen != VNOVAL)) { return EINVAL; *************** *** 632,648 **** return error; /*XXX (?) */ } - if (vap->va_atime.tv_sec != VNOVAL) - { - file_node->atime = vap->va_atime; - } ! if (vap->va_mtime.tv_sec != VNOVAL) ! { file_node->mtime = vap->va_mtime; ! } ! ! if (vap->va_ctime.tv_sec != VNOVAL) ! { ! file_node->ctime = vap->va_ctime; } --- 629,646 ---- return error; /*XXX (?) */ } ! if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { ! if (vp->v_mount->mnt_flag & MNT_RDONLY) ! return (EROFS); ! if (cred->cr_uid != file_node->uid && ! (error = suser(cred, &p->p_acflag)) && ! ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || ! (error = VOP_ACCESS(vp, VWRITE, cred, p)))) ! return (error); ! file_node->atime = vap->va_atime; file_node->mtime = vap->va_mtime; ! microtime(&tv); ! TIMEVAL_TO_TIMESPEC(&tv, &file_node->ctime); ! return (0); }