@@ -17,8 +17,6 @@ use std::fmt::Display;
1717#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
1818use std:: os:: unix:: io:: AsRawFd ;
1919#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
20- use std:: os:: unix:: process:: CommandExt ;
21- #[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
2220use std:: path:: Path ;
2321
2422/// The prefix we apply to our temporary files.
@@ -274,20 +272,12 @@ pub(crate) struct ApplyUpdateOptions {
274272// Let's just fork off a helper process for now.
275273#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
276274pub ( crate ) fn syncfs ( d : & openat:: Dir ) -> Result < ( ) > {
277- let d = d. sub_dir ( "." ) . expect ( "subdir" ) ;
278- let mut c = std:: process:: Command :: new ( "sync" ) ;
279- let c = c. args ( [ "-f" , "." ] ) ;
280- unsafe {
281- c. pre_exec ( move || {
282- nix:: unistd:: fchdir ( d. as_raw_fd ( ) ) . expect ( "fchdir" ) ;
283- Ok ( ( ) )
284- } )
285- } ;
286- let r = c. status ( ) . context ( "syncfs failed" ) ?;
287- if !r. success ( ) {
288- bail ! ( "syncfs failed" ) ;
289- }
290- Ok ( ( ) )
275+ use rustix:: fd:: BorrowedFd ;
276+ use rustix:: fs:: { Mode , OFlags } ;
277+ let d = unsafe { BorrowedFd :: borrow_raw ( d. as_raw_fd ( ) ) } ;
278+ let oflags = OFlags :: RDONLY | OFlags :: CLOEXEC | OFlags :: DIRECTORY ;
279+ let d = rustix:: fs:: openat ( d, "." , oflags, Mode :: empty ( ) ) ?;
280+ rustix:: fs:: syncfs ( d) . map_err ( Into :: into)
291281}
292282
293283#[ cfg( any( target_arch = "x86_64" , target_arch = "aarch64" ) ) ]
0 commit comments