NLinker icon

Check if mount okay

NLinker | PRO | 12/30/19 08:13:04 PM UTC | 0 ⭐ | 8133 👁️ | Never ⏰ | []
Rust |

730 B

|

None

|

0 👍

/

0 👎

//https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1532a4ff9c699e1ed33cda47e81593b7
 
use std::error::Error;
use tokio::runtime::Runtime;
use tokio::process::{Command, Child};
use std::process::Output;
 
pub fn main() -> Result<(), Box<dyn Error>> {
    let mut rt = Runtime::new().unwrap();
    let answer = rt.block_on(is_mount_point_mounted("/mnt/lustre1"))?;
    println!("answer = {:?}", answer);
    Ok(())
}
 
pub async fn is_mount_point_mounted(mount_point: &str) -> std::io::Result<bool> {
    let process: Child = Command::new("mountpoint")
        .arg("-q")
        .arg(mount_point)
        .spawn()?;
    let output: Output = process.wait_with_output().await?;
    Ok(output.status.success())
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎