8000 add stubs for `statvfs`, `chmod`, etc. (#463) · WebAssembly/wasi-libc@cc62fa8 · GitHub
[go: up one dir, main page]

Skip to content

Commit cc62fa8

Browse files
authored
add stubs for statvfs, chmod, etc. (#463)
Per WebAssembly/wasi-sdk#373, LLVM's libc++ no longer allows us to enable `<fstream>` and `<filesystem>` separately -- it's both or neither. Consequently, we either need to patch libc++ to not use `statvfs`, `chmod`, etc. or add stub functions for those features to `wasi-libc`. Since we're planning to eventually support those features with WASI Preview 2 and beyond, it makes sense to do the latter. Note that since libc++ uses `DT_SOCK`, I've added a definition for it -- even though WASI Preview 1 does not define it. No Preview 1 file will ever have that type, so code that handles that type will never be reached, but defining it allows us to avoid WASI-specific patches to libc++. Related to `DT_SOCK`, I had to change the `S_IFIFO` value so it does not conflict with `S_IFSOCK`, thereby avoiding ambiguity in `__wasilibc_iftodt`. Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 47b9db6 commit cc62fa8

File tree

15 files changed

+120
-11
lines changed

15 files changed

+120
-11
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ MUSL_OMIT_HEADERS += \
446446
"bits/shm.h" "bits/msg.h" "bits/ipc.h" "bits/ptrace.h" \
447447
"bits/statfs.h" \
448448
"sys/vfs.h" \
449-
"sys/statvfs.h" \
450449
"syslog.h" "sys/syslog.h" \
451450
"wait.h" "sys/wait.h" \
452451
"ucontext.h" "sys/ucontext.h" \

expected/wasm32-wasi-preview2/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ cexp
449449
cexpf
450450
cexpl
451451
chdir
452+
chmod
452453
cimag
453454
cimagf
454455
cimagl
@@ -550,6 +551,8 @@ fabs
550551
fabsf
551552
fabsl
552553
faccessat
554+
fchmod
555+
fchmodat
553556
fclose
554557
fcntl
555558
fcvt
@@ -701,6 +704,7 @@ fsetpos
701704
fsetpos64
702705
fstat
703706
fstatat
707+
fstatvfs
704708
fsync
705709
ftell
706710
ftello
@@ -1121,6 +1125,7 @@ srand48
11211125
srandom
11221126
sscanf
11231127
stat
1128+
statvfs
11241129
stderr
11251130
stderr_get_stderr
11261131
stdin

expected/wasm32-wasi-preview2/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#include <sys/select.h>
142142
#include <sys/socket.h>
143143
#include <sys/stat.h>
144+
#include <sys/statvfs.h>
144145
#include <sys/stropts.h>
145146
#include <sys/syscall.h>
146147
#include <sys/sysinfo.h>

expected/wasm32-wasi-preview2/predefined-macros.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
182182
#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
183183
#define DT_REG __WASI_FILETYPE_REGULAR_FILE
184+
#define DT_SOCK 20
184185
#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
185186
#define D_FMT 0x20029
186187
#define D_T_FMT 0x20028
@@ -1731,6 +1732,18 @@
17311732
#define STRU_F 1
17321733
#define STRU_P 3
17331734
#define STRU_R 2
1735+
#define ST_APPEND 256
1736+
#define ST_IMMUTABLE 512
1737+
#define ST_MANDLOCK 64
1738+
#define ST_NOATIME 1024
1739+
#define ST_NODEV 4
1740+
#define ST_NODIRATIME 2048
1741+
#define ST_NOEXEC 8
1742+
#define ST_NOSUID 2
1743+
#define ST_RDONLY 1
1744+
#define ST_RELATIME 4096
1745+
#define ST_SYNCHRONOUS 16
1746+
#define ST_WRITE 128
17341747
#define SUN_LEN(s) (2+strlen((s)->sun_path))
17351748
#define SUSP 237
17361749
#define SYMLOOP_MAX 40
@@ -1745,7 +1758,7 @@
17451758
#define S_IFBLK (0x6000)
17461759
#define S_IFCHR (0x2000)
17471760
#define S_IFDIR (0x4000)
1748-
#define S_IFIFO (0xc000)
1761+
#define S_IFIFO (0x1000)
17491762
#define S_IFLNK (0xa000)
17501763
#define S_IFMT (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
17511764
#define S_IFREG (0x8000)
@@ -2420,6 +2433,7 @@
24202433
#define _SYS_REG_H
24212434
#define _SYS_SELECT_H
24222435
#define _SYS_SOCKET_H
2436+
#define _SYS_STATVFS_H
24232437
#define _SYS_STAT_H
24242438
#define _SYS_SYSCALL_H
24252439
#define _SYS_SYSINFO_H
@@ -3244,6 +3258,7 @@
32443258
#define fsfilcnt64_t fsfilcnt_t
32453259
#define fstat64 fstat
32463260
#define fstatat64 fstatat
3261+
#define fstatvfs64 fstatvfs
32473262
#define ftello64 ftello
32483263
#define ftruncate64 ftruncate
32493264
#define getdents64 getdents
@@ -3427,6 +3442,7 @@
34273442
#define st_mtime st_mtim.tv_sec
34283443
#define stat64 stat
34293444
#define static_assert _Static_assert
3445+
#define statvfs64 statvfs
34303446
#define stderr (stderr)
34313447
#define stdin (stdin)
34323448
#define stdout (stdout)

expected/wasm32-wasi-threads/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ cexp
511511
cexpf
512512
cexpl
513513
chdir
514+
chmod
514515
cimag
515516
cimagf
516517
cimagl
@@ -607,6 +608,8 @@ fabs
607608
fabsf
608609
fabsl
609610
faccessat
611+
fchmod
612+
fchmodat
610613
fclose
611614
fcntl
612615
fcvt
@@ -702,6 +705,7 @@ fsetpos
702705
fsetpos64
703706
fstat
704707
fstatat
708+
fstatvfs
705709
fsync
706710
ftell
707711
ftello
@@ -1162,6 +1166,7 @@ srand48
11621166
srandom
11631167
sscanf
11641168
stat
1169+
statvfs
11651170
stderr
11661171
stdin
11671172
stdout

expected/wasm32-wasi-threads/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
#include <sys/select.h>
143143
#include <sys/socket.h>
144144
#include <sys/stat.h>
145+
#include <sys/statvfs.h>
145146
#include <sys/stropts.h>
146147
#include <sys/syscall.h>
147148
#include <sys/sysinfo.h>

expected/wasm32-wasi-threads/predefined-macros.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
182182
#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
183183
#define DT_REG __WASI_FILETYPE_REGULAR_FILE
184+
#define DT_SOCK 20
184185
#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
185186
#define D_FMT 0x20029
186187
#define D_T_FMT 0x20028
@@ -1671,6 +1672,18 @@
16711672
#define STRU_F 1
16721673
#define STRU_P 3
16731674
#define STRU_R 2
1675+
#define ST_APPEND 256
1676+
#define ST_IMMUTABLE 512
1677+
#define ST_MANDLOCK 64
1678+
#define ST_NOATIME 1024
1679+
#define ST_NODEV 4
1680+
#define ST_NODIRATIME 2048
1681+
#define ST_NOEXEC 8
1682+
#define ST_NOSUID 2
1683+
#define ST_RDONLY 1
1684+
#define ST_RELATIME 4096
1685+
#define ST_SYNCHRONOUS 16
1686+
#define ST_WRITE 128
16741687
#define SUN_LEN(s) (2+strlen((s)->sun_path))
16751688
#define SUSP 237
16761689
#define SYMLOOP_MAX 40
@@ -1685,7 +1698,7 @@
16851698
#define S_IFBLK (0x6000)
16861699
#define S_IFCHR (0x2000)
16871700
#define S_IFDIR (0x4000)
1688-
#define S_IFIFO (0xc000)
1701+
#define S_IFIFO (0x1000)
16891702
#define S_IFLNK (0xa000)
16901703
#define S_IFMT (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
16911704
#define S_IFREG (0x8000)
@@ -2052,7 +2065,7 @@
20522065
#define _Complex_I (0.0f+1.0fi)
20532066
#define _DIRENT_H
20542067
#define _DIRENT_HAVE_D_TYPE
2055-
#define _DLFCN_H
2068+
#define _DLFCN_H
20562069
#define _ENDIAN_H
20572070
#define _ERRNO_H
20582071
#define _ERR_H
@@ -2360,6 +2373,7 @@
23602373
#define _SYS_REG_H
23612374
#define _SYS_SELECT_H
23622375
#define _SYS_SOCKET_H
2376+
#define _SYS_STATVFS_H
23632377
#define _SYS_STAT_H
23642378
#define _SYS_SYSCALL_H
23652379
#define _SYS_SYSINFO_H
@@ -3185,6 +3199,7 @@
31853199
#define fsfilcnt64_t fsfilcnt_t
31863200
#define fstat64 fstat
31873201
#define fstatat64 fstatat
3202+
#define fstatvfs64 fstatvfs
31883203
#define ftello64 ftello
31893204
#define ftruncate64 ftruncate
31903205
#define getdents64 getdents
@@ -3371,6 +3386,7 @@
33713386
#define st_mtime st_mtim.tv_sec
33723387
#define stat64 stat
33733388
#define static_assert _Static_assert
3389+
#define statvfs64 statvfs
33743390
#define stderr (stderr)
33753391
#define stdin (stdin)
33763392
#define stdout (stdout)

expected/wasm32-wasi/defined-symbols.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ cexp
447447
cexpf
448448
cexpl
449449
chdir
450+
chmod
450451
cimag
451452
cimagf
452453
cimagl
@@ -543,6 +544,8 @@ fabs
543544
fabsf
544545
fabsl
545546
faccessat
547+
fchmod
548+
fchmodat
546549
fclose
547550
fcntl
548551
fcvt
@@ -637,6 +640,7 @@ fsetpos
637640
fsetpos64
638641
fstat
639642
fstatat
643+
fstatvfs
640644
fsync
641645
ftell
642646
ftello
@@ -1012,6 +1016,7 @@ srand48
10121016
srandom
10131017
sscanf
10141018
stat
1019+
statvfs
10151020
stderr
10161021
stdin
10171022
stdout

expected/wasm32-wasi/include-all.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#include <sys/select.h>
142142
#include <sys/socket.h>
143143
#include <sys/stat.h>
144+
#include <sys/statvfs.h>
144145
#include <sys/stropts.h>
145146
#include <sys/syscall.h>
146147
#include <sys/sysinfo.h>

expected/wasm32-wasi/predefined-macros.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
182182
#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
183183
#define DT_REG __WASI_FILETYPE_REGULAR_FILE
184+
#define DT_SOCK 20
184185
#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
185186
#define D_FMT 0x20029
186187
#define D_T_FMT 0x20028
@@ -1637,6 +1638,18 @@
16371638
#define STRU_F 1
16381639
#define STRU_P 3
16391640
#define STRU_R 2
1641+
#define ST_APPEND 256
1642+
#define ST_IMMUTABLE 512
1643+
#define ST_MANDLOCK 64
1644+
#define ST_NOATIME 1024
1645+
#define ST_NODEV 4
1646+
#define ST_NODIRATIME 2048
1647+
#define ST_NOEXEC 8
1648+
#define ST_NOSUID 2
1649+
#define ST_RDONLY 1
1650+
#define ST_RELATIME 4096
1651+
#define ST_SYNCHRONOUS 16
1652+
#define ST_WRITE 128
16401653
#define SUN_LEN(s) (2+strlen((s)->sun_path))
16411654
#define SUSP 237
16421655
#define SYMLOOP_MAX 40
@@ -1651,7 +1664,7 @@
16511664
#define S_IFBLK (0x6000)
16521665
#define S_IFCHR (0x2000)
16531666
#define S_IFDIR (0x4000)
1654-
#define S_IFIFO (0xc000)
1667+
#define S_IFIFO (0x1000)
16551668
#define S_IFLNK (0xa000)
16561669
#define S_IFMT (S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK)
16571670
#define S_IFREG (0x8000)
@@ -2018,7 +2031,7 @@
20182031
#define _Complex_I (0.0f+1.0fi)
20192032
#define _DIRENT_H
20202033
#define _DIRENT_HAVE_D_TYPE
2021-
#define _DLFCN_H
2034+
#define _DLFCN_H
20222035
#define _ENDIAN_H
20232036
#define _ERRNO_H
20242037
#define _ERR_H
@@ -2323,6 +2336,7 @@
23232336
#define _SYS_REG_H
23242337
#define _SYS_SELECT_H
23252338
#define _SYS_SOCKET_H
2339+
#define _SYS_STATVFS_H
23262340
#define _SYS_STAT_H
23272341
#define _SYS_SYSCALL_H
23282342
#define _SYS_SYSINFO_H
@@ -3146,6 +3160,7 @@
31463160
#define fsfilcnt64_t fsfilcnt_t
31473161
#define fstat64 fstat
31483162
#define fstatat64 fstatat
3163+
#define fstatvfs64 fstatvfs
31493164
#define ftello64 ftello
31503165
#define ftruncate64 ftruncate
31513166
#define getdents64 getdents
@@ -3329,6 +3344,7 @@
33293344
#define st_mtime st_mtim.tv_sec
33303345
#define stat64 stat
33313346
#define static_assert _Static_assert
3347+
#define statvfs64 statvfs
33323348
#define stderr (stderr)
33333349
#define stdin (stdin)
33343350
#define stdout (stdout)

0 commit comments

Comments
 (0)
0