[PATCH v2] touch: switch to using utimensat() and futimens()
Xabier Oneca -- xOneca
xoneca at gmail.com
Tue Apr 13 21:08:30 UTC 2021
Hi Denys,
> Applied, thank you
You over-shrunk the code and omitted what seems to be a fundamental
part of the logic of the applet. Now 'touch -am file' does not update
times.
Here's the merged hunk where the bug is:
- if ((opts & (OPT_a | OPT_m)) && !newtime) {
- time(&timebuf[0].tv_sec);
- timebuf[1].tv_sec = timebuf[0].tv_sec;
- newtime = timebuf;
+ if (opts & OPT_a) {
+ timebuf[1].tv_nsec = UTIME_OMIT;
+ }
+ if (opts & OPT_m) {
+ timebuf[0].tv_nsec = UTIME_OMIT;
}
>From https://pubs.opengroup.org/onlinepubs/007904975/utilities/touch.html:
-a Change the access time of file. Do not change the modification
time unless -m is also specified.
-m Change the modification time of file. Do not change the access
time unless -a is also specified.
Cheers,
Xabier Oneca_,,_
More information about the busybox
mailing list