Skip to content

Commit 197d922

Browse files
committed
WASI: define AT_FDCWD and update to latest WASI libc
Update to the latest WASI libc, define `AT_FDCWD`, update the signature for __wasilibc_find_relpath, and add declarations for various `__wasilibc_` utility functions.
1 parent f9562dd commit 197d922

File tree

3 files changed

+112
-3
lines changed

3 files changed

+112
-3
lines changed

ci/docker/wasm32-wasi/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ RUN apt-get update && \
1414
# verification for now. The sysroot is currently in somewhat of a state of flux
1515
# and is expected to have breaking changes, so this is an attempt to mitigate
1616
# those breaking changes on `libc`'s own CI
17-
RUN git clone https://github.com/CraneStation/wasi-libc && \
17+
RUN git clone https://github.com/WebAssembly/wasi-libc && \
1818
cd wasi-libc && \
19-
git reset --hard f645f498dfbbbc00a7a97874d33082d3605c3f21
19+
git reset --hard f2e779e5f1ba4a539937cedeeaa762c1e0c162df
2020
RUN apt-get install -y --no-install-recommends llvm
2121
RUN make -C wasi-libc install -j $(nproc) INSTALL_DIR=/wasi-libc
2222

libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,7 @@ fn test_wasi(target: &str) {
12721272
"wasi/api.h",
12731273
"wasi/libc.h",
12741274
"wasi/libc-find-relpath.h",
1275+
"wasi/libc-nocwd.h",
12751276
"wchar.h",
12761277
}
12771278

src/wasi.rs

+109-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ pub const POSIX_FADV_NORMAL: c_int = 0;
210210
pub const POSIX_FADV_RANDOM: c_int = 2;
211211
pub const POSIX_FADV_SEQUENTIAL: c_int = 1;
212212
pub const POSIX_FADV_WILLNEED: c_int = 3;
213+
pub const AT_FDCWD: ::c_int = -2;
213214
pub const AT_EACCESS: c_int = 0x0;
214215
pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1;
215216
pub const AT_SYMLINK_FOLLOW: c_int = 0x2;
@@ -775,9 +776,116 @@ extern "C" {
775776
pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int;
776777
pub fn __wasilibc_find_relpath(
777778
path: *const c_char,
778-
relative_path: *mut *const c_char,
779+
abs_prefix: *mut *const c_char,
780+
relative_path: *mut *mut c_char,
781+
relative_path_len: usize,
779782
) -> c_int;
780783
pub fn __wasilibc_tell(fd: c_int) -> ::off_t;
784+
pub fn __wasilibc_nocwd___wasilibc_unlinkat(
785+
dirfd: c_int,
786+
path: *const c_char,
787+
) -> c_int;
788+
pub fn __wasilibc_nocwd___wasilibc_rmdirat(
789+
dirfd: c_int,
790+
path: *const c_char,
791+
) -> c_int;
792+
pub fn __wasilibc_nocwd_linkat(
793+
olddirfd: c_int,
794+
oldpath: *const c_char,
795+
newdirfd: c_int,
796+
newpath: *const c_char,
797+
flags: c_int,
798+
) -> c_int;
799+
pub fn __wasilibc_nocwd_symlinkat(
800+
target: *const c_char,
801+
dirfd: c_int,
802+
path: *const c_char,
803+
) -> c_int;
804+
pub fn __wasilibc_nocwd_readlinkat(
805+
dirfd: c_int,
806+
path: *const c_char,
807+
buf: *mut c_char,
808+
bufsize: usize,
809+
) -> isize;
810+
pub fn __wasilibc_nocwd_faccessat(
811+
dirfd: c_int,
812+
path: *const c_char,
813+
mode: c_int,
814+
flags: c_int,
815+
) -> c_int;
816+
pub fn __wasilibc_nocwd_renameat(
817+
olddirfd: c_int,
818+
oldpath: *const c_char,
819+
newdirfd: c_int,
820+
newpath: *const c_char,
821+
) -> c_int;
822+
pub fn __wasilibc_nocwd_openat_nomode(
823+
dirfd: c_int,
824+
path: *const c_char,
825+
flags: c_int,
826+
) -> c_int;
827+
pub fn __wasilibc_nocwd_fstatat(
828+
dirfd: c_int,
829+
path: *const c_char,
830+
buf: *mut stat,
831+
flags: c_int,
832+
) -> c_int;
833+
pub fn __wasilibc_nocwd_mkdirat_nomode(
834+
dirfd: c_int,
835+
path: *const c_char,
836+
) -> c_int;
837+
pub fn __wasilibc_nocwd_utimensat(
838+
dirfd: c_int,
839+
path: *const c_char,
840+
times: *const ::timespec,
841+
flags: c_int,
842+
) -> c_int;
843+
pub fn __wasilibc_nocwd_opendirat(
844+
dirfd: c_int,
845+
path: *const c_char,
846+
) -> *mut ::DIR;
847+
pub fn __wasilibc_access(
848+
pathname: *const c_char,
849+
mode: c_int,
850+
flags: c_int,
851+
) -> c_int;
852+
pub fn __wasilibc_stat(
853+
pathname: *const c_char,
854+
buf: *mut stat,
855+
flags: c_int,
856+
) -> c_int;
857+
pub fn __wasilibc_utimens(
858+
pathname: *const c_char,
859+
times: *const ::timespec,
860+
flags: c_int,
861+
) -> c_int;
862+
pub fn __wasilibc_link(
863+
oldpath: *const c_char,
864+
newpath: *const c_char,
865+
flags: c_int,
866+
) -> c_int;
867+
pub fn __wasilibc_link_oldat(
868+
olddirfd: c_int,
869+
oldpath: *const c_char,
870+
newpath: *const c_char,
871+
flags: c_int,
872+
) -> c_int;
873+
pub fn __wasilibc_link_newat(
874+
oldpath: *const c_char,
875+
newdirfd: c_int,
876+
newpath: *const c_char,
877+
flags: c_int,
878+
) -> c_int;
879+
pub fn __wasilibc_rename_oldat(
880+
olddirfd: c_int,
881+
oldpath: *const c_char,
882+
newpath: *const c_char,
883+
) -> c_int;
884+
pub fn __wasilibc_rename_newat(
885+
oldpath: *const c_char,
886+
newdirfd: c_int,
887+
newpath: *const c_char,
888+
) -> c_int;
781889

782890
pub fn arc4random() -> u32;
783891
pub fn arc4random_buf(a: *mut c_void, b: size_t);

0 commit comments

Comments
 (0)