1 // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
3 // SPDX-License-Identifier: BSD-2-Clause
5 #include <common/errno.h>
13 int linkat(int fd1
, const char *path1
, int fd2
, const char *path2
, int flag
) {
14 // Create lookup properties.
15 #ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
16 __wasi_lookup_t lookup1
= {.fd
= fd1
, .flags
= 0};
18 __wasi_lookupflags_t lookup1_flags
= 0;
20 if ((flag
& AT_SYMLINK_FOLLOW
) != 0)
21 #ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
22 lookup1
.flags
|= __WASI_LOOKUP_SYMLINK_FOLLOW
;
24 lookup1_flags
|= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW
;
27 // Perform system call.
28 #ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
29 __wasi_errno_t error
= __wasi_file_link(lookup1
, path1
, strlen(path1
),
31 __wasi_errno_t error
= __wasi_path_link(fd1
, lookup1_flags
, path1
, strlen(path1
),
33 fd2
, path2
, strlen(path2
));
35 errno
= errno_fixup_directory(fd1
, errno_fixup_directory(fd2
, error
));