1
1
diff --git a/system/lib/standalone/standalone.c b/system/lib/standalone/standalone.c
2
- index 200002dce..bbaf32d7d 100644
2
+ index 200002dce..5624c926f 100644
3
3
--- a/system/lib/standalone/standalone.c
4
4
+++ b/system/lib/standalone/standalone.c
5
5
@@ -6,6 +6,7 @@
@@ -38,7 +38,7 @@ index 200002dce..bbaf32d7d 100644
38
38
void abort() {
39
39
_Exit(1);
40
40
}
41
- @@ -85,41 +100,809 @@ __attribute__((__weak__)) int _munmap_js(
41
+ @@ -85,41 +100,867 @@ __attribute__((__weak__)) int _munmap_js(
42
42
return -ENOSYS;
43
43
}
44
44
@@ -520,31 +520,89 @@ index 200002dce..bbaf32d7d 100644
520
520
+ }
521
521
+
522
522
+ __attribute__((__weak__)) int __syscall_rmdir(intptr_t path) {
523
- + return -ENOSYS;
524
- + }
525
- +
523
+ return -ENOSYS;
524
+ }
525
+
526
+ - // There is no good source of entropy without an import. Make this weak so that
527
+ - // it can be replaced with a pRNG or a proper import.
526
528
+ __attribute__((__weak__)) int __syscall_unlinkat(int dirfd, intptr_t path, int flags) {
527
- + return -ENOSYS;
529
+ + const char* resolved_path = (const char*)path;
530
+ +
531
+ + // Resolve path if fd is AT_FDCWD.
532
+ + if (dirfd == AT_FDCWD) {
533
+ + char *relative_path;
534
+ + dirfd = find_relpath(resolved_path, &relative_path);
535
+ +
536
+ + // If we can't find a preopen for it, fail as if we can't find the path.
537
+ + if (dirfd == -1) {
538
+ + errno = ENOENT;
539
+ + return -1;
540
+ + }
541
+ +
542
+ + resolved_path = relative_path;
543
+ + }
544
+ +
545
+ + __wasi_errno_t error = __wasi_path_unlink_file(dirfd, resolved_path, strlen(resolved_path));
546
+ + if (error != 0) {
547
+ + errno = error;
548
+ + return -1;
549
+ + }
550
+ + return 0;
528
551
+ }
529
552
+
530
553
+ __attribute__((__weak__)) int __syscall_pipe(intptr_t fd) {
531
554
+ return -ENOSYS;
532
555
+ }
533
556
+
534
557
+ __attribute__((__weak__)) int __syscall_renameat(int olddirfd, intptr_t oldpath, int newdirfd, intptr_t newpath) {
535
- + return -ENOSYS;
558
+ + const char* oldpathresolved_path = (const char*)oldpath;
559
+ +
560
+ + // Resolve path if fd is AT_FDCWD.
561
+ + if (olddirfd == AT_FDCWD) {
562
+ + char *oldpathrelative_path;
563
+ + olddirfd = find_relpath(oldpathresolved_path, &oldpathrelative_path);
564
+ +
565
+ + // If we can't find a preopen for it, fail as if we can't find the path.
566
+ + if (olddirfd == -1) {
567
+ + errno = ENOENT;
568
+ + return -1;
569
+ + }
570
+ +
571
+ + oldpathresolved_path = oldpathrelative_path;
572
+ + }
573
+ +
574
+ + const char* newpathresolved_path = (const char*)newpath;
575
+ +
576
+ + // Resolve path if fd is AT_FDCWD.
577
+ + if (newdirfd == AT_FDCWD) {
578
+ + char *newpathrelative_path;
579
+ + newdirfd = find_relpath(newpathresolved_path, &newpathrelative_path);
580
+ +
581
+ + // If we can't find a preopen for it, fail as if we can't find the path.
582
+ + if (newdirfd == -1) {
583
+ + errno = ENOENT;
584
+ + return -1;
585
+ + }
586
+ +
587
+ + newpathresolved_path = newpathrelative_path;
588
+ + }
589
+ +
590
+ + __wasi_errno_t error = __wasi_path_rename(olddirfd, oldpathresolved_path, strlen(oldpathresolved_path), newdirfd, newpathresolved_path, strlen(newpathresolved_path));
591
+ + if (error != 0) {
592
+ + errno = error;
593
+ + return -1;
594
+ + }
595
+ + return 0;
536
596
+ }
537
597
+
538
598
+ __attribute__((__weak__)) int __syscall_dup(int fd) {
539
599
+ return -ENOSYS;
540
600
+ }
541
601
+
542
602
+ __attribute__((__weak__)) int __syscall_dup3(int fd, int suggestfd, int flags) {
543
- return -ENOSYS;
544
- }
545
-
546
- - // There is no good source of entropy without an import. Make this weak so that
547
- - // it can be replaced with a pRNG or a proper import.
603
+ + return -ENOSYS;
604
+ + }
605
+ +
548
606
+ __attribute__((__weak__)) int __syscall_faccessat(int dirfd, intptr_t path, int amode, int flags) {
549
607
+ return -ENOSYS;
550
608
+ }
@@ -859,7 +917,7 @@ index 200002dce..bbaf32d7d 100644
859
917
}
860
918
861
919
// Emscripten additions
862
- @@ -155,12 +938 ,24 @@ double emscripten_get_now(void) {
920
+ @@ -155,12 +996 ,24 @@ double emscripten_get_now(void) {
863
921
return (1000 * clock()) / (double)CLOCKS_PER_SEC;
864
922
}
865
923
@@ -885,7 +943,7 @@ index 200002dce..bbaf32d7d 100644
885
943
//
886
944
// Define these symbols as weak so that when we build with exceptions
887
945
// enabled (using wasm-eh) we get the real versions of these functions
888
- @@ -168,11 +963 ,7 @@ double emscripten_get_now(void) {
946
+ @@ -168,11 +1021 ,7 @@ double emscripten_get_now(void) {
889
947
890
948
__attribute__((__weak__))
891
949
void __cxa_throw(void* ptr, void* type, void* destructor) {
@@ -898,7 +956,7 @@ index 200002dce..bbaf32d7d 100644
898
956
abort();
899
957
}
900
958
901
- @@ -228,3 +1019 ,14 @@ void _emscripten_err(const char* text) { wasi_writeln(2, text); }
959
+ @@ -228,3 +1077 ,14 @@ void _emscripten_err(const char* text) { wasi_writeln(2, text); }
902
960
void __call_sighandler(sighandler_t handler, int sig) {
903
961
handler(sig);
904
962
}
0 commit comments