Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions shell/platform/fuchsia/flutter/file_in_namespace_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "file_in_namespace_buffer.h"

#include <fuchsia/io/cpp/fidl.h>
#include <lib/fdio/directory.h>
#include <zircon/status.h>

Expand All @@ -16,17 +17,6 @@

namespace flutter_runner {

namespace {

// TODO(kaushikiska): Use these constants from ::llcpp::fuchsia::io
// Can read from target object.
constexpr uint32_t OPEN_RIGHT_READABLE = 1u;

// Connection can map target object executable.
constexpr uint32_t OPEN_RIGHT_EXECUTABLE = 8u;

} // namespace

FileInNamespaceBuffer::FileInNamespaceBuffer(int namespace_fd,
const char* path,
bool executable)
Expand Down Expand Up @@ -84,15 +74,16 @@ std::unique_ptr<fml::Mapping> LoadFile(int namespace_fd,

std::unique_ptr<fml::FileMapping> MakeFileMapping(const char* path,
bool executable) {
uint32_t flags = OPEN_RIGHT_READABLE;
auto flags = fuchsia::io::OPEN_RIGHT_READABLE;
if (executable) {
flags |= OPEN_RIGHT_EXECUTABLE;
flags |= fuchsia::io::OPEN_RIGHT_EXECUTABLE;
}

// The returned file descriptor is compatible with standard posix operations
// such as close, mmap, etc. We only need to treat open/open_at specially.
int fd;
const zx_status_t status = fdio_open_fd(path, flags, &fd);
const zx_status_t status =
fdio_open_fd(path, static_cast<uint32_t>(flags), &fd);
if (status != ZX_OK) {
return nullptr;
}
Expand Down
12 changes: 7 additions & 5 deletions shell/platform/fuchsia/runtime/dart/utils/mapped_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ static int OpenFdExec(const std::string& path, int dirfd) {
// fdio_open_fd_at does not support AT_FDCWD, by design. Use fdio_open_fd
// and expect an absolute path for that usage pattern.
dart_utils::Check(path[0] == '/', LOG_TAG);
result = fdio_open_fd(
path.c_str(),
fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_EXECUTABLE,
&fd);
result =
fdio_open_fd(path.c_str(),
static_cast<uint32_t>(fuchsia::io::OPEN_RIGHT_READABLE |
fuchsia::io::OPEN_RIGHT_EXECUTABLE),
&fd);
} else {
dart_utils::Check(path[0] != '/', LOG_TAG);
result = fdio_open_fd_at(
dirfd, path.c_str(),
fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_EXECUTABLE,
static_cast<uint32_t>(fuchsia::io::OPEN_RIGHT_READABLE |
fuchsia::io::OPEN_RIGHT_EXECUTABLE),
&fd);
}
if (result != ZX_OK) {
Expand Down
23 changes: 14 additions & 9 deletions shell/platform/fuchsia/runtime/dart/utils/vmo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ bool VmoFromFilename(const std::string& filename,
// Note: the implementation here cannot be shared with VmoFromFilenameAt
// because fdio_open_fd_at does not aim to provide POSIX compatibility, and
// thus does not handle AT_FDCWD as dirfd.
uint32_t flags = fuchsia::io::OPEN_RIGHT_READABLE |
(executable ? fuchsia::io::OPEN_RIGHT_EXECUTABLE : 0);
zx_status_t status;
int fd;
auto flags = fuchsia::io::OPEN_RIGHT_READABLE;
if (executable) {
flags |= fuchsia::io::OPEN_RIGHT_EXECUTABLE;
}

status = fdio_open_fd(filename.c_str(), flags, &fd);
int fd;
const zx_status_t status =
fdio_open_fd(filename.c_str(), static_cast<uint32_t>(flags), &fd);
if (status != ZX_OK) {
FX_LOGF(ERROR, LOG_TAG, "fdio_open_fd(\"%s\", %08x) failed: %s",
filename.c_str(), flags, zx_status_get_string(status));
Expand All @@ -79,11 +81,14 @@ bool VmoFromFilenameAt(int dirfd,
const std::string& filename,
bool executable,
fuchsia::mem::Buffer* buffer) {
uint32_t flags = fuchsia::io::OPEN_RIGHT_READABLE |
(executable ? fuchsia::io::OPEN_RIGHT_EXECUTABLE : 0);
zx_status_t status;
auto flags = fuchsia::io::OPEN_RIGHT_READABLE;
if (executable) {
flags |= fuchsia::io::OPEN_RIGHT_EXECUTABLE;
}

int fd;
status = fdio_open_fd_at(dirfd, filename.c_str(), flags, &fd);
const zx_status_t status = fdio_open_fd_at(dirfd, filename.c_str(),
static_cast<uint32_t>(flags), &fd);
if (status != ZX_OK) {
FX_LOGF(ERROR, LOG_TAG, "fdio_open_fd_at(%d, \"%s\", %08x) failed: %s",
dirfd, filename.c_str(), flags, zx_status_get_string(status));
Expand Down