bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: touch command


From: Bob Proulx
Subject: Re: touch command
Date: Mon, 27 Aug 2007 18:55:59 -0600
User-agent: Mutt/1.5.9i

address@hidden wrote:
>  I am not really sure if it is a bug, but the line command
>  "touch" seems incapable of changing the timestamp of a
>  link (on a related issue, "tar" does not usually recover
>  the timestamp of links).

Thanks for the report but as it turns out this is not a bug but simply
a non-feature of current unix-like kernels.  There is no system call
available to change the timestamp of a symlink.  If there were then
touch could be written to use it but since it does not exist there is
no way for touch to do this.  Fortunately the timestamp on symlinks is
mostly cosmetic.  The feature is not really needed.

By default the touch command operates as if the file were written to
by the user.  When a user touch's a file it is the same as if the file
were at that moment written to by the user.  Writing to the file
pushes through the symlink and affects the real underlying file.

>  For example, the command "chown" has an option "-h"
>  specially designed for links.

The old V7 touch command would read and write the first byte of the
file and by writing the file update the timestamp.  The current touch
command uses the kernel utimes(2) system call to set the times on the
argument to the user specified timestamp.  The utimes(2) call follows
symlinks.

There is no lutimes(2) call and therefore way way to set the times on
a symlink.  This is why touch does not have a -h option.  Since
lchmod(2) is available the chmod command has a -h option and uses it
to change the owner of the symlink.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]