From fcffe19529007d065b0b729d12c7941f7a4112c6 Mon Sep 17 00:00:00 2001 From: yxliang01 <13267.okk@gmail.com> Date: Sun, 29 Apr 2018 05:51:35 -0700 Subject: Fixed utimes() behavior for symbolic files when the second argument is NULL --- runtime/POSIX/fd.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'runtime') diff --git a/runtime/POSIX/fd.c b/runtime/POSIX/fd.c index e0e87604..84d0bdc5 100644 --- a/runtime/POSIX/fd.c +++ b/runtime/POSIX/fd.c @@ -28,6 +28,7 @@ #include #include #include +#include /* Returns pointer to the symbolic file structure fs the pathname is symbolic */ static exe_disk_file_t *__get_sym_file(const char *pathname) { @@ -246,6 +247,14 @@ int utimes(const char *path, const struct timeval times[2]) { exe_disk_file_t *dfile = __get_sym_file(path); if (dfile) { + + if (!times) { + struct timeval newTimes[2]; + gettimeofday(&(newTimes[0]), NULL); + newTimes[1] = newTimes[0]; + times = newTimes; + } + /* don't bother with usecs */ dfile->stat->st_atime = times[0].tv_sec; dfile->stat->st_mtime = times[1].tv_sec; -- cgit 1.4.1