Skip to content

Commit f7ae9fe

Browse files
committed
fcntl adding few apple extensions
1 parent 6906a61 commit f7ae9fe

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/fcntl.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,16 @@ pub enum FcntlArg<'a> {
499499
F_GET_SEALS,
500500
#[cfg(any(target_os = "macos", target_os = "ios"))]
501501
F_FULLFSYNC,
502+
#[cfg(any(target_os = "macos", target_os = "ios"))]
503+
F_BARRIERFSYNC,
502504
#[cfg(any(target_os = "linux", target_os = "android"))]
503505
F_GETPIPE_SZ,
504506
#[cfg(any(target_os = "linux", target_os = "android"))]
505507
F_SETPIPE_SZ(c_int),
506508
#[cfg(any(target_os = "netbsd", target_os = "dragonfly", target_os = "macos", target_os = "ios"))]
507509
F_GETPATH(&'a mut PathBuf),
510+
#[cfg(any(target_os = "macos", target_os = "ios"))]
511+
F_GETPATH_NOFIRMLINK(&'a mut PathBuf),
508512
// TODO: Rest of flags
509513
}
510514

@@ -561,6 +565,8 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
561565
F_GET_SEALS => libc::fcntl(fd, libc::F_GET_SEALS),
562566
#[cfg(any(target_os = "macos", target_os = "ios"))]
563567
F_FULLFSYNC => libc::fcntl(fd, libc::F_FULLFSYNC),
568+
#[cfg(any(target_os = "macos", target_os = "ios"))]
569+
F_BARRIERFSYNC => libc::fcntl(fd, libc::F_BARRIERFSYNC),
564570
#[cfg(any(target_os = "linux", target_os = "android"))]
565571
F_GETPIPE_SZ => libc::fcntl(fd, libc::F_GETPIPE_SZ),
566572
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -574,6 +580,15 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
574580
*path = PathBuf::from(OsString::from(optr.to_str().unwrap()));
575581
return Ok(ok_res)
576582
},
583+
#[cfg(any(target_os = "macos", target_os = "ios"))]
584+
F_GETPATH_NOFIRMLINK(path) => {
585+
let mut buffer = vec![0; libc::PATH_MAX as usize];
586+
let res = libc::fcntl(fd, libc::F_GETPATH_NOFIRMLINK, buffer.as_mut_ptr());
587+
let ok_res = Errno::result(res)?;
588+
let optr = CStr::from_bytes_until_nul(&buffer).unwrap();
589+
*path = PathBuf::from(OsString::from(optr.to_str().unwrap()));
590+
return Ok(ok_res)
591+
},
577592
}
578593
};
579594

0 commit comments

Comments
 (0)