#define _ALL_SOURCE
#include <sys/stat.h>
+#include <utime.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
return -1;
}
- return fstatat(dirfd, relative_path, st, AT_SYMLINK_NOFOLLOW);
+ return fstatat(dirfd, relative_path, st, 0);
+}
+
+int
+utime(const char *path, const struct utimbuf *times)
+{
+ const char *relative_path;
+ int fd = __wasilibc_find_relpath(path, &relative_path);
+
+ // If we can't find a preopened directory handle to open this file with,
+ // indicate that the program lacks the capabilities.
+ if (fd == -1) {
+ errno = ENOTCAPABLE;
+ return -1;
+ }
+ return utimensat(fd, relative_path, times ? ((struct timespec [2]){
+ { .tv_sec = times->actime }, { .tv_sec = times->modtime }})
+ : 0, 0);
}
int