summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c')
-rw-r--r--libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c b/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
new file mode 100644
index 0000000..d57f562
--- /dev/null
+++ b/libc-bottom-half/cloudlibc/src/libc/unistd/linkat.c
@@ -0,0 +1,24 @@
+// Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
+//
+// SPDX-License-Identifier: BSD-2-Clause
+
+#include <wasi/api.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+int __wasilibc_nocwd_linkat(int fd1, const char *path1, int fd2, const char *path2, int flag) {
+ // Create lookup properties.
+ __wasi_lookupflags_t lookup1_flags = 0;
+ if ((flag & AT_SYMLINK_FOLLOW) != 0)
+ lookup1_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW;
+
+ // Perform system call.
+ __wasi_errno_t error = __wasi_path_link(fd1, lookup1_flags, path1, fd2, path2);
+ if (error != 0) {
+ errno = error;
+ return -1;
+ }
+ return 0;
+}