File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -50,33 +50,22 @@ impl Device {
50
50
self . children . as_ref ( ) . map_or ( false , |v| !v. is_empty ( ) )
51
51
}
52
52
53
- // I know I can pretty this up, very much a wip
54
- pub ( crate ) fn is_mounted_in_pid_mounts ( & self , pid : rustix :: process :: Pid ) -> Result < bool > {
53
+ // Return true if device is mounted anywhere
54
+ pub ( crate ) fn is_mounted_in_pid_mounts ( & self ) -> Result < bool > {
55
55
let output = Command :: new ( "findmnt" )
56
56
. arg ( "-N" )
57
- //.arg((pid.as_raw_nonzero()).to_string())
58
57
. arg ( "1" )
59
- //.arg("-S")
60
- //.arg("/dev/vdb3")
61
- //.arg(self.path())
62
58
. arg ( "--output=SOURCE" )
63
59
. output ( )
64
60
. expect ( "Failed to execute findmnt" ) ;
65
61
66
- // findmnt -N 1 --output=SOURCE
67
-
68
62
let mounts = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
69
63
70
- let mut mounts_present = false ;
71
-
72
64
if mounts. contains ( & self . path ( ) ) {
73
- //if mounts.contains("/dev/vdb3") {
74
- mounts_present = true ;
65
+ return Ok ( true ) ;
75
66
}
76
67
77
- println ! ( "{mounts}" ) ;
78
-
79
- Ok ( mounts_present)
68
+ Ok ( false )
80
69
}
81
70
82
71
// The "start" parameter was only added in a version of util-linux that's only
Original file line number Diff line number Diff line change @@ -163,8 +163,10 @@ pub(crate) fn install_create_rootfs(
163
163
let devpath: Utf8PathBuf = device. path ( ) . into ( ) ;
164
164
165
165
// Always disallow writing to mounted device
166
- if device. is_mounted_in_pid_mounts ( rustix:: process:: getpid ( ) ) . expect ( "Failed to check mountpoints" ) {
167
- println ! ( "{:?}" , rustix:: process:: getpid( ) ) ;
166
+ if device
167
+ . is_mounted_in_pid_mounts ( )
168
+ . expect ( "Failed to check mountpoints" )
169
+ {
168
170
anyhow:: bail!( "Device {} is mounted" , device. path( ) )
169
171
}
170
172
You can’t perform that action at this time.
0 commit comments