Skip to content

Commit 375b30d

Browse files
antoncxxtgross35
authored andcommitted
FreeBSD: Added xfile structe and file descriptor types
1 parent 82b7480 commit 375b30d

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,6 +2747,9 @@ fn test_freebsd(target: &str) {
27472747
// Added in FreeBSD 15
27482748
"AT_HWCAP3" | "AT_HWCAP4" if Some(15) > freebsd_ver => true,
27492749

2750+
// Added in FreeBSD 15
2751+
"DTYPE_INOTIFY" | "DTYPE_JAILDESC" if Some(15) > freebsd_ver => true,
2752+
27502753
_ => false,
27512754
}
27522755
});

libc-test/semver/freebsd.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,4 +2425,5 @@ vmtotal
24252425
wait4
24262426
waitid
24272427
xallocx
2428+
xfile
24282429
xucred

src/new/freebsd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
//! * Headers: <https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/include/ucontext.h>
44
//! * Symbol map: <https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/Symbol.map>
55
6+
pub(crate) mod sys;
67
pub(crate) mod unistd;

src/new/freebsd/sys/file.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//! Header: `sys/file.h`
2+
//!
3+
//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/file.h
4+
5+
use crate::prelude::*;
6+
7+
pub const DTYPE_NONE: c_int = 0;
8+
pub const DTYPE_VNODE: c_int = 1;
9+
pub const DTYPE_SOCKET: c_int = 2;
10+
pub const DTYPE_PIPE: c_int = 3;
11+
pub const DTYPE_FIFO: c_int = 4;
12+
pub const DTYPE_KQUEUE: c_int = 5;
13+
pub const DTYPE_CRYPTO: c_int = 6;
14+
pub const DTYPE_MQUEUE: c_int = 7;
15+
pub const DTYPE_SHM: c_int = 8;
16+
pub const DTYPE_SEM: c_int = 9;
17+
pub const DTYPE_PTS: c_int = 10;
18+
pub const DTYPE_DEV: c_int = 11;
19+
pub const DTYPE_PROCDESC: c_int = 12;
20+
pub const DTYPE_EVENTFD: c_int = 13;
21+
pub const DTYPE_TIMERFD: c_int = 14;
22+
pub const DTYPE_INOTIFY: c_int = 15;
23+
pub const DTYPE_JAILDESC: c_int = 16;
24+
25+
s! {
26+
#[cfg(not(any(freebsd10, freebsd11)))]
27+
pub struct xfile {
28+
pub xf_size: crate::ksize_t,
29+
pub xf_pid: crate::pid_t,
30+
pub xf_uid: crate::uid_t,
31+
pub xf_fd: c_int,
32+
_xf_int_pad1: Padding<c_int>,
33+
pub xf_file: crate::kvaddr_t,
34+
pub xf_type: c_short,
35+
_xf_short_pad1: Padding<c_short>,
36+
pub xf_count: c_int,
37+
pub xf_msgcount: c_int,
38+
_xf_int_pad2: Padding<c_int>,
39+
pub xf_offset: crate::off_t,
40+
pub xf_data: crate::kvaddr_t,
41+
pub xf_vnode: crate::kvaddr_t,
42+
pub xf_flag: c_uint,
43+
_xf_int_pad3: Padding<c_int>,
44+
_xf_int64_pad: Padding<[i64; 6]>,
45+
}
46+
}

src/new/freebsd/sys/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Directory: `sys/`
2+
//!
3+
//! https://github.com/freebsd/freebsd-src/tree/main/sys/sys'
4+
5+
pub(crate) mod file;

src/new/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ cfg_if! {
211211
} else if #[cfg(target_os = "nto")] {
212212
pub use net::bpf::*;
213213
pub use net::if_::*;
214+
} else if #[cfg(target_os = "freebsd")] {
215+
pub use sys::file::*;
214216
}
215217
}
216218

0 commit comments

Comments
 (0)