@@ -33,7 +33,9 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
33
33
// Compute rights corresponding with the access modes provided.
34
34
// Attempt to obtain all rights, except the ones that contradict the
35
35
// access mode provided to openat().
36
+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
36
37
__wasi_rights_t min = 0 ;
38
+ #endif
37
39
__wasi_rights_t max =
38
40
~(__WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_READ |
39
41
#ifdef __wasilibc_unmodified_upstream // fstat
@@ -53,21 +55,23 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
53
55
case O_RDWR :
54
56
case O_WRONLY :
55
57
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.
57
59
min |= (oflag & O_DIRECTORY ) == 0 ? __WASI_RIGHT_FD_READ
58
60
: __WASI_RIGHT_FILE_READDIR ;
61
+ #endif
62
+ #ifdef __wasilibc_unmodified_upstream // RIGHT_MEM_MAP_EXEC
59
63
max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FILE_READDIR |
60
64
__WASI_RIGHT_MEM_MAP_EXEC ;
61
65
#else
62
- min |= (oflag & O_DIRECTORY ) == 0 ? __WASI_RIGHT_FD_READ
63
- : __WASI_RIGHT_FD_READDIR ;
64
66
max |= __WASI_RIGHT_FD_READ | __WASI_RIGHT_FD_READDIR ;
65
67
#endif
66
68
}
67
69
if ((oflag & O_WRONLY ) != 0 ) {
70
+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
68
71
min |= __WASI_RIGHT_FD_WRITE ;
69
72
if ((oflag & O_APPEND ) == 0 )
70
73
min |= __WASI_RIGHT_FD_SEEK ;
74
+ #endif
71
75
max |= __WASI_RIGHT_FD_DATASYNC | __WASI_RIGHT_FD_WRITE |
72
76
#ifdef __wasilibc_unmodified_upstream // fstat
73
77
__WASI_RIGHT_FILE_ALLOCATE |
@@ -89,8 +93,10 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
89
93
errno = EINVAL ;
90
94
return -1 ;
91
95
}
96
+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
92
97
assert ((min & max ) == min &&
93
98
"Minimal rights should be a subset of the maximum" );
99
+ #endif
94
100
95
101
// Ensure that we can actually obtain the minimal rights needed.
96
102
__wasi_fdstat_t fsb_cur ;
@@ -103,6 +109,7 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
103
109
errno = error ;
104
110
return -1 ;
105
111
}
112
+ #ifdef __wasilibc_unmodified_upstream // Let the WASI implementation check this instead.
106
113
if (fsb_cur .fs_filetype != __WASI_FILETYPE_DIRECTORY ) {
107
114
errno = ENOTDIR ;
108
115
return -1 ;
@@ -111,6 +118,7 @@ int __wasilibc_openat_nomode(int fd, const char *path, int oflag) {
111
118
errno = ENOTCAPABLE ;
112
119
return -1 ;
113
120
}
121
+ #endif
114
122
115
123
// Path lookup properties.
116
124
#ifdef __wasilibc_unmodified_upstream // split out __wasi_lookup_t
0 commit comments