From 0c45b7e8615a91066020d707bafc4bbc92084f7f Mon Sep 17 00:00:00 2001 From: Brandon Castellano Date: Tue, 2 Sep 2025 14:27:50 -0700 Subject: [PATCH] [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 Reviewed-by: Ben Konyi --- runtime/bin/directory_fuchsia.cc | 17 ++++++++--------- runtime/bin/process_fuchsia.cc | 16 +++++----------- runtime/platform/utils.cc | 4 ++-- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/runtime/bin/directory_fuchsia.cc b/runtime/bin/directory_fuchsia.cc index 4b7107874ae..737d1d0002d 100644 --- a/runtime/bin/directory_fuchsia.cc +++ b/runtime/bin/directory_fuchsia.cc @@ -7,15 +7,14 @@ #include "bin/directory.h" -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT -#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT +#include // NOLINT #include "bin/crypto.h" #include "bin/dartutils.h" diff --git a/runtime/bin/process_fuchsia.cc b/runtime/bin/process_fuchsia.cc index 4c6a1688ea1..6d0b568ce73 100644 --- a/runtime/bin/process_fuchsia.cc +++ b/runtime/bin/process_fuchsia.cc @@ -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(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(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; } diff --git a/runtime/platform/utils.cc b/runtime/platform/utils.cc index 4a02c56a0e3..9ecd17d9154 100644 --- a/runtime/platform/utils.cc +++ b/runtime/platform/utils.cc @@ -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;