[L] Change in fuchsia/fuchsia[main]: [vfs][rust] Simplify directory/serving code

6 views
Skip to first unread message

'Brandon Castellano (Gerrit)' via owners-override

unread,
Mar 14, 2025, 4:01:23 PM3/14/25
to Owners Override
Attention needed from Owners Override

Brandon Castellano has uploaded the change for review

Brandon Castellano would like Owners Override to review this change.

Commit message

[vfs][rust] Simplify directory/serving code

Add new serve functions for commonly used operations. This avoids the
need for many users to construct a new proxy/server pair,
ExecutionScope, ObjectRequest, and fuchsia.io/Options, which aren't
required by the vast majority of vfs crate users.

Rename directory "spawn" functions to "serve" to match their
counterparts in other parts of this crate (e.g. "file::serve",
"symlink::serve"). Make the default of serving a directory with readable
rights explicit by renaming "spawn_directory" to "serve_read_only".
Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662

Change diff


Change information

Files:
  • M sdk/ctf/tests/fidl/fuchsia.intl/testing/realm-factory/src/main.rs
  • M sdk/lib/device-watcher/rust/src/lib.rs
  • M sdk/lib/zxio/tests/zxio-test.rs
  • M src/connectivity/bluetooth/testing/realmbuilder-mock-helpers/src/lib.rs
  • M src/connectivity/network/testing/netemul/service/src/main.rs
  • M src/developer/ffx/playground/src/test.rs
  • M src/developer/ffx/tools/playground/src/cf_fs.rs
  • M src/developer/ffx/tools/playground/src/host_fs.rs
  • M src/developer/ffx/tools/playground/src/lib.rs
  • M src/diagnostics/persistence/tests/mock_filesystems.rs
  • M src/lib/fdomain/example/src/transport.rs
  • M src/lib/fuchsia-fs/src/directory.rs
  • M src/lib/fuchsia-fs/src/lib.rs
  • M src/media/audio/lib/rust/src/device.rs
  • M src/settings/service/integration_tests/light_tests/src/light_realm.rs
  • M src/storage/gpt/component/src/gpt.rs
  • M src/storage/lib/vfs/rust/src/directory.rs
  • M src/storage/lib/vfs/rust/src/lib.rs
  • M src/sys/component_manager/lib/serve_processargs/src/namespace.rs
  • M src/sys/lib/fidl-fuchsia-component-abi-ext/src/lib.rs
  • M src/sys/lib/mem_util/src/lib.rs
  • M src/sys/pkg/bin/pkg-cache/src/compat/pkgfs/validation.rs
  • M src/sys/pkg/lib/blobfs/src/mock.rs
  • M src/sys/pkg/lib/package-directory/src/meta_as_dir.rs
  • M src/sys/pkg/lib/package-directory/src/meta_subdir.rs
  • M src/sys/pkg/lib/package-directory/src/non_meta_subdir.rs
  • M src/sys/pkg/lib/package-directory/src/root_dir.rs
  • M src/sys/pkg/lib/update-package/src/images.rs
  • M src/sys/tools/debug-dash-launcher/src/trampoline.rs
Change size: L
Delta: 29 files changed, 189 insertions(+), 464 deletions(-)
Open in Gerrit

Related details

Attention is currently required from:
  • Owners Override
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
Gerrit-Change-Number: 1228945
Gerrit-PatchSet: 5
Gerrit-Owner: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/6b4ccc3d95195d2554275e700e54ce26e6dadad4-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'Brandon Castellano (Gerrit)' via owners-override

unread,
Mar 14, 2025, 5:21:47 PM3/14/25
to Owners Override, James Sullivan, GI Try Builder, CQ Bot
Attention needed from Brandon Castellano and Owners Override

Brandon Castellano voted and added 1 comment

Votes added by Brandon Castellano

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 4:
James Sullivan . resolved

Great change! Thanks.

Brandon Castellano

This will help a lot with migrating the remainder of Open1 callers in Rust as can be seen from some follow up changes. I likely won't be able to get all of them done, but I do want to try and address the ones in //src/sys before EoQ.

Open in Gerrit

Related details

Attention is currently required from:
  • Brandon Castellano
  • Owners Override
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
Gerrit-Change-Number: 1228945
Gerrit-PatchSet: 8
Gerrit-Owner: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Brandon Castellano <bcas...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Comment-Date: Fri, 14 Mar 2025 21:21:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: James Sullivan <jfsu...@google.com>

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/3326cd54f69131f63c4e6ce1b2960cf48b153d5c-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'James Robinson (Gerrit)' via owners-override

unread,
Mar 14, 2025, 6:04:22 PM3/14/25
to Brandon Castellano, Owners Override, James Sullivan, GI Try Builder, CQ Bot
Attention needed from Brandon Castellano and Owners Override

James Robinson voted Owners-Override+1

Owners-Override+1
Open in Gerrit

Related details

Attention is currently required from:
  • Brandon Castellano
  • Owners Override
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
Gerrit-Change-Number: 1228945
Gerrit-PatchSet: 9
Gerrit-Owner: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: James Robinson <jam...@google.com>
Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Brandon Castellano <bcas...@google.com>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Comment-Date: Fri, 14 Mar 2025 22:04:05 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/7fabf622c171c0bc3e3a5ac754bfca7e6a59f291-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'Brandon Castellano (Gerrit)' via owners-override

unread,
Mar 14, 2025, 6:51:35 PM3/14/25
to James Robinson, Owners Override, James Sullivan, GI Try Builder, CQ Bot
Attention needed from Owners Override

Brandon Castellano voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Owners Override
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: fuchsia
Gerrit-Branch: main
Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
Gerrit-Change-Number: 1228945
Gerrit-PatchSet: 9
Gerrit-Owner: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
Gerrit-Reviewer: James Robinson <jam...@google.com>
Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
Gerrit-Attention: Owners Override <owners-...@fuchsia.dev>
Gerrit-Comment-Date: Fri, 14 Mar 2025 22:51:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

--
You received this message because you are subscribed to the Google Groups "owners-override" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/ab2a1f88d50d7476414c3adb1e46e02364cfd3fc-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
satisfied_requirement
open
diffy

'CQ Bot (Gerrit)' via owners-override

unread,
Mar 14, 2025, 6:52:14 PM3/14/25
to Brandon Castellano, James Robinson, Owners Override, James Sullivan, GI Try Builder

CQ Bot submitted the change with unreviewed changes

Unreviewed changes

4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/storage/lib/vfs/rust/src/directory.rs
Insertions: 2, Deletions: 2.

@@ -76,6 +76,6 @@
/// Helper function to serve a new connection to `directory` as read-only (i.e. with
/// [`fio::PERM_READABLE`]). Errors will be communicated via epitaph on the returned proxy. A new
/// [`crate::execution_scope::ExecutionScope`] will be created for the request.
-pub fn serve_read_only<D: Directory + ?Sized>(dir: Arc<D>) -> fio::DirectoryProxy {
- crate::serve_directory(dir, Path::dot(), fio::PERM_READABLE)
+pub fn serve_read_only<D: Directory + ?Sized>(directory: Arc<D>) -> fio::DirectoryProxy {
+ crate::serve_directory(directory, Path::dot(), fio::PERM_READABLE)
}
```
```
The name of the file: src/lib/fuchsia-fs/src/lib.rs
Insertions: 1, Deletions: 3.

@@ -32,11 +32,9 @@
use std::fs;
use std::path::Path;
use tempfile::TempDir;
- use vfs::directory::entry_container::Directory;
- use vfs::execution_scope::ExecutionScope;
use vfs::file::vmo::read_only;
+ use vfs::pseudo_directory;
use vfs::remote::remote_dir;
- use vfs::{pseudo_directory, ObjectRequest};
use {fuchsia_async as fasync, zx_status};

#[fasync::run_singlethreaded(test)]
```
```
The name of the file: src/sys/pkg/bin/pkg-cache/src/compat/pkgfs/validation.rs
Insertions: 0, Deletions: 1.

@@ -221,7 +221,6 @@
use vfs::directory::entry::GetEntryInfo;
use vfs::directory::entry_container::Directory;
use vfs::node::Node;
- use vfs::ObjectRequest;

struct TestEnv {
_blobfs: BlobfsRamdisk,
```
```
The name of the file: src/lib/fuchsia-fs/src/directory.rs
Insertions: 1, Deletions: 2.

@@ -775,13 +775,12 @@
use vfs::directory::entry_container::Directory;
use vfs::execution_scope::ExecutionScope;
use vfs::file::vmo::read_only;
+ use vfs::pseudo_directory;
use vfs::remote::remote_dir;
- use vfs::{pseudo_directory, ObjectRequest};

const DATA_FILE_CONTENTS: &str = "Hello World!\n";

#[cfg(target_os = "fuchsia")]
- #[cfg(target_os = "fuchsia")]
const LONG_DURATION: MonotonicDuration = MonotonicDuration::from_seconds(30);

#[cfg(not(target_os = "fuchsia"))]
```
```
The name of the file: src/sys/pkg/lib/blobfs/src/mock.rs
Insertions: 4, Deletions: 2.

@@ -51,7 +51,7 @@
})) => {
assert_eq!(path, merkle.to_string());
assert!(flags.contains(fio::PERM_READABLE));
- assert!(!flags.intersects(fio::PERM_WRITABLE | fio::Flags::FLAG_MAYBE_CREATE));
+ assert!(!flags.intersects(fio::Flags::PERM_WRITE | fio::Flags::FLAG_MAYBE_CREATE));

let stream =
fio::NodeRequestStream::from_channel(fasync::Channel::from_channel(object))
@@ -216,7 +216,9 @@
control_handle: _,
})) => {
assert!(flags.contains(fio::PERM_READABLE));
- assert!(!flags.intersects(fio::PERM_WRITABLE | fio::Flags::FLAG_MAYBE_CREATE));
+ assert!(
+ !flags.intersects(fio::Flags::PERM_WRITE | fio::Flags::FLAG_MAYBE_CREATE)
+ );
let path: Hash = path.parse().unwrap();

let stream =
```

Change information

Commit message:
[vfs][rust] Simplify directory/serving code

Add new serve functions for commonly used operations. This avoids the
need for many users to construct a new proxy/server pair,
ExecutionScope, ObjectRequest, and fuchsia.io/Options, which aren't
required by the vast majority of vfs crate users.

Rename directory "spawn" functions to "serve" to match their
counterparts in other parts of this crate (e.g. "file::serve",
"symlink::serve"). Make the default of serving a directory with readable
rights explicit by renaming "spawn_directory" to "serve_read_only".
Bug: 324111518
Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
Owners-Override: James Robinson <jam...@google.com>
Reviewed-by: James Sullivan <jfsu...@google.com>
Commit-Queue: Brandon Castellano <bcas...@google.com>
Files:
    • M sdk/ctf/tests/fidl/fuchsia.intl/testing/realm-factory/src/main.rs
    • M sdk/lib/device-watcher/rust/src/lib.rs
    • M sdk/lib/zxio/tests/zxio-test.rs
    • M src/connectivity/bluetooth/testing/realmbuilder-mock-helpers/src/lib.rs
    • M src/connectivity/network/testing/netemul/service/src/main.rs
    • M src/developer/ffx/playground/src/test.rs
    • M src/developer/ffx/tools/playground/src/cf_fs.rs
    • M src/developer/ffx/tools/playground/src/host_fs.rs
    • M src/developer/ffx/tools/playground/src/lib.rs
    • M src/diagnostics/persistence/tests/mock_filesystems.rs
    • M src/lib/fdomain/example/src/transport.rs
    • M src/lib/fuchsia-fs/src/directory.rs
    • M src/lib/fuchsia-fs/src/lib.rs
    • M src/media/audio/lib/rust/src/device.rs
    • M src/settings/service/integration_tests/light_tests/src/light_realm.rs
    • M src/storage/gpt/component/src/gpt.rs
    • M src/storage/lib/vfs/rust/src/directory.rs
    • M src/storage/lib/vfs/rust/src/lib.rs
    • M src/sys/component_manager/lib/serve_processargs/src/namespace.rs
    • M src/sys/lib/fidl-fuchsia-component-abi-ext/src/lib.rs
    • M src/sys/lib/mem_util/src/lib.rs
    • M src/sys/pkg/bin/pkg-cache/src/compat/pkgfs/validation.rs
    • M src/sys/pkg/lib/package-directory/src/meta_as_dir.rs
    • M src/sys/pkg/lib/package-directory/src/meta_subdir.rs
    • M src/sys/pkg/lib/package-directory/src/non_meta_subdir.rs
    • M src/sys/pkg/lib/package-directory/src/root_dir.rs
    • M src/sys/pkg/lib/update-package/src/images.rs
    • M src/sys/tools/debug-dash-launcher/src/trampoline.rs
      Change size: L
      Delta: 28 files changed, 189 insertions(+), 466 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +2 by James Sullivan
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: fuchsia
      Gerrit-Branch: main
      Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
      Gerrit-Change-Number: 1228945
      Gerrit-PatchSet: 10
      Gerrit-Owner: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: James Robinson <jam...@google.com>
      Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
      Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>

      --
      You received this message because you are subscribed to the Google Groups "owners-override" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
      To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/a425218a3402e2d1f14bcad9f94991bded3b63a3-HTML%40fuchsia-review.googlesource.com.
      open
      diffy
      satisfied_requirement

      'GI Roller (Gerrit)' via owners-override

      unread,
      Mar 14, 2025, 7:00:39 PM3/14/25
      to Brandon Castellano, CQ Bot, James Robinson, Owners Override, James Sullivan, GI Try Builder

      Message from GI Roller

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: fuchsia
      Gerrit-Branch: main
      Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
      Gerrit-Change-Number: 1228945
      Gerrit-PatchSet: 10
      Gerrit-Owner: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: James Robinson <jam...@google.com>
      Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
      Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
      Gerrit-Comment-Date: Fri, 14 Mar 2025 23:00:35 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: No

      --
      You received this message because you are subscribed to the Google Groups "owners-override" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
      To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/265e8c462e94a2454385293a61fffe81d86ee012-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
      satisfied_requirement
      open
      diffy

      'Ben Keller (Gerrit)' via owners-override

      unread,
      Mar 14, 2025, 8:30:32 PM3/14/25
      to Brandon Castellano, CQ Bot, GI Roller, James Robinson, Owners Override, James Sullivan, GI Try Builder

      Ben Keller added 1 comment

      Patchset-level comments
      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: fuchsia
      Gerrit-Branch: main
      Gerrit-Change-Id: Ia37686c956d37eebb8cea14c28ad4a3fdab7f662
      Gerrit-Change-Number: 1228945
      Gerrit-PatchSet: 10
      Gerrit-Owner: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: Brandon Castellano <bcas...@google.com>
      Gerrit-Reviewer: James Robinson <jam...@google.com>
      Gerrit-Reviewer: James Sullivan <jfsu...@google.com>
      Gerrit-Reviewer: Owners Override <owners-...@fuchsia.dev>
      Gerrit-CC: Ben Keller <galb...@google.com>
      Gerrit-Comment-Date: Sat, 15 Mar 2025 00:30:27 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No

      --
      You received this message because you are subscribed to the Google Groups "owners-override" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to owners-overri...@fuchsia.dev.
      To view this discussion visit https://groups.google.com/a/fuchsia.dev/d/msgid/owners-override/455483847dfdba9f2ad1922cd0663eb69851984b-EmailReviewComments-HTML%40fuchsia-review.googlesource.com.
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages