@@ -50,24 +50,23 @@ pub struct Findmnt {
50
50
pub filesystems : Vec < Filesystem > ,
51
51
}
52
52
53
- fn run_findmnt ( args : & [ & str ] , path : & str ) -> Result < Findmnt > {
54
- let o: Findmnt = Command :: new ( "findmnt" )
55
- . args ( [
56
- "-J" ,
57
- "-v" ,
58
- // If you change this you probably also want to change the Filesystem struct above
59
- "--output=SOURCE,TARGET,MAJ:MIN,FSTYPE,OPTIONS,UUID" ,
60
- ] )
61
- . args ( args)
62
- . arg ( path)
63
- . log_debug ( )
64
- . run_and_parse_json ( ) ?;
53
+ pub fn run_findmnt ( args : & [ & str ] , path : Option < & str > ) -> Result < Findmnt > {
54
+ let mut cmd = Command :: new ( "findmnt" ) ;
55
+ cmd. args ( [
56
+ "-J" ,
57
+ "-v" ,
58
+ // If you change this you probably also want to change the Filesystem struct above
59
+ "--output=SOURCE,TARGET,MAJ:MIN,FSTYPE,OPTIONS,UUID" ,
60
+ ] )
61
+ . args ( args)
62
+ . args ( path) ;
63
+ let o: Findmnt = cmd. log_debug ( ) . run_and_parse_json ( ) ?;
65
64
Ok ( o)
66
65
}
67
66
68
67
// Retrieve a mounted filesystem from a device given a matching path
69
68
fn findmnt_filesystem ( args : & [ & str ] , path : & str ) -> Result < Filesystem > {
70
- let o = run_findmnt ( args, path) ?;
69
+ let o = run_findmnt ( args, Some ( path) ) ?;
71
70
o. filesystems
72
71
. into_iter ( )
73
72
. next ( )
@@ -90,7 +89,7 @@ pub fn inspect_filesystem_by_uuid(uuid: &str) -> Result<Filesystem> {
90
89
// Check if a specified device contains an already mounted filesystem
91
90
// in the root mount namespace
92
91
pub fn is_mounted_in_pid1_mountns ( path : & str ) -> Result < bool > {
93
- let o = run_findmnt ( & [ "-N" ] , "1" ) ?;
92
+ let o = run_findmnt ( & [ "-N" ] , Some ( "1" ) ) ?;
94
93
95
94
let mounted = o. filesystems . iter ( ) . any ( |fs| is_source_mounted ( path, fs) ) ;
96
95
0 commit comments