[runtime] Transition to new fdio functions

This should allow Dart to start targeting Fuchsia API level 28.

TEST=ci

Bug: b/434220174
Change-Id: Id55deb491122be85d9a5731be2c7571b0126dcd8
Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448260
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Brandon Castellano
2025-09-02 14:27:50 -07:00
committed by Commit Queue
parent b40781459a
commit 0c45b7e861
3 changed files with 15 additions and 22 deletions
+8 -9
View File
@@ -7,15 +7,14 @@
#include "bin/directory.h"
#include <dirent.h> // NOLINT
#include <errno.h> // NOLINT
#include <fcntl.h> // NOLINT
#include <lib/fdio/namespace.h> // NOLINT
#include <stdlib.h> // NOLINT
#include <string.h> // NOLINT
#include <sys/param.h> // NOLINT
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
#include <dirent.h> // NOLINT
#include <errno.h> // NOLINT
#include <fcntl.h> // NOLINT
#include <stdlib.h> // NOLINT
#include <string.h> // NOLINT
#include <sys/param.h> // NOLINT
#include <sys/stat.h> // NOLINT
#include <unistd.h> // NOLINT
#include "bin/crypto.h"
#include "bin/dartutils.h"
+5 -11
View File
@@ -586,24 +586,18 @@ class ProcessStarter {
NamespaceScope ns(namespc_, path_);
int pathfd = -1;
zx_status_t status;
constexpr fuchsia::io::Flags kFlags =
fuchsia::io::PERM_READABLE | fuchsia::io::PERM_EXECUTABLE;
if (ns.fd() == AT_FDCWD) {
status = fdio_open_fd(
ns.path(),
static_cast<uint32_t>(fuchsia::io::OpenFlags::RIGHT_READABLE |
fuchsia::io::OpenFlags::RIGHT_EXECUTABLE),
&pathfd);
status = fdio_open3_fd(ns.path(), uint64_t{kFlags}, &pathfd);
} else {
status = fdio_open_fd_at(
ns.fd(), ns.path(),
static_cast<uint32_t>(fuchsia::io::OpenFlags::RIGHT_READABLE |
fuchsia::io::OpenFlags::RIGHT_EXECUTABLE),
&pathfd);
status = fdio_open3_fd_at(ns.fd(), ns.path(), uint64_t{kFlags}, &pathfd);
}
if (status != ZX_OK) {
close(exit_pipe_fds[0]);
close(exit_pipe_fds[1]);
ReportStartError(
"Failed to load executable for process start (fdio_open_fd_at %s).",
"Failed to load executable for process start (fdio_open3_fd_at %s).",
zx_status_get_string(status));
return status;
}
+2 -2
View File
@@ -306,10 +306,10 @@ void* Utils::LoadDynamicLibrary(const char* library_path,
if (handle == nullptr) {
// Fuchsia's search path is different.
// https://fuchsia.dev/fuchsia-src/concepts/process/program_loading#zircons_standard_elf_dynamic_linker
fuchsia::io::Flags flags =
constexpr fuchsia::io::Flags kFlags =
fuchsia::io::PERM_READABLE | fuchsia::io::PERM_EXECUTABLE;
int fd = -1;
zx_status_t status = fdio_open3_fd(library_path, uint64_t{flags}, &fd);
zx_status_t status = fdio_open3_fd(library_path, uint64_t{kFlags}, &fd);
if (status != ZX_OK) {
*error = strdup(zx_status_get_string(status));
return nullptr;