Skip to content

Commit 73c5a9c

Browse files
BreakthroughCQ Bot
authored and
CQ Bot
committed
[connectivity] Migrate remaining usages of io1 to io2
Bug: 324111518 Change-Id: I5c1bf6aa4ea9c04a648631e2bbb2062bfa41c41e Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1200345 Reviewed-by: Bruno Dal Bo <[email protected]> Commit-Queue: Brandon Castellano <[email protected]>
1 parent 6c34131 commit 73c5a9c

File tree

6 files changed

+39
-33
lines changed

6 files changed

+39
-33
lines changed

src/connectivity/bluetooth/tools/bt-hci-emulator/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async fn main() -> Result<(), Error> {
3131
}
3232
};
3333

34-
let dev_dir = fuchsia_fs::directory::open_in_namespace(DEV_DIR, fuchsia_fs::OpenFlags::empty())
34+
let dev_dir = fuchsia_fs::directory::open_in_namespace(DEV_DIR, fuchsia_fs::PERM_READABLE)
3535
.with_context(|| format!("failed to open {}", DEV_DIR))?;
3636

3737
let emulator = Emulator::create_and_publish(dev_dir).await?;

src/connectivity/network/netstack-proxy/src/main.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,16 @@ pub async fn main() -> std::process::ExitCode {
101101
let scope = vfs::execution_scope::ExecutionScope::new();
102102

103103
let (svc_dir, server_end) = fidl::endpoints::create_endpoints::<fidl_fuchsia_io::NodeMarker>();
104-
105-
svc.open(
104+
let flags = fidl_fuchsia_io::PERM_READABLE
105+
| fidl_fuchsia_io::PERM_WRITABLE
106+
| fidl_fuchsia_io::PERM_EXECUTABLE;
107+
svc.open3(
106108
scope.clone(),
107-
fidl_fuchsia_io::OpenFlags::RIGHT_READABLE
108-
| fidl_fuchsia_io::OpenFlags::RIGHT_WRITABLE
109-
| fidl_fuchsia_io::OpenFlags::RIGHT_EXECUTABLE,
110109
vfs::path::Path::dot(),
111-
server_end,
112-
);
110+
flags.clone(),
111+
&mut vfs::ObjectRequest::new(flags, &Default::default(), server_end.into_channel()),
112+
)
113+
.expect("failed to create connection to service directory");
113114

114115
actions.push(fdio::SpawnAction::add_namespace_entry(c"/svc", svc_dir.into_channel().into()));
115116

src/connectivity/network/testing/netemul/service/src/main.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,17 @@ impl ManagedRealm {
734734
})?;
735735
}
736736
ManagedRealmRequest::GetDevfs { devfs: server_end, control_handle: _ } => {
737-
let () = devfs.clone().open(
737+
let flags = fio::PERM_READABLE | fio::Flags::PROTOCOL_DIRECTORY;
738+
// On errors `server_end` will be closed with an epitaph.
739+
let _ = devfs.clone().open3(
738740
vfs::execution_scope::ExecutionScope::new(),
739-
fio::OpenFlags::RIGHT_READABLE | fio::OpenFlags::DIRECTORY,
740741
vfs::path::Path::dot(),
741-
server_end.into_channel().into(),
742+
flags,
743+
&mut vfs::ObjectRequest::new(
744+
flags,
745+
&Default::default(),
746+
server_end.into_channel(),
747+
),
742748
);
743749
}
744750
ManagedRealmRequest::AddDevice { path, device, responder } => {
@@ -922,16 +928,15 @@ impl ManagedRealm {
922928
directory,
923929
control_handle: _,
924930
} => {
925-
let flags = fio::OpenFlags::RIGHT_READABLE | fio::OpenFlags::DIRECTORY;
926-
931+
let flags = fio::PERM_READABLE | fio::Flags::PROTOCOL_DIRECTORY;
927932
realm
928933
.root
929934
.get_exposed_dir()
930-
.open(
931-
flags,
932-
fio::ModeType::empty(),
935+
.open3(
933936
&format!("{child_name}-diagnostics"),
934-
ServerEnd::new(directory.into_channel()),
937+
flags,
938+
&Default::default(),
939+
directory.into_channel(),
935940
)
936941
.context(format!("opening diagnostics dir for {child_name}"))?;
937942
}
@@ -2686,11 +2691,11 @@ mod tests {
26862691

26872692
let (network, server_end) = fidl::endpoints::create_proxy::<fio::DirectoryMarker>();
26882693
let () = devfs
2689-
.open(
2690-
fio::OpenFlags::RIGHT_READABLE | fio::OpenFlags::DIRECTORY,
2691-
fio::ModeType::empty(),
2694+
.open3(
26922695
&ethernet_path,
2693-
server_end.into_channel().into(),
2696+
fio::PERM_READABLE | fio::Flags::PROTOCOL_DIRECTORY,
2697+
&Default::default(),
2698+
server_end.into_channel(),
26942699
)
26952700
.expect("calling open");
26962701
let mut watcher = fvfs_watcher::Watcher::new(&network).await.expect("watcher creation");

src/connectivity/network/testing/network-test-realm/ffx/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ffx_plugin("ffx_net_test_realm") {
1919
]
2020
deps = [
2121
"//sdk/fidl/fuchsia.developer.remotecontrol:fuchsia.developer.remotecontrol_rust",
22-
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
2322
"//sdk/fidl/fuchsia.net:fuchsia.net_rust",
2423
"//sdk/fidl/fuchsia.net.dhcpv6:fuchsia.net.dhcpv6_rust",
2524
"//sdk/fidl/fuchsia.sys2:fuchsia.sys2_rust",

src/connectivity/network/testing/network-test-realm/ffx/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use log::error;
1111
use target_holders::RemoteControlProxyHolder;
1212
use {
1313
ffx_net_test_realm_args as ntr_args, fidl_fuchsia_developer_remotecontrol as fremotecontrol,
14-
fidl_fuchsia_io as fio, fidl_fuchsia_net as fnet, fidl_fuchsia_net_dhcpv6 as fnet_dhcpv6,
14+
fidl_fuchsia_net as fnet, fidl_fuchsia_net_dhcpv6 as fnet_dhcpv6,
1515
fidl_fuchsia_net_dhcpv6_ext as fnet_dhcpv6_ext, fidl_fuchsia_net_ext as fnet_ext,
1616
fidl_fuchsia_net_test_realm as fntr, fidl_fuchsia_sys2 as fsys,
1717
};
@@ -22,12 +22,11 @@ async fn connect_to_protocol<S: fidl::endpoints::DiscoverableProtocolMarker>(
2222
) -> anyhow::Result<S::Proxy> {
2323
let (proxy, server_end) = fidl::endpoints::create_proxy::<S>();
2424
remote_control
25-
.deprecated_open_capability(
25+
.connect_capability(
2626
moniker,
2727
fsys::OpenDirType::ExposedDir,
2828
S::PROTOCOL_NAME,
2929
server_end.into_channel(),
30-
fio::OpenFlags::empty(),
3130
)
3231
.await?
3332
.map_err(|e| {

src/connectivity/wlan/wlandevicemonitor/src/device_watch.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ mod tests {
8787
use vfs::directory::entry_container::Directory;
8888
use vfs::execution_scope::ExecutionScope;
8989
use vfs::path::Path;
90-
use vfs::pseudo_directory;
90+
use vfs::{pseudo_directory, ObjectRequest};
9191
use wlan_common::test_utils::ExpectWithin;
9292

9393
#[fasync::run_singlethreaded(test)]
@@ -152,13 +152,15 @@ mod tests {
152152

153153
fn serve_and_bind_vfs(vfs_dir: Arc<dyn Directory>, path: &'static str) {
154154
let (client, server) = fidl::endpoints::create_endpoints();
155-
let scope = ExecutionScope::new();
156-
vfs_dir.open(
157-
scope.clone(),
158-
fidl_fuchsia_io::OpenFlags::RIGHT_READABLE | fidl_fuchsia_io::OpenFlags::DIRECTORY,
159-
Path::dot(),
160-
fidl::endpoints::ServerEnd::new(server.into_channel()),
161-
);
155+
let flags = fio::PERM_READABLE | fio::Flags::PROTOCOL_DIRECTORY;
156+
vfs_dir
157+
.open3(
158+
ExecutionScope::new(),
159+
Path::dot(),
160+
flags,
161+
&mut ObjectRequest::new(flags, &Default::default(), server.into_channel()),
162+
)
163+
.expect("failed to serve root directory");
162164

163165
let ns = fdio::Namespace::installed().expect("failed to get installed namespace");
164166
ns.bind(path, client).expect("Failed to bind dev in namespace");

0 commit comments

Comments
 (0)