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 @@ -630,6 +630,25 @@ fn test_f_get_path() {
630
630
) ;
631
631
}
632
632
633
+ #[ cfg( apple_targets) ]
634
+ #[ test]
635
+ fn test_f_preallocate ( ) {
636
+ use nix:: fcntl:: * ;
637
+ use std:: os:: unix:: io:: AsRawFd ;
638
+
639
+ let tmp = NamedTempFile :: new ( ) . unwrap ( ) ;
640
+ let fd = tmp. as_raw_fd ( ) ;
641
+ let mut st: libc:: fstore_t = unsafe { std:: mem:: zeroed ( ) } ;
642
+
643
+ st. fst_flags = libc:: F_ALLOCATECONTIG as libc:: c_uint ;
644
+ st. fst_posmode = libc:: F_PEOFPOSMODE ;
645
+ st. fst_length = 1024 ;
646
+ let res =
647
+ fcntl ( fd, FcntlArg :: F_PREALLOCATE ( & st) ) . expect ( "preallocation failed" ) ;
648
+
649
+ assert_eq ! ( res, 0 ) ;
650
+ }
651
+
633
652
#[ cfg( apple_targets) ]
634
653
#[ test]
635
654
fn test_f_get_path_nofirmlink ( ) {
You can’t perform that action at this time.
0 commit comments