7575__wasilibc_open_nomode (const char * path , int flags )
7676{
7777 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 );
8079
8180 // If we can't find a preopened directory handle to open this file with,
8281 // indicate that the program lacks the capabilities.
9291access (const char * path , int mode )
9392{
9493 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 );
9795
9896 // If we can't find a preopened directory handle to open this file with,
9997 // indicate that the program lacks the capabilities.
109107lstat (const char * path , struct stat * st )
110108{
111109 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 );
114111
115112 // If we can't find a preopened directory handle to open this file with,
116113 // indicate that the program lacks the capabilities.
@@ -126,12 +123,10 @@ int
126123rename (const char * from , const char * to )
127124{
128125 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 );
131127
132128 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 );
135130
136131 // If we can't find a preopened directory handle to open this file with,
137132 // indicate that the program lacks the capabilities.
147142stat (const char * path , struct stat * st )
148143{
149144 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 );
152146
153147 // If we can't find a preopened directory handle to open this file with,
154148 // indicate that the program lacks the capabilities.
164158unlink (const char * path )
165159{
166160 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 );
169162
170163 // If we can't find a preopened directory handle to open this file with,
171164 // indicate that the program lacks the capabilities.
184177rmdir (const char * pathname )
185178{
186179 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 );
189181
190182 // If we can't find a preopened directory handle to open this file with,
191183 // indicate that the program lacks the capabilities.
@@ -201,20 +193,14 @@ int
201193remove (const char * pathname )
202194{
203195 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 );
209197
210198 // If searching for both file and directory rights failed, try searching
211199 // for either individually.
212200 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 );
215202 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 );
218204 }
219205 }
220206
@@ -235,12 +221,10 @@ int
235221link (const char * oldpath , const char * newpath )
236222{
237223 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 );
240225
241226 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 );
244228
245229 // If we can't find a preopened directory handle to open this file with,
246230 // indicate that the program lacks the capabilities.
256240mkdir (const char * pathname , mode_t mode )
257241{
258242 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 );
261244
262245 // If we can't find a preopened directory handle to open this file with,
263246 // indicate that the program lacks the capabilities.
@@ -273,8 +256,7 @@ DIR *
273256opendir (const char * name )
274257{
275258 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 );
278260
279261 // If we can't find a preopened directory handle to open this file with,
280262 // indicate that the program lacks the capabilities.
@@ -290,8 +272,7 @@ ssize_t
290272readlink (const char * pathname , char * buf , size_t bufsiz )
291273{
292274 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 );
295276
296277 // If we can't find a preopened directory handle to open this file with,
297278 // indicate that the program lacks the capabilities.
@@ -311,10 +292,7 @@ scandir(
311292 int (* compar )(const struct dirent * * , const struct dirent * * ))
312293{
313294 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 );
318296
319297 // If we can't find a preopened directory handle to open this file with,
320298 // indicate that the program lacks the capabilities.
330308symlink (const char * target , const char * linkpath )
331309{
332310 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 );
335312
336313 // If we can't find a preopened directory handle to open this file with,
337314 // indicate that the program lacks the capabilities.
@@ -359,10 +336,6 @@ struct po_map_entry {
359336
360337 /// File descriptor (which may be a directory)
361338 int fd ;
362-
363- /// Capability rights associated with the file descriptor
364- __wasi_rights_t rights_base ;
365- __wasi_rights_t rights_inheriting ;
366339};
367340
368341/// A vector of po_map_entry.
@@ -472,19 +445,10 @@ internal_register_preopened_fd(int fd, const char *name)
472445 }
473446 }
474447
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-
482448 struct po_map_entry * entry = & global_map .entries [global_map .length ++ ];
483449
484450 entry -> name = name ;
485451 entry -> fd = fd ;
486- entry -> rights_base = statbuf .fs_rights_base ;
487- entry -> rights_inheriting = statbuf .fs_rights_inheriting ;
488452
489453 po_map_assertvalid ();
490454
@@ -504,8 +468,6 @@ __wasilibc_register_preopened_fd(int fd, const char *path)
504468int
505469__wasilibc_find_relpath (
506470 const char * path ,
507- __wasi_rights_t rights_base ,
508- __wasi_rights_t rights_inheriting ,
509471 const char * * relative_path )
510472{
511473 size_t bestlen = 0 ;
@@ -539,11 +501,6 @@ __wasilibc_find_relpath(
539501 continue ;
540502 }
541503
542- if ((rights_base & ~entry -> rights_base ) != 0 ||
543- (rights_inheriting & ~entry -> rights_inheriting ) != 0 ) {
544- continue ;
545- }
546-
547504 best = entry -> fd ;
548505 bestlen = len ;
549506 any_matches = true;
0 commit comments