Skip to content

Commit ebe84c2

Browse files
committed
fcntl adding few apple extensions
1 parent e7c877a commit ebe84c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/fcntl.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ pub enum FcntlArg<'a> {
503503
F_GET_SEALS,
504504
#[cfg(any(target_os = "macos", target_os = "ios"))]
505505
F_FULLFSYNC,
506+
#[cfg(any(target_os = "macos", target_os = "ios"))]
507+
F_BARRIERFSYNC,
506508
#[cfg(any(target_os = "linux", target_os = "android"))]
507509
F_GETPIPE_SZ,
508510
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -511,6 +513,8 @@ pub enum FcntlArg<'a> {
511513
F_GETPATH(&'a mut PathBuf),
512514
#[cfg(all(target_os = "freebsd", target_arch = "x86_64"))]
513515
F_KINFO(&'a mut PathBuf),
516+
#[cfg(any(target_os = "macos", target_os = "ios"))]
517+
F_GETPATH_NOFIRMLINK(&'a mut PathBuf),
514518
// TODO: Rest of flags
515519
}
516520

@@ -567,6 +571,8 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
567571
F_GET_SEALS => libc::fcntl(fd, libc::F_GET_SEALS),
568572
#[cfg(any(target_os = "macos", target_os = "ios"))]
569573
F_FULLFSYNC => libc::fcntl(fd, libc::F_FULLFSYNC),
574+
#[cfg(any(target_os = "macos", target_os = "ios"))]
575+
F_BARRIERFSYNC => libc::fcntl(fd, libc::F_BARRIERFSYNC),
570576
#[cfg(any(target_os = "linux", target_os = "android"))]
571577
F_GETPIPE_SZ => libc::fcntl(fd, libc::F_GETPIPE_SZ),
572578
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -589,6 +595,13 @@ pub fn fcntl(fd: RawFd, arg: FcntlArg) -> Result<c_int> {
589595
let p = info.kf_path;
590596
let u8_slice = slice::from_raw_parts(p.as_ptr().cast(), p.len());
591597
let optr = CStr::from_bytes_until_nul(u8_slice).unwrap();
598+
},
599+
#[cfg(any(target_os = "macos", target_os = "ios"))]
600+
F_GETPATH_NOFIRMLINK(path) => {
601+
let mut buffer = vec![0; libc::PATH_MAX as usize];
602+
let res = libc::fcntl(fd, libc::F_GETPATH_NOFIRMLINK, buffer.as_mut_ptr());
603+
let ok_res = Errno::result(res)?;
604+
let optr = CStr::from_bytes_until_nul(&buffer).unwrap();
592605
*path = PathBuf::from(OsString::from(optr.to_str().unwrap()));
593606
return Ok(ok_res)
594607
},

0 commit comments

Comments
 (0)