75
75
__wasilibc_open_nomode (const char * path , int flags )
76
76
{
77
77
const char * relative_path ;
78
- int dirfd = __wasilibc_find_relpath (path , __WASI_RIGHT_PATH_OPEN , 0 ,
79
- & relative_path );
78
+ int dirfd = __wasilibc_find_relpath (path , & relative_path );
80
79
81
80
// If we can't find a preopened directory handle to open this file with,
82
81
// indicate that the program lacks the capabilities.
92
91
access (const char * path , int mode )
93
92
{
94
93
const char * relative_path ;
95
- int dirfd = __wasilibc_find_relpath (path , __WASI_RIGHT_PATH_FILESTAT_GET , 0 ,
96
- & relative_path );
94
+ int dirfd = __wasilibc_find_relpath (path , & relative_path );
97
95
98
96
// If we can't find a preopened directory handle to open this file with,
99
97
// indicate that the program lacks the capabilities.
109
107
lstat (const char * path , struct stat * st )
110
108
{
111
109
const char * relative_path ;
112
- int dirfd = __wasilibc_find_relpath (path , __WASI_RIGHT_PATH_FILESTAT_GET , 0 ,
113
- & relative_path );
110
+ int dirfd = __wasilibc_find_relpath (path , & relative_path );
114
111
115
112
// If we can't find a preopened directory handle to open this file with,
116
113
// indicate that the program lacks the capabilities.
@@ -126,12 +123,10 @@ int
126
123
rename (const char * from , const char * to )
127
124
{
128
125
const char * from_relative_path ;
129
- int from_dirfd = __wasilibc_find_relpath (from , __WASI_RIGHT_PATH_RENAME_SOURCE , 0 ,
130
- & from_relative_path );
126
+ int from_dirfd = __wasilibc_find_relpath (from , & from_relative_path );
131
127
132
128
const char * to_relative_path ;
133
- int to_dirfd = __wasilibc_find_relpath (to , __WASI_RIGHT_PATH_RENAME_TARGET , 0 ,
134
- & to_relative_path );
129
+ int to_dirfd = __wasilibc_find_relpath (to , & to_relative_path );
135
130
136
131
// If we can't find a preopened directory handle to open this file with,
137
132
// indicate that the program lacks the capabilities.
147
142
stat (const char * path , struct stat * st )
148
143
{
149
144
const char * relative_path ;
150
- int dirfd = __wasilibc_find_relpath (path , __WASI_RIGHT_PATH_FILESTAT_GET , 0 ,
151
- & relative_path );
145
+ int dirfd = __wasilibc_find_relpath (path , & relative_path );
152
146
153
147
// If we can't find a preopened directory handle to open this file with,
154
148
// indicate that the program lacks the capabilities.
164
158
unlink (const char * path )
165
159
{
166
160
const char * relative_path ;
167
- int dirfd = __wasilibc_find_relpath (path , __WASI_RIGHT_PATH_UNLINK_FILE , 0 ,
168
- & relative_path );
161
+ int dirfd = __wasilibc_find_relpath (path , & relative_path );
169
162
170
163
// If we can't find a preopened directory handle to open this file with,
171
164
// indicate that the program lacks the capabilities.
184
177
rmdir (const char * pathname )
185
178
{
186
179
const char * relative_path ;
187
- int dirfd = __wasilibc_find_relpath (pathname , __WASI_RIGHT_PATH_REMOVE_DIRECTORY , 0 ,
188
- & relative_path );
180
+ int dirfd = __wasilibc_find_relpath (pathname , & relative_path );
189
181
190
182
// If we can't find a preopened directory handle to open this file with,
191
183
// indicate that the program lacks the capabilities.
@@ -201,20 +193,14 @@ int
201
193
remove (const char * pathname )
202
194
{
203
195
const char * relative_path ;
204
- int dirfd = __wasilibc_find_relpath (pathname ,
205
- __WASI_RIGHT_PATH_UNLINK_FILE |
206
- __WASI_RIGHT_PATH_REMOVE_DIRECTORY ,
207
- 0 ,
208
- & relative_path );
196
+ int dirfd = __wasilibc_find_relpath (pathname , & relative_path );
209
197
210
198
// If searching for both file and directory rights failed, try searching
211
199
// for either individually.
212
200
if (dirfd == -1 ) {
213
- dirfd = __wasilibc_find_relpath (pathname , __WASI_RIGHT_PATH_UNLINK_FILE , 0 ,
214
- & relative_path );
201
+ dirfd = __wasilibc_find_relpath (pathname , & relative_path );
215
202
if (dirfd == -1 ) {
216
- dirfd = __wasilibc_find_relpath (pathname , __WASI_RIGHT_PATH_REMOVE_DIRECTORY , 0 ,
217
- & relative_path );
203
+ dirfd = __wasilibc_find_relpath (pathname , & relative_path );
218
204
}
219
205
}
220
206
@@ -235,12 +221,10 @@ int
235
221
link (const char * oldpath , const char * newpath )
236
222
{
237
223
const char * old_relative_path ;
238
- int old_dirfd = __wasilibc_find_relpath (oldpath , __WASI_RIGHT_PATH_LINK_SOURCE , 0 ,
239
- & old_relative_path );
224
+ int old_dirfd = __wasilibc_find_relpath (oldpath , & old_relative_path );
240
225
241
226
const char * new_relative_path ;
242
- int new_dirfd = __wasilibc_find_relpath (newpath , __WASI_RIGHT_PATH_LINK_TARGET , 0 ,
243
- & new_relative_path );
227
+ int new_dirfd = __wasilibc_find_relpath (newpath , & new_relative_path );
244
228
245
229
// If we can't find a preopened directory handle to open this file with,
246
230
// indicate that the program lacks the capabilities.
256
240
mkdir (const char * pathname , mode_t mode )
257
241
{
258
242
const char * relative_path ;
259
- int dirfd = __wasilibc_find_relpath (pathname , __WASI_RIGHT_PATH_CREATE_DIRECTORY , 0 ,
260
- & relative_path );
243
+ int dirfd = __wasilibc_find_relpath (pathname , & relative_path );
261
244
262
245
// If we can't find a preopened directory handle to open this file with,
263
246
// indicate that the program lacks the capabilities.
@@ -273,8 +256,7 @@ DIR *
273
256
opendir (const char * name )
274
257
{
275
258
const char * relative_path ;
276
- int dirfd = __wasilibc_find_relpath (name , __WASI_RIGHT_PATH_OPEN , 0 ,
277
- & relative_path );
259
+ int dirfd = __wasilibc_find_relpath (name , & relative_path );
278
260
279
261
// If we can't find a preopened directory handle to open this file with,
280
262
// indicate that the program lacks the capabilities.
@@ -290,8 +272,7 @@ ssize_t
290
272
readlink (const char * pathname , char * buf , size_t bufsiz )
291
273
{
292
274
const char * relative_path ;
293
- int dirfd = __wasilibc_find_relpath (pathname , __WASI_RIGHT_PATH_READLINK , 0 ,
294
- & relative_path );
275
+ int dirfd = __wasilibc_find_relpath (pathname , & relative_path );
295
276
296
277
// If we can't find a preopened directory handle to open this file with,
297
278
// indicate that the program lacks the capabilities.
@@ -311,10 +292,7 @@ scandir(
311
292
int (* compar )(const struct dirent * * , const struct dirent * * ))
312
293
{
313
294
const char * relative_path ;
314
- int dirfd = __wasilibc_find_relpath (dirp ,
315
- __WASI_RIGHT_PATH_OPEN ,
316
- __WASI_RIGHT_FD_READDIR ,
317
- & relative_path );
295
+ int dirfd = __wasilibc_find_relpath (dirp , & relative_path );
318
296
319
297
// If we can't find a preopened directory handle to open this file with,
320
298
// indicate that the program lacks the capabilities.
330
308
symlink (const char * target , const char * linkpath )
331
309
{
332
310
const char * relative_path ;
333
- int dirfd = __wasilibc_find_relpath (linkpath , __WASI_RIGHT_PATH_SYMLINK , 0 ,
334
- & relative_path );
311
+ int dirfd = __wasilibc_find_relpath (linkpath , & relative_path );
335
312
336
313
// If we can't find a preopened directory handle to open this file with,
337
314
// indicate that the program lacks the capabilities.
@@ -359,10 +336,6 @@ struct po_map_entry {
359
336
360
337
/// File descriptor (which may be a directory)
361
338
int fd ;
362
-
363
- /// Capability rights associated with the file descriptor
364
- __wasi_rights_t rights_base ;
365
- __wasi_rights_t rights_inheriting ;
366
339
};
367
340
368
341
/// A vector of po_map_entry.
@@ -472,19 +445,10 @@ internal_register_preopened_fd(int fd, const char *name)
472
445
}
473
446
}
474
447
475
- __wasi_fdstat_t statbuf ;
476
- int r = __wasi_fd_fdstat_get ((__wasi_fd_t )fd , & statbuf );
477
- if (r != 0 ) {
478
- errno = r ;
479
- return -1 ; // TODO: Add an infallible way to get the rights?
480
- }
481
-
482
448
struct po_map_entry * entry = & global_map .entries [global_map .length ++ ];
483
449
484
450
entry -> name = name ;
485
451
entry -> fd = fd ;
486
- entry -> rights_base = statbuf .fs_rights_base ;
487
- entry -> rights_inheriting = statbuf .fs_rights_inheriting ;
488
452
489
453
po_map_assertvalid ();
490
454
@@ -504,8 +468,6 @@ __wasilibc_register_preopened_fd(int fd, const char *path)
504
468
int
505
469
__wasilibc_find_relpath (
506
470
const char * path ,
507
- __wasi_rights_t rights_base ,
508
- __wasi_rights_t rights_inheriting ,
509
471
const char * * relative_path )
510
472
{
511
473
size_t bestlen = 0 ;
@@ -539,11 +501,6 @@ __wasilibc_find_relpath(
539
501
continue ;
540
502
}
541
503
542
- if ((rights_base & ~entry -> rights_base ) != 0 ||
543
- (rights_inheriting & ~entry -> rights_inheriting ) != 0 ) {
544
- continue ;
545
- }
546
-
547
504
best = entry -> fd ;
548
505
bestlen = len ;
549
506
any_matches = true;
0 commit comments