mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
LibWasm: Accept newly-created wasi file descriptors as well
This commit is contained in:
parent
a608e87ff9
commit
f62187ed5d
1 changed files with 39 additions and 24 deletions
|
@ -515,14 +515,19 @@ ErrorOr<Result<FileStat>> Implementation::impl$path_filestat_get(Configuration&
|
||||||
auto dir_fd = AT_FDCWD;
|
auto dir_fd = AT_FDCWD;
|
||||||
|
|
||||||
auto mapped_fd = map_fd(fd);
|
auto mapped_fd = map_fd(fd);
|
||||||
if (mapped_fd.has<PreopenedDirectoryDescriptor>()) {
|
mapped_fd.visit(
|
||||||
auto& entry = preopened_directories()[mapped_fd.get<PreopenedDirectoryDescriptor>().value()];
|
[&](PreopenedDirectoryDescriptor descriptor) {
|
||||||
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
auto& entry = preopened_directories()[descriptor.value()];
|
||||||
DeprecatedString path = entry.host_path.string();
|
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
||||||
return open(path.characters(), O_DIRECTORY, 0755);
|
DeprecatedString path = entry.host_path.string();
|
||||||
});
|
return open(path.characters(), O_DIRECTORY, 0755);
|
||||||
entry.opened_fd = dir_fd;
|
});
|
||||||
}
|
entry.opened_fd = dir_fd;
|
||||||
|
},
|
||||||
|
[&](u32 fd) {
|
||||||
|
dir_fd = fd;
|
||||||
|
},
|
||||||
|
[](UnmappedDescriptor) {});
|
||||||
|
|
||||||
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
||||||
return errno_value_from_errno(errno);
|
return errno_value_from_errno(errno);
|
||||||
|
@ -573,14 +578,19 @@ ErrorOr<Result<void>> Implementation::impl$path_create_directory(Configuration&
|
||||||
auto dir_fd = AT_FDCWD;
|
auto dir_fd = AT_FDCWD;
|
||||||
|
|
||||||
auto mapped_fd = map_fd(fd);
|
auto mapped_fd = map_fd(fd);
|
||||||
if (mapped_fd.has<PreopenedDirectoryDescriptor>()) {
|
mapped_fd.visit(
|
||||||
auto& entry = preopened_directories()[mapped_fd.get<PreopenedDirectoryDescriptor>().value()];
|
[&](PreopenedDirectoryDescriptor descriptor) {
|
||||||
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
auto& entry = preopened_directories()[descriptor.value()];
|
||||||
DeprecatedString path = entry.host_path.string();
|
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
||||||
return open(path.characters(), O_DIRECTORY, 0755);
|
DeprecatedString path = entry.host_path.string();
|
||||||
});
|
return open(path.characters(), O_DIRECTORY, 0755);
|
||||||
entry.opened_fd = dir_fd;
|
});
|
||||||
}
|
entry.opened_fd = dir_fd;
|
||||||
|
},
|
||||||
|
[&](u32 fd) {
|
||||||
|
dir_fd = fd;
|
||||||
|
},
|
||||||
|
[](UnmappedDescriptor) {});
|
||||||
|
|
||||||
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
||||||
return errno_value_from_errno(errno);
|
return errno_value_from_errno(errno);
|
||||||
|
@ -599,14 +609,19 @@ ErrorOr<Result<FD>> Implementation::impl$path_open(Configuration& configuration,
|
||||||
auto dir_fd = AT_FDCWD;
|
auto dir_fd = AT_FDCWD;
|
||||||
|
|
||||||
auto mapped_fd = map_fd(fd);
|
auto mapped_fd = map_fd(fd);
|
||||||
if (mapped_fd.has<PreopenedDirectoryDescriptor>()) {
|
mapped_fd.visit(
|
||||||
auto& entry = preopened_directories()[mapped_fd.get<PreopenedDirectoryDescriptor>().value()];
|
[&](PreopenedDirectoryDescriptor descriptor) {
|
||||||
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
auto& entry = preopened_directories()[descriptor.value()];
|
||||||
DeprecatedString path = entry.host_path.string();
|
dir_fd = entry.opened_fd.value_or_lazy_evaluated([&] {
|
||||||
return open(path.characters(), O_DIRECTORY, 0755);
|
DeprecatedString path = entry.host_path.string();
|
||||||
});
|
return open(path.characters(), O_DIRECTORY, 0755);
|
||||||
entry.opened_fd = dir_fd;
|
});
|
||||||
}
|
entry.opened_fd = dir_fd;
|
||||||
|
},
|
||||||
|
[&](u32 fd) {
|
||||||
|
dir_fd = fd;
|
||||||
|
},
|
||||||
|
[](UnmappedDescriptor) {});
|
||||||
|
|
||||||
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
if (dir_fd < 0 && dir_fd != AT_FDCWD)
|
||||||
return errno_value_from_errno(errno);
|
return errno_value_from_errno(errno);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue