File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -692,6 +692,9 @@ pub enum FcntlArg<'a> {
692
692
/// Return the full path without firmlinks of the fd.
693
693
#[ cfg( apple_targets) ]
694
694
F_GETPATH_NOFIRMLINK ( & ' a mut PathBuf ) ,
695
+ /// Pre-allocate storage with different policies on fd.
696
+ #[ cfg( apple_targets) ]
697
+ F_PREALLOCATE ( & ' a libc:: fstore_t) ,
695
698
// TODO: Rest of flags
696
699
}
697
700
@@ -797,6 +800,10 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
797
800
* path = PathBuf :: from( OsString :: from( optr. to_str( ) . unwrap( ) ) ) ;
798
801
return Ok ( ok_res)
799
802
} ,
803
+ #[ cfg( apple_targets) ]
804
+ F_PREALLOCATE ( st) => {
805
+ libc:: fcntl( fd, libc:: F_PREALLOCATE , st)
806
+ } ,
800
807
}
801
808
} ;
802
809
Original file line number Diff line number Diff line change @@ -626,6 +626,25 @@ fn test_f_get_path() {
626
626
) ;
627
627
}
628
628
629
+ #[ cfg( apple_targets) ]
630
+ #[ test]
631
+ fn test_f_preallocate ( ) {
632
+ use nix:: fcntl:: * ;
633
+ use std:: os:: unix:: io:: AsRawFd ;
634
+
635
+ let tmp = NamedTempFile :: new ( ) . unwrap ( ) ;
636
+ let fd = tmp. as_raw_fd ( ) ;
637
+ let mut st: libc:: fstore_t = unsafe { std:: mem:: zeroed ( ) } ;
638
+
639
+ st. fst_flags = libc:: F_ALLOCATECONTIG as libc:: c_uint ;
640
+ st. fst_posmode = libc:: F_PEOFPOSMODE ;
641
+ st. fst_length = 1024 ;
642
+ let res =
643
+ fcntl ( fd, FcntlArg :: F_PREALLOCATE ( & st) ) . expect ( "preallocation failed" ) ;
644
+
645
+ assert_eq ! ( res, 0 ) ;
646
+ }
647
+
629
648
#[ cfg( apple_targets) ]
630
649
#[ test]
631
650
fn test_f_get_path_nofirmlink ( ) {
You can’t perform that action at this time.
0 commit comments