dart-sdk/runtime/bin/namespace_fuchsia.h
Zach Anderson 56f87f409e [dart:io,fuchsia] Pass Isolate namespace to child process. Fix double free.
Before this change, the child process inherits the namespace of the
process. After this change the child process inherits the namespace of
the calling isolate.

Related: DX-710

Change-Id: Idbc72e30f5796f8034cedae776d4572ad0b0360f
Reviewed-on: https://dart-review.googlesource.com/c/89460
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2019-01-15 22:07:51 +00:00

44 lines
1.2 KiB
C++

// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_NAMESPACE_FUCHSIA_H_
#define RUNTIME_BIN_NAMESPACE_FUCHSIA_H_
#include "platform/globals.h"
#if !defined(HOST_OS_FUCHSIA)
#error "This header file should only be included when targeting Fuchsia."
#endif
#include <lib/fdio/namespace.h>
namespace dart {
namespace bin {
class NamespaceImpl {
public:
explicit NamespaceImpl(fdio_ns_t* fdio_ns);
explicit NamespaceImpl(const char* path);
~NamespaceImpl();
intptr_t rootfd() const { return rootfd_; }
char* cwd() const { return cwd_; }
intptr_t cwdfd() const { return cwdfd_; }
fdio_ns_t* fdio_ns() const { return fdio_ns_; }
bool SetCwd(Namespace* namespc, const char* new_path);
private:
fdio_ns_t* fdio_ns_; // native namespace object, if any.
intptr_t rootfd_; // dirfd for the namespace root.
char* cwd_; // cwd relative to the namespace.
intptr_t cwdfd_; // dirfd for the cwd.
DISALLOW_COPY_AND_ASSIGN(NamespaceImpl);
};
} // namespace bin
} // namespace dart
#endif // RUNTIME_BIN_NAMESPACE_FUCHSIA_H_