]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/sys/stat/futimens.c
Remove __wasilibc_unmodified_upstream markers from libc-bottom-half.
[wasi-libc.git] / libc-bottom-half / cloudlibc / src / libc / sys / stat / futimens.c
1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
2 //
3 // SPDX-License-Identifier: BSD-2-Clause
4
5 #include <sys/stat.h>
6
7 #include <wasi/api.h>
8 #include <errno.h>
9
10 #include "stat_impl.h"
11
12 int futimens(int fd, const struct timespec *times) {
13 // Convert timestamps and extract NOW/OMIT flags.
14 __wasi_timestamp_t st_atim;
15 __wasi_timestamp_t st_mtim;
16 __wasi_fstflags_t flags;
17 if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) {
18 errno = EINVAL;
19 return -1;
20 }
21
22 // Perform system call.
23 __wasi_errno_t error = __wasi_fd_filestat_set_times(fd, st_atim, st_mtim, flags);
24 if (error != 0) {
25 errno = error;
26 return -1;
27 }
28 return 0;
29 }