Advertisement
NLinker

Check if mount okay

Dec 30th, 2019
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.73 KB | None | 0 0
  1. //https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1532a4ff9c699e1ed33cda47e81593b7
  2.  
  3. use std::error::Error;
  4. use tokio::runtime::Runtime;
  5. use tokio::process::{Command, Child};
  6. use std::process::Output;
  7.  
  8. pub fn main() -> Result<(), Box<dyn Error>> {
  9.     let mut rt = Runtime::new().unwrap();
  10.     let answer = rt.block_on(is_mount_point_mounted("/mnt/lustre1"))?;
  11.     println!("answer = {:?}", answer);
  12.     Ok(())
  13. }
  14.  
  15. pub async fn is_mount_point_mounted(mount_point: &str) -> std::io::Result<bool> {
  16.     let process: Child = Command::new("mountpoint")
  17.         .arg("-q")
  18.         .arg(mount_point)
  19.         .spawn()?;
  20.     let output: Output = process.wait_with_output().await?;
  21.     Ok(output.status.success())
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement