Skip to content

Commit 91d57d8

Browse files
committed
Enable fcntl OFD commands on macOS
This PR adds support for Open File Description (OFD) fcntl commands on macOS. The implementation uses the upstream libc crate which now includes the required constants that were previously only available in a fork. Changes: - Added macOS OFD fcntl command support in src/fcntl.rs - Updated sys/select.rs with improved file descriptor handling - Fixed type casting issues in test_select.rs
1 parent 09d66fe commit 91d57d8

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

changelog/2300.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `F_OFD_SETLK`, `F_OFD_SETLKW`, and `F_OFD_GETLK` fcntl commands on macOS

src/fcntl.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,15 @@ pub enum FcntlArg<'a> {
751751
/// Get the first lock that blocks the lock description
752752
F_GETLK(&'a mut libc::flock),
753753
/// Acquire or release an open file description lock
754-
#[cfg(linux_android)]
754+
#[cfg(any(linux_android, macos))]
755755
F_OFD_SETLK(&'a libc::flock),
756756
/// Like [`F_OFD_SETLK`] except that if a conflicting lock is held on
757757
/// the file, then wait for that lock to be released.
758-
#[cfg(linux_android)]
758+
#[cfg(any(linux_android, macos))]
759759
F_OFD_SETLKW(&'a libc::flock),
760760
/// Determine whether it would be possible to create the given lock. If not, return details
761761
/// about one existing lock that would prevent it.
762-
#[cfg(linux_android)]
762+
#[cfg(any(linux_android, macos))]
763763
F_OFD_GETLK(&'a mut libc::flock),
764764
/// Add seals to the file
765765
#[cfg(any(
@@ -879,11 +879,11 @@ pub fn fcntl<Fd: std::os::fd::AsFd>(fd: Fd, arg: FcntlArg) -> Result<c_int> {
879879
F_SETLKW(flock) => libc::fcntl(fd, libc::F_SETLKW, flock),
880880
#[cfg(not(target_os = "redox"))]
881881
F_GETLK(flock) => libc::fcntl(fd, libc::F_GETLK, flock),
882-
#[cfg(linux_android)]
882+
#[cfg(any(linux_android, macos))]
883883
F_OFD_SETLK(flock) => libc::fcntl(fd, libc::F_OFD_SETLK, flock),
884-
#[cfg(linux_android)]
884+
#[cfg(any(linux_android, macos))]
885885
F_OFD_SETLKW(flock) => libc::fcntl(fd, libc::F_OFD_SETLKW, flock),
886-
#[cfg(linux_android)]
886+
#[cfg(any(linux_android, macos))]
887887
F_OFD_GETLK(flock) => libc::fcntl(fd, libc::F_OFD_GETLK, flock),
888888
#[cfg(any(
889889
linux_android,

src/sys/select.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::errno::Errno;
33
use crate::sys::time::{TimeSpec, TimeVal};
44
use crate::Result;
55
use libc::{self, c_int};
6-
use std::convert::TryFrom;
76
use std::iter::FusedIterator;
87
use std::mem;
98
use std::ops::Range;

test/test_sendfile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ fn test_sendfile_dragonfly() {
159159
fn test_sendfile_darwin() {
160160
// Declare the content
161161
let header_strings =
162-
vec!["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
162+
["HTTP/1.1 200 OK\n", "Content-Type: text/plain\n", "\n"];
163163
let body = "Xabcdef123456";
164164
let body_offset = 1;
165-
let trailer_strings = vec!["\n", "Served by Make Believe\n"];
165+
let trailer_strings = ["\n", "Served by Make Believe\n"];
166166

167167
// Write the body to a file
168168
let mut tmp = tempfile().unwrap();

0 commit comments

Comments
 (0)