diff options
author | Benjamin Gwin <bgwin@google.com> | 2021-12-09 16:42:36 -0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2021-12-27 00:00:46 +0100 |
commit | a13b588a915d3a4498bf342d85524eb7dde71594 (patch) | |
tree | d0b2dd722c8ebbfa184ca8d176beceb52cb7fb1b | |
parent | 12db27ba0db4fabe1230d1d9b8be56453991e6a9 (diff) | |
download | klibc-a13b588a915d3a4498bf342d85524eb7dde71594.tar.gz |
[klibc] Fix implementation of utimes
This was not correctly initializing the timespec array before passing it
on to utimensat.
Tested: Built cpio and extracted an image with `cpio -im` to preserve
mtime. The calls to utime now pass through the correct timestamps.
Signed-off-by: Benjamin Gwin <bgwin@google.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r-- | usr/klibc/utimes.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr/klibc/utimes.c b/usr/klibc/utimes.c index fd378a635dc64f..ce6d2f811a5421 100644 --- a/usr/klibc/utimes.c +++ b/usr/klibc/utimes.c @@ -10,8 +10,10 @@ int utimes(const char *file, const struct timeval tvp[2]) struct timespec ts[2]; if (tvp) { - ts->tv_sec = tvp->tv_sec; - ts->tv_nsec = tvp->tv_usec * 1000; + ts[0].tv_sec = tvp[0].tv_sec; + ts[0].tv_nsec = tvp[0].tv_usec * 1000; + ts[1].tv_sec = tvp[1].tv_sec; + ts[1].tv_nsec = tvp[1].tv_usec * 1000; } return utimensat(AT_FDCWD, file, &ts[0], 0); |