summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorXabier Oneca2021-04-08 02:05:37 +0200
committerDenys Vlasenko2021-04-12 20:05:48 +0200
commitde1a49cb419d931a62500eaddb7c888ee011eefe (patch)
tree3e016e5fd33cc29264da35cf2dd15d1e8cc27732 /coreutils
parent520bb3eac2627e2f6bda05ceb2e3e7db71b73dd3 (diff)
downloadbusybox-de1a49cb419d931a62500eaddb7c888ee011eefe.zip
busybox-de1a49cb419d931a62500eaddb7c888ee011eefe.tar.gz
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>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/touch.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/coreutils/touch.c b/coreutils/touch.c
index dff68cb..68fb625 100644
--- a/coreutils/touch.c
+++ b/coreutils/touch.c
@@ -147,7 +147,8 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
if (reference_file) {
struct stat 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
* (or is it .st_mtimensec?? see date.c)
* to set microseconds too.