File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -489,6 +489,8 @@ pub enum FcntlArg<'a> {
489
489
F_GETPIPE_SZ ,
490
490
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
491
491
F_SETPIPE_SZ ( c_int) ,
492
+ #[ cfg( any( target_os = "netbsd" , target_os = "macos" , target_os = "ios" ) ) ]
493
+ F_GETPATH ( Vec <u8 >) ,
492
494
// TODO: Rest of flags
493
495
}
494
496
@@ -549,6 +551,11 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
549
551
F_GETPIPE_SZ => libc:: fcntl( fd, libc:: F_GETPIPE_SZ ) ,
550
552
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
551
553
F_SETPIPE_SZ ( size) => libc:: fcntl( fd, libc:: F_SETPIPE_SZ , size) ,
554
+ #[ cfg( any( target_os = "netbsd" , target_os = "macos" , target_os = "ios" ) ) ]
555
+ F_GETPATH ( path) => {
556
+ path. resize( libc:: PATH_MAX ) ;
557
+ libc:: fcntl( fd, libc:: F_GETPATH , path. as_ptr( ) )
558
+ } ,
552
559
}
553
560
} ;
554
561
Original file line number Diff line number Diff line change @@ -561,3 +561,21 @@ mod test_posix_fallocate {
561
561
}
562
562
}
563
563
}
564
+
565
+ #[ test]
566
+ #[ cfg( any( target_os = "netbsd" , target_os = "macos" , target_os = "ios" ) ) ]
567
+ mod test_apple_netbsd {
568
+ use nix:: fcntl:: * ;
569
+ use tempfile:: NamedTempFile ;
570
+
571
+ #[ test]
572
+ fn test_path ( ) {
573
+ let mut tmp = NamedTempFile :: new ( ) . unwrap ( ) ;
574
+ let fd = tmp. as_raw_fd ( ) ;
575
+ let mut path: Vec < u8 > = Vec :: new ( ) ;
576
+ let res = fcntl ( fd, FcntlArg :: F_GETPATH ( path) ) . expect ( "get path failed" ) ;
577
+ assert_eq ! (
578
+ path. len( ) > 0
579
+ ) ;
580
+ }
581
+ }
You can’t perform that action at this time.
0 commit comments