mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-08-14 05:31:28 +00:00
Added utime.h (#188)
* Added utime.h * Changes after code review * Auto-generated expected files instead of manually editing * Fix libpreopoen stat and utime not following symlinks correctly
This commit is contained in:
parent
156fdc476a
commit
7b92f334e6
3
Makefile
3
Makefile
@ -316,8 +316,7 @@ MUSL_OMIT_HEADERS += \
|
||||
"netinet/ether.h" \
|
||||
"sys/timerfd.h" \
|
||||
"libintl.h" \
|
||||
"sys/sysmacros.h" \
|
||||
"utime.h"
|
||||
"sys/sysmacros.h"
|
||||
|
||||
ifeq ($(THREAD_MODEL), single)
|
||||
# Remove headers not supported in single-threaded mode.
|
||||
|
@ -1028,6 +1028,7 @@ unlinkat
|
||||
unsetenv
|
||||
uselocale
|
||||
usleep
|
||||
utime
|
||||
utimensat
|
||||
vasprintf
|
||||
vdprintf
|
||||
|
@ -164,6 +164,7 @@
|
||||
#include <time.h>
|
||||
#include <uchar.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <values.h>
|
||||
#include <wasi/api.h>
|
||||
#include <wasi/libc-environ.h>
|
||||
|
@ -2407,6 +2407,7 @@
|
||||
#define _TIME_H
|
||||
#define _UCHAR_H
|
||||
#define _UNISTD_H
|
||||
#define _UTIME_H
|
||||
#define _VALUES_H
|
||||
#define _VA_LIST
|
||||
#define _WCHAR_H
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
#define _ALL_SOURCE
|
||||
#include <sys/stat.h>
|
||||
#include <utime.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
@ -152,7 +153,24 @@ stat(const char *path, struct stat *st)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user