]> git.proxmox.com Git - wasi-libc.git/blob - libc-bottom-half/cloudlibc/src/libc/unistd/readlinkat.c
Update README and add CI-tests for minimal supported LLVM-version (10) (#302)
[wasi-libc.git] / libc-bottom-half / cloudlibc / src / libc / unistd / readlinkat.c
1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
2 //
3 // SPDX-License-Identifier: BSD-2-Clause
4
5 #include <common/errno.h>
6
7 #include <wasi/api.h>
8 #include <errno.h>
9 #include <string.h>
10 #include <unistd.h>
11
12 ssize_t __wasilibc_nocwd_readlinkat(int fd, const char *restrict path, char *restrict buf,
13 size_t bufsize) {
14 size_t bufused;
15 // TODO: Remove the cast on `buf` once the witx is updated with char8 support.
16 __wasi_errno_t error = __wasi_path_readlink(fd, path,
17 (uint8_t*)buf, bufsize, &bufused);
18 if (error != 0) {
19 errno = errno_fixup_directory(fd, error);
20 return -1;
21 }
22 return bufused;
23 }