touch: fix atime set from reference file
When using a file's times as reference, use both atime and mtime for the files to be modified. Signed-off-by: Xabier Oneca <xoneca@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
520bb3eac2
commit
de1a49cb41
@ -147,7 +147,8 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (reference_file) {
|
if (reference_file) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
xstat(reference_file, &stbuf);
|
xstat(reference_file, &stbuf);
|
||||||
timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime;
|
timebuf[0].tv_sec = stbuf.st_atime;
|
||||||
|
timebuf[1].tv_sec = stbuf.st_mtime;
|
||||||
/* Can use .st_mtim.tv_nsec
|
/* Can use .st_mtim.tv_nsec
|
||||||
* (or is it .st_mtimensec?? see date.c)
|
* (or is it .st_mtimensec?? see date.c)
|
||||||
* to set microseconds too.
|
* to set microseconds too.
|
||||||
|
Loading…
Reference in New Issue
Block a user