-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
137 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Use of this source code is governed by an MIT-style license that can be found | ||
// in the LICENSE file or at https://opensource.org/licenses/MIT. | ||
|
||
/// A result of the `list_mounts` action. | ||
struct Item { | ||
// Information about the individual filesystem mount. | ||
mount: ospect::fs::Mount, | ||
} | ||
|
||
// Handles invocations of the `list_mounts` action. | ||
pub fn handle<S>(session: &mut S, _: ()) -> crate::session::Result<()> | ||
where | ||
S: crate::session::Session, | ||
{ | ||
let mounts = ospect::fs::mounts() | ||
.map_err(crate::session::Error::action)?; | ||
|
||
for mount in mounts { | ||
let mount = match mount { | ||
Ok(mount) => mount, | ||
Err(error) => { | ||
log::warn!("failed to obtain mount information: {}", error); | ||
continue; | ||
} | ||
}; | ||
|
||
session.reply(Item { | ||
mount, | ||
})?; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
impl crate::response::Item for Item { | ||
|
||
type Proto = rrg_proto::v2::list_mounts::Result; | ||
|
||
fn into_proto(self) -> rrg_proto::v2::list_mounts::Result { | ||
let mut proto = rrg_proto::v2::list_mounts::Result::default(); | ||
proto.set_mount(self.mount.into()); | ||
|
||
proto | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn handle_some_mount() { | ||
let mut session = crate::session::FakeSession::new(); | ||
assert!(handle(&mut session, ()).is_ok()); | ||
|
||
assert!(session.reply_count() > 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Use of this source code is governed by an MIT-style license that can be found | ||
// in the LICENSE file or at https://opensource.org/licenses/MIT. | ||
syntax = "proto3"; | ||
|
||
package rrg.action.list_mounts; | ||
|
||
import "rrg/fs.proto"; | ||
|
||
message Result { | ||
// Information about the individual filesystem mount. | ||
rrg.fs.Mount mount = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters