6#if defined(DART_HOST_OS_FUCHSIA)
13#include <lib/fdio/namespace.h>
14#include <zircon/status.h>
24 : fdio_ns_(fdio_ns), cwd_(
strdup(
"/")) {
25 rootfd_ = fdio_ns_opendir(fdio_ns);
27 FATAL(
"Failed to open file descriptor for namespace: errno=%d: %s", errno,
30 cwdfd_ = dup(rootfd_);
32 FATAL(
"Failed to dup() namespace file descriptor: errno=%d: %s", errno,
37NamespaceImpl::NamespaceImpl(
const char*
path)
38 : fdio_ns_(nullptr), cwd_(
strdup(
"/")) {
41 FATAL(
"Failed to open file descriptor for namespace: errno=%d: %s", errno,
44 cwdfd_ = dup(rootfd_);
46 FATAL(
"Failed to dup() namespace file descriptor: errno=%d: %s", errno,
51NamespaceImpl::~NamespaceImpl() {
55 if (fdio_ns_ !=
nullptr) {
56 zx_status_t status = fdio_ns_destroy(fdio_ns_);
57 if (status != ZX_OK) {
58 Syslog::PrintErr(
"fdio_ns_destroy: %s\n", zx_status_get_string(status));
63bool NamespaceImpl::SetCwd(Namespace* namespc,
const char* new_path) {
64 NamespaceScope ns(namespc, new_path);
65 const intptr_t new_cwdfd =
76 tbuf.AddString(File::PathSeparator());
77 tbuf.AddString(ns.path());
81 const intptr_t result_len =
96 NamespaceImpl* namespc_impl =
nullptr;
97 if (namespc !=
kNone) {
98 namespc_impl =
new NamespaceImpl(
reinterpret_cast<fdio_ns_t*
>(namespc));
100 return new Namespace(namespc_impl);
104 return new Namespace(
new NamespaceImpl(
path));
107Namespace::~Namespace() {
111intptr_t Namespace::Default() {
115const char* Namespace::GetCurrent(Namespace* namespc) {
116 if (Namespace::IsDefault(namespc)) {
121 return DartUtils::ScopedCopyCString(
buffer);
123 return namespc->namespc()->cwd();
126bool Namespace::SetCurrent(Namespace* namespc,
const char*
path) {
127 if (Namespace::IsDefault(namespc)) {
130 return namespc->namespc()->SetCwd(namespc,
path);
133void Namespace::ResolvePath(Namespace* namespc,
136 const char** resolved_path) {
138 ASSERT(resolved_path !=
nullptr);
139 if (Namespace::IsDefault(namespc)) {
141 *resolved_path =
path;
145 *dirfd = namespc->namespc()->rootfd();
146 if (strcmp(
path, File::PathSeparator()) == 0) {
148 *resolved_path =
".";
151 *resolved_path = &
path[1];
154 *dirfd = namespc->namespc()->cwdfd();
155 *resolved_path =
path;
159NamespaceScope::NamespaceScope(Namespace* namespc,
const char*
path) {
160 Namespace::ResolvePath(namespc,
path, &fd_, &path_);
163NamespaceScope::~NamespaceScope() {}
static sk_sp< Effect > Create()
NamespaceImpl(fdio_ns_t *fdio_ns)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static bool IsAbsolutePath(const char *path)
char * strdup(const char *str1)
#define NO_RETRY_EXPECTED(expression)
#define TEMP_FAILURE_RETRY(expression)