File tree Expand file tree Collapse file tree 2 files changed +23
-10
lines changed
Expand file tree Collapse file tree 2 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -54,17 +54,29 @@ impl Device {
5454 pub ( crate ) fn is_mounted_in_pid_mounts ( & self , pid : rustix:: process:: Pid ) -> Result < bool > {
5555 let output = Command :: new ( "findmnt" )
5656 . arg ( "-N" )
57- . arg ( ( pid. as_raw_nonzero ( ) ) . to_string ( ) )
58- . arg ( "-S" )
59- . arg ( self . path ( ) )
57+ //.arg((pid.as_raw_nonzero()).to_string())
58+ . arg ( "1" )
59+ //.arg("-S")
60+ //.arg("/dev/vdb3")
61+ //.arg(self.path())
62+ . arg ( "--output=SOURCE" )
6063 . output ( )
6164 . expect ( "Failed to execute findmnt" ) ;
6265
66+ // findmnt -N 1 --output=SOURCE
67+
6368 let mounts = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
6469
65- let mounts_present = mounts. is_empty ( ) ;
70+ let mut mounts_present = false ;
71+
72+ if mounts. contains ( & self . path ( ) ) {
73+ //if mounts.contains("/dev/vdb3") {
74+ mounts_present = true ;
75+ }
76+
77+ println ! ( "{mounts}" ) ;
6678
67- Ok ( ! mounts_present)
79+ Ok ( mounts_present)
6880 }
6981
7082 // 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 @@ -162,6 +162,12 @@ pub(crate) fn install_create_rootfs(
162162 // Canonicalize devpath
163163 let devpath: Utf8PathBuf = device. path ( ) . into ( ) ;
164164
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( ) ) ;
168+ anyhow:: bail!( "Device {} is mounted" , device. path( ) )
169+ }
170+
165171 // Handle wiping any existing data
166172 if opts. wipe {
167173 let dev = & opts. device ;
@@ -179,11 +185,6 @@ pub(crate) fn install_create_rootfs(
179185 ) ;
180186 }
181187
182- // Always disallow writing to mounted device
183- if device. is_mounted_in_pid_mounts ( rustix:: process:: getpid ( ) ) . expect ( "Failed to check mountpoints" ) {
184- anyhow:: bail!( "Device {} is mounted" , device. path( ) )
185- }
186-
187188 let run_bootc = Utf8Path :: new ( RUN_BOOTC ) ;
188189 let mntdir = run_bootc. join ( "mounts" ) ;
189190 if mntdir. exists ( ) {
You can’t perform that action at this time.
0 commit comments