@@ -193,9 +193,13 @@ feature! {
193193
194194// The conversion is not identical on all operating systems.
195195#[ allow( clippy:: useless_conversion) ]
196- pub fn open<P : ?Sized + NixPath >( path: & P , oflag: OFlag , mode: Mode ) -> Result <RawFd > {
197- let fd = path. with_nix_path( |cstr| {
198- unsafe { libc:: open( cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint) }
196+ pub fn open<P : ?Sized + NixPath >(
197+ path: & P ,
198+ oflag: OFlag ,
199+ mode: Mode ,
200+ ) -> Result <RawFd > {
201+ let fd = path. with_nix_path( |cstr| unsafe {
202+ libc:: open( cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint)
199203 } ) ?;
200204
201205 Errno :: result( fd)
@@ -210,8 +214,8 @@ pub fn openat<P: ?Sized + NixPath>(
210214 oflag: OFlag ,
211215 mode: Mode ,
212216) -> Result <RawFd > {
213- let fd = path. with_nix_path( |cstr| {
214- unsafe { libc:: openat( dirfd, cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint) }
217+ let fd = path. with_nix_path( |cstr| unsafe {
218+ libc:: openat( dirfd, cstr. as_ptr( ) , oflag. bits( ) , mode. bits( ) as c_uint)
215219 } ) ?;
216220 Errno :: result( fd)
217221}
@@ -303,7 +307,10 @@ fn readlink_maybe_at<P: ?Sized + NixPath>(
303307 } )
304308}
305309
306- fn inner_readlink<P : ?Sized + NixPath >( dirfd: Option <RawFd >, path: & P ) -> Result <OsString > {
310+ fn inner_readlink<P : ?Sized + NixPath >(
311+ dirfd: Option <RawFd >,
312+ path: & P ,
313+ ) -> Result <OsString > {
307314 let mut v = Vec :: with_capacity( libc:: PATH_MAX as usize ) ;
308315
309316 {
@@ -387,7 +394,10 @@ pub fn readlink<P: ?Sized + NixPath>(path: &P) -> Result<OsString> {
387394}
388395
389396#[ cfg( not( target_os = "redox" ) ) ]
390- pub fn readlinkat<P : ?Sized + NixPath >( dirfd: RawFd , path: & P ) -> Result <OsString > {
397+ pub fn readlinkat<P : ?Sized + NixPath >(
398+ dirfd: RawFd ,
399+ path: & P ,
400+ ) -> Result <OsString > {
391401 inner_readlink( Some ( dirfd) , path)
392402}
393403
@@ -450,9 +460,17 @@ pub enum FcntlArg<'a> {
450460 F_OFD_SETLKW ( & ' a libc:: flock) ,
451461 #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
452462 F_OFD_GETLK ( & ' a mut libc:: flock) ,
453- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
463+ #[ cfg( any(
464+ target_os = "android" ,
465+ target_os = "linux" ,
466+ target_os = "freebsd"
467+ ) ) ]
454468 F_ADD_SEALS ( SealFlag ) ,
455- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
469+ #[ cfg( any(
470+ target_os = "android" ,
471+ target_os = "linux" ,
472+ target_os = "freebsd"
473+ ) ) ]
456474 F_GET_SEALS ,
457475 #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
458476 F_FULLFSYNC ,
@@ -481,7 +499,9 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
481499 let res = unsafe {
482500 match arg {
483501 F_DUPFD ( rawfd) => libc:: fcntl( fd, libc:: F_DUPFD , rawfd) ,
484- F_DUPFD_CLOEXEC ( rawfd) => libc:: fcntl( fd, libc:: F_DUPFD_CLOEXEC , rawfd) ,
502+ F_DUPFD_CLOEXEC ( rawfd) => {
503+ libc:: fcntl( fd, libc:: F_DUPFD_CLOEXEC , rawfd)
504+ }
485505 F_GETFD => libc:: fcntl( fd, libc:: F_GETFD ) ,
486506 F_SETFD ( flag) => libc:: fcntl( fd, libc:: F_SETFD , flag. bits( ) ) ,
487507 F_GETFL => libc:: fcntl( fd, libc:: F_GETFL ) ,
@@ -498,9 +518,19 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
498518 F_OFD_SETLKW ( flock) => libc:: fcntl( fd, libc:: F_OFD_SETLKW , flock) ,
499519 #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
500520 F_OFD_GETLK ( flock) => libc:: fcntl( fd, libc:: F_OFD_GETLK , flock) ,
501- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
502- F_ADD_SEALS ( flag) => libc:: fcntl( fd, libc:: F_ADD_SEALS , flag. bits( ) ) ,
503- #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "freebsd" ) ) ]
521+ #[ cfg( any(
522+ target_os = "android" ,
523+ target_os = "linux" ,
524+ target_os = "freebsd"
525+ ) ) ]
526+ F_ADD_SEALS ( flag) => {
527+ libc:: fcntl( fd, libc:: F_ADD_SEALS , flag. bits( ) )
528+ }
529+ #[ cfg( any(
530+ target_os = "android" ,
531+ target_os = "linux" ,
532+ target_os = "freebsd"
533+ ) ) ]
504534 F_GET_SEALS => libc:: fcntl( fd, libc:: F_GET_SEALS ) ,
505535 #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
506536 F_FULLFSYNC => libc:: fcntl( fd, libc:: F_FULLFSYNC ) ,
@@ -535,8 +565,12 @@ pub fn flock(fd: RawFd, arg: FlockArg) -> Result<()> {
535565 LockShared => libc:: flock( fd, libc:: LOCK_SH ) ,
536566 LockExclusive => libc:: flock( fd, libc:: LOCK_EX ) ,
537567 Unlock => libc:: flock( fd, libc:: LOCK_UN ) ,
538- LockSharedNonblock => libc:: flock( fd, libc:: LOCK_SH | libc:: LOCK_NB ) ,
539- LockExclusiveNonblock => libc:: flock( fd, libc:: LOCK_EX | libc:: LOCK_NB ) ,
568+ LockSharedNonblock => {
569+ libc:: flock( fd, libc:: LOCK_SH | libc:: LOCK_NB )
570+ }
571+ LockExclusiveNonblock => {
572+ libc:: flock( fd, libc:: LOCK_EX | libc:: LOCK_NB )
573+ }
540574 UnlockNonblock => libc:: flock( fd, libc:: LOCK_UN | libc:: LOCK_NB ) ,
541575 }
542576 } ;
@@ -632,12 +666,19 @@ pub fn splice(
632666 . map( |offset| offset as * mut libc:: loff_t)
633667 . unwrap_or( ptr:: null_mut( ) ) ;
634668
635- let ret = unsafe { libc:: splice( fd_in, off_in, fd_out, off_out, len, flags. bits( ) ) } ;
669+ let ret = unsafe {
670+ libc:: splice( fd_in, off_in, fd_out, off_out, len, flags. bits( ) )
671+ } ;
636672 Errno :: result( ret) . map( |r| r as usize )
637673}
638674
639675#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
640- pub fn tee( fd_in: RawFd , fd_out: RawFd , len: usize , flags: SpliceFFlags ) -> Result <usize > {
676+ pub fn tee(
677+ fd_in: RawFd ,
678+ fd_out: RawFd ,
679+ len: usize ,
680+ flags: SpliceFFlags ,
681+ ) -> Result <usize > {
641682 let ret = unsafe { libc:: tee( fd_in, fd_out, len, flags. bits( ) ) } ;
642683 Errno :: result( ret) . map( |r| r as usize )
643684}
@@ -646,9 +687,8 @@ pub fn tee(fd_in: RawFd, fd_out: RawFd, len: usize, flags: SpliceFFlags) -> Resu
646687pub fn vmsplice(
647688 fd: RawFd ,
648689 iov: & [ std:: io:: IoSlice <' _>] ,
649- flags: SpliceFFlags
650- ) -> Result <usize >
651- {
690+ flags: SpliceFFlags ,
691+ ) -> Result <usize > {
652692 let ret = unsafe {
653693 libc:: vmsplice(
654694 fd,
@@ -778,14 +818,19 @@ impl SpacectlRange {
778818/// ```
779819 #[ cfg( target_os = "freebsd" ) ]
780820pub fn fspacectl( fd: RawFd , range: SpacectlRange ) -> Result <SpacectlRange > {
781- let mut rqsr = libc:: spacectl_range{ r_offset: range. 0 , r_len: range. 1 } ;
782- let res = unsafe { libc:: fspacectl(
821+ let mut rqsr = libc:: spacectl_range {
822+ r_offset: range. 0 ,
823+ r_len: range. 1 ,
824+ } ;
825+ let res = unsafe {
826+ libc:: fspacectl(
783827 fd,
784828 libc:: SPACECTL_DEALLOC , // Only one command is supported ATM
785829 & rqsr,
786- 0 , // No flags are currently supported
787- & mut rqsr
788- ) } ;
830+ 0 , // No flags are currently supported
831+ & mut rqsr,
832+ )
833+ } ;
789834 Errno :: result( res) . map( |_| SpacectlRange ( rqsr. r_offset, rqsr. r_len) )
790835}
791836
@@ -820,18 +865,25 @@ pub fn fspacectl(fd: RawFd, range: SpacectlRange) -> Result<SpacectlRange> {
820865/// assert_eq!(buf, b"012\0\0\0\0\0\09abcdef");
821866/// ```
822867 #[ cfg( target_os = "freebsd" ) ]
823- pub fn fspacectl_all( fd: RawFd , offset: libc:: off_t, len: libc:: off_t)
824- -> Result <( ) >
825- {
826- let mut rqsr = libc:: spacectl_range{ r_offset: offset, r_len: len} ;
868+ pub fn fspacectl_all(
869+ fd: RawFd ,
870+ offset: libc:: off_t,
871+ len: libc:: off_t,
872+ ) -> Result <( ) > {
873+ let mut rqsr = libc:: spacectl_range {
874+ r_offset: offset,
875+ r_len: len,
876+ } ;
827877 while rqsr. r_len > 0 {
828- let res = unsafe { libc:: fspacectl(
878+ let res = unsafe {
879+ libc:: fspacectl(
829880 fd,
830881 libc:: SPACECTL_DEALLOC , // Only one command is supported ATM
831882 & rqsr,
832- 0 , // No flags are currently supported
833- & mut rqsr
834- ) } ;
883+ 0 , // No flags are currently supported
884+ & mut rqsr,
885+ )
886+ } ;
835887 Errno :: result( res) ?;
836888 }
837889 Ok ( ( ) )
@@ -848,8 +900,8 @@ pub fn fspacectl_all(fd: RawFd, offset: libc::off_t, len: libc::off_t)
848900) ) ]
849901mod posix_fadvise {
850902 use crate :: errno:: Errno ;
851- use std:: os:: unix:: io:: RawFd ;
852903 use crate :: Result ;
904+ use std:: os:: unix:: io:: RawFd ;
853905
854906 #[ cfg( feature = "fs" ) ]
855907 libc_enum! {
@@ -894,7 +946,11 @@ mod posix_fadvise {
894946 target_os = "wasi" ,
895947 target_os = "freebsd"
896948) ) ]
897- pub fn posix_fallocate( fd: RawFd , offset: libc:: off_t, len: libc:: off_t) -> Result <( ) > {
949+ pub fn posix_fallocate(
950+ fd: RawFd ,
951+ offset: libc:: off_t,
952+ len: libc:: off_t,
953+ ) -> Result <( ) > {
898954 let res = unsafe { libc:: posix_fallocate( fd, offset, len) } ;
899955 match Errno :: result( res) {
900956 Err ( err) => Err ( err) ,
0 commit comments