On Mon, 2011-11-14 at 08:39 -0500, Eli Zaretskii wrote:
> > Date: Mon, 14 Nov 2011 07:25:47 -0500
> > From: David Boyce <[email protected]>
> > Cc: "[email protected]" <[email protected]>
> >
> > On a side note, I've often wondered why, after all these years and
> > discussions like this one, nobody's modified at least the GNU version
> > of touch to do its work by opening the file for write and writing 0
> > bytes to it, or appending one byte and then removing it, or whatever
> > it takes to force an mtime update, rather than using the flawed utimes
> > syscall.
I think any change like this would be too much of a change in behavior.
The timestamp on a file is a feature of the directory, not the file
itself (at least in POSIX). In particular this means that you CAN touch
a read-only file and change its mod time:
~$ ls -al foo
-r--r--r-- 1 psmith psmith 0 Sep 7 23:59 foo
~$ touch foo
~$ ls -al foo
-r--r--r-- 1 psmith psmith 0 Nov 14 09:18 foo
But you can't even open a read-only file for writing, much less actually
write to it. Also, writing 0 bytes to a file does not (at least in my
experiment) change its modtime.
> Did you miss this portion of Coreutils' NEWS?
>
> * Noteworthy changes in release 6.12 (2008-05-31) [stable]
>
> ** New features
>
> cp, install, mv, and touch now preserve nanosecond resolution on
> file timestamps, on platforms that have the 'utimensat' and
> 'futimens' system calls.
Yes, this actually works, too:
~$ touch --version
touch (GNU coreutils) 8.5
~$ ls -l --full-time foo
-rw-r--r-- 1 psmith psmith 0 2011-11-14 09:18:16.937969078 -0500 foo
~$ touch foo
~$ ls -l --full-time foo
-rw-r--r-- 1 psmith psmith 0 2011-11-14 09:23:59.807379653 -0500 foo
--
-------------------------------------------------------------------------------
Paul D. Smith <[email protected]> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make