@@ -33,7 +33,9 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
3333 // Compute rights corresponding with the access modes provided.
3434 // Attempt to obtain all rights, except the ones that contradict the
3535 // access mode provided to openat().
36+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
3637 __wasi_rights_t min = 0 ;
38+ #endif
3739 __wasi_rights_t max =
3840 ~(__WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_READ |
3941#ifdef __wasilibc_unmodified_upstream // fstat
@@ -53,21 +55,23 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
5355 case O_RDWR :
5456 case O_WRONLY :
5557 if ((oflag & O_RDONLY ) != 0 ) {
56- #ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
58+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
5759 min |= (oflag & O_DIRECTORY ) == 0 ? __WASI_RIGHT_FD_READ
5860 : __WASI_RIGHT_FILE_READDIR ;
61+ #endif
62+ #ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
5963 max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR |
6064 __WASI_RIGHT_MEM_MAP_EXEC ;
6165#else
62- min |= (oflag & O_DIRECTORY ) == 0 ? __WASI_RIGHT_FD_READ
63- : __WASI_RIGHT_FD_READDIR ;
6466 max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_READDIR ;
6567#endif
6668 }
6769 if ((oflag & O_WRONLY ) != 0 ) {
70+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
6871 min |= __WASI_RIGHT_FD_WRITE ;
6972 if ((oflag & O_APPEND ) == 0 )
7073 min |= __WASI_RIGHT_FD_SEEK ;
74+ #endif
7175 max |= __WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_WRITE |
7276#ifdef __wasilibc_unmodified_upstream // fstat
7377 __WASI_RIGHT_FILE_ALLOCATE |
@@ -89,8 +93,10 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
8993 errno = EINVAL ;
9094 return -1 ;
9195 }
96+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
9297 assert ((min & max ) == min &&
9398 "Minimal rights should be a subset of the maximum" );
99+ #endif
94100
95101 // Ensure that we can actually obtain the minimal rights needed.
96102 __wasi_fdstat_t fsb_cur ;
@@ -103,6 +109,7 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
103109 errno = error ;
104110 return -1 ;
105111 }
112+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
106113 if (fsb_cur .fs_filetype != __WASI_FILETYPE_DIRECTORY ) {
107114 errno = ENOTDIR ;
108115 return -1 ;
@@ -111,6 +118,7 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
111118 errno = ENOTCAPABLE ;
112119 return -1 ;
113120 }
121+ #endif
114122
115123 // Path lookup properties.
116124#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
0 commit comments