Flutter Engine
dart_utils::RunnerTemp Class Reference

#include <tempfs.h>

Public Member Functions

 RunnerTemp ()
 
 ~RunnerTemp ()
 

Static Public Member Functions

static void SetupComponent (fdio_ns_t *ns)
 

Detailed Description

Definition at line 16 of file tempfs.h.

Constructor & Destructor Documentation

◆ RunnerTemp()

dart_utils::RunnerTemp::RunnerTemp ( )

Definition at line 32 of file tempfs.cc.

References dart_runner::kTmpPath, LOG_TAG, and ~RunnerTemp().

33  : loop_(std::make_unique<async::Loop>(
34  &kAsyncLoopConfigNoAttachToCurrentThread)) {
35  loop_->StartThread("RunnerTemp");
36  Start();
37 }

◆ ~RunnerTemp()

dart_utils::RunnerTemp::~RunnerTemp ( )
default

Referenced by RunnerTemp().

Member Function Documentation

◆ SetupComponent()

void dart_utils::RunnerTemp::SetupComponent ( fdio_ns_t *  ns)
static

Definition at line 63 of file tempfs.cc.

References dart_runner::kTmpPath, and LOG_TAG.

Referenced by flutter_runner::MakeDataFileMapping().

63  {
64  // TODO(zra): Should isolates share a /tmp file system within a process, or
65  // should isolates each get their own private memfs for /tmp? For now,
66  // sharing the process-wide /tmp simplifies hot reload since the hot reload
67  // devfs requires sharing between the service isolate and the app isolates.
68  zx_status_t status;
69  fdio_flat_namespace_t* rootns;
70  status = fdio_ns_export_root(&rootns);
71  if (status != ZX_OK) {
72  FX_LOGF(ERROR, LOG_TAG, "Failed to export root ns: %s",
73  zx_status_get_string(status));
74  return;
75  }
76 
77  zx_handle_t tmp_dir_handle;
78  for (size_t i = 0; i < rootns->count; i++) {
79  if (strcmp(rootns->path[i], kTmpPath) == 0) {
80  tmp_dir_handle = rootns->handle[i];
81  } else {
82  zx_handle_close(rootns->handle[i]);
83  rootns->handle[i] = ZX_HANDLE_INVALID;
84  }
85  }
86  free(rootns);
87  rootns = nullptr;
88 
89  status = fdio_ns_bind(ns, kTmpPath, tmp_dir_handle);
90  if (status != ZX_OK) {
91  zx_handle_close(tmp_dir_handle);
92  FX_LOGF(ERROR, LOG_TAG,
93  "Failed to bind /tmp directory into isolate namespace: %s",
94  zx_status_get_string(status));
95  }
96 }
constexpr char kTmpPath[]
#define LOG_TAG
Definition: logging.h:11

The documentation for this class was generated from the following files: