Skip to content

Commit 6c34131

Browse files
BreakthroughCQ Bot
authored and
CQ Bot
committed
[fuchsia-component] Migrate ServiceFs to io2
Migrate remaining uses of io1 in fuchsia-component and fuchsia-component-test. Bug: 324111518 Test: fx test //src/lib/fuchsia-component \ //src/lib/fuchsia-component-test Change-Id: I8afe7a39cb1d1baa72c3b945a841a426c55e23c2 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1200344 Commit-Queue: Brandon Castellano <[email protected]> Reviewed-by: Claire Gonyeo <[email protected]>
1 parent 6010ecb commit 6c34131

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

src/lib/fuchsia-component-test/realm_builder_server/src/builtin.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use vfs::directory::immutable::simple as simpledir;
1313
use vfs::execution_scope::ExecutionScope;
1414
use vfs::file::vmo::VmoFile;
1515
use vfs::path::Path as VfsPath;
16+
use vfs::ObjectRequest;
1617
use zx::{self as zx, HandleBased};
1718
use {fidl_fuchsia_component_test as ftest, fidl_fuchsia_io as fio};
1819

@@ -60,12 +61,13 @@ pub async fn read_only_directory_helper(
6061
top_directory.clone().set_not_found_handler(Box::new(move |path| {
6162
warn!("nonexistent path {:?} accessed in read only directory {:?}", path, directory_name);
6263
}));
63-
top_directory.open(
64+
let flags = fio::PERM_READABLE | fio::Flags::PROTOCOL_DIRECTORY;
65+
top_directory.open3(
6466
execution_scope_dropper.execution_scope.clone(),
65-
fio::OpenFlags::RIGHT_READABLE | fio::OpenFlags::DIRECTORY,
6667
VfsPath::dot(),
67-
outgoing_dir.into_channel().into(),
68-
);
68+
flags.clone(),
69+
&mut ObjectRequest::new(flags, &Default::default(), outgoing_dir.into_channel().into()),
70+
)?;
6971
execution_scope_dropper.execution_scope.wait().await;
7072
Ok(())
7173
}

src/lib/fuchsia-component-test/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,12 +2061,7 @@ impl ScopedInstance {
20612061
server_end: zx::Channel,
20622062
) -> Result<(), anyhow::Error> {
20632063
self.exposed_dir
2064-
.open(
2065-
fio::OpenFlags::NOT_DIRECTORY,
2066-
fio::ModeType::empty(),
2067-
protocol_name,
2068-
ServerEnd::new(server_end),
2069-
)
2064+
.open3(protocol_name, fio::Flags::PROTOCOL_SERVICE, &Default::default(), server_end)
20702065
.map_err(Into::into)
20712066
}
20722067

src/lib/fuchsia-component/src/server/mod.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use vfs::name::Name;
2828
use vfs::path::Path;
2929
use vfs::remote::remote_dir;
3030
use vfs::service::endpoint;
31+
use vfs::ObjectRequest;
3132
use zx::MonotonicDuration;
3233
use {fidl_fuchsia_io as fio, fuchsia_async as fasync};
3334

@@ -471,19 +472,27 @@ impl<ServiceObjTy: ServiceObjTrait> ServiceFs<ServiceObjTy> {
471472

472473
/// When a connection is first made to the `ServiceFs` in the absence of a parent connection,
473474
/// it will be granted these rights.
474-
fn base_connection_flags() -> fio::OpenFlags {
475-
return fio::OpenFlags::RIGHT_READABLE
476-
| fio::OpenFlags::RIGHT_WRITABLE
477-
| fio::OpenFlags::RIGHT_EXECUTABLE;
475+
const fn base_connection_flags() -> fio::Flags {
476+
return fio::Flags::PROTOCOL_DIRECTORY
477+
.union(fio::PERM_READABLE)
478+
.union(fio::PERM_WRITABLE)
479+
.union(fio::PERM_EXECUTABLE);
478480
}
479481

480482
fn serve_connection_impl(&self, chan: fidl::endpoints::ServerEnd<fio::DirectoryMarker>) {
481-
self.dir.clone().open(
482-
self.scope.clone(),
483-
Self::base_connection_flags(),
484-
Path::dot(),
485-
fidl::endpoints::ServerEnd::<fio::NodeMarker>::new(chan.into_channel()),
486-
);
483+
self.dir
484+
.clone()
485+
.open3(
486+
self.scope.clone(),
487+
Path::dot(),
488+
Self::base_connection_flags(),
489+
&mut ObjectRequest::new(
490+
Self::base_connection_flags(),
491+
&Default::default(),
492+
chan.into_channel(),
493+
),
494+
)
495+
.expect("failed to serve root ServiceFs connection");
487496
}
488497

489498
/// Creates a protocol connector that can access the capabilities exposed by this ServiceFs.

src/lib/fuchsia-component/src/server/until_stalled.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<ServiceObjTy: ServiceObjTrait> Stream for StallableServiceFs<ServiceObjTy>
130130
}
131131

132132
struct OutgoingConnector {
133-
flags: fio::OpenFlags,
133+
flags: fio::Flags,
134134
scope: ExecutionScope,
135135
dir: Arc<Simple>,
136136
}

0 commit comments

Comments
 (0)