-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
Feature Request
We are implementing 2 of the syscalls that deal with removing files and empty directories.
Lines 99 to 101 in 7349f7d
path_remove_directory(path): number { | |
return -1; | |
} |
Lines 108 to 110 in 7349f7d
path_unlink_file(path): number { | |
return -1; | |
} |
https://wasix.org/docs/api-reference/wasi/path_unlink_file
https://wasix.org/docs/api-reference/wasi/path_remove_directory
Status
We have implemented both and it seems to work for empty file and empty directory.
The code is based on https://github.com/bjorn3/browser_wasi_shim/pull/42/files#diff-177a21b9f40c72ea679cf8658d14ed0d9702afcea694e92e0936f11ab182d2a3R331-R333
with some additional checks.
Challenges
- Fails on a directory that is not empty. In Golang with https://pkg.go.dev/os#RemoveAll it uses a recursive algorithm with
unlinkat
to unlink the files and remove the empty directories. This goes into an infinite loop. - The WASI spec requires that we check file and directory permissions/rights before removing/unlinking but the rights base isn't stored anywhere? We couldn't find many examples of checking rights
browser_wasi_shim/src/wasi_defs.ts
Line 116 in 7349f7d
export const RIGHTS_PATH_UNLINK_FILE = 1 << 26;
other thanbrowser_wasi_shim/src/fs_fd.ts
Lines 290 to 291 in 7349f7d
(fs_rights_base & BigInt(wasi.RIGHTS_FD_WRITE)) == BigInt(wasi.RIGHTS_FD_WRITE)
Metadata
Metadata
Assignees
Labels
No labels