Skip to content

Commit ed010bf

Browse files
committed
add new fcntl operation for freebsd 14.
1 parent e81e068 commit ed010bf

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

libc-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,9 @@ fn test_freebsd(target: &str) {
21602160
// Added in FreeBSD 14.
21612161
"PT_COREDUMP" | "PC_ALL" | "PC_COMPRESS" if Some(14) > freebsd_ver => true,
21622162

2163+
// Added in FreeBSD 14.
2164+
"F_KINFO" => true, // FIXME: depends how frequent freebsd 14 is updated on CI, this addition went this week only.
2165+
21632166
_ => false,
21642167
}
21652168
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,7 @@ pub const F_OSETLKW: ::c_int = 9;
29782978
pub const F_RDAHEAD: ::c_int = 16;
29792979
pub const F_READAHEAD: ::c_int = 15;
29802980
pub const F_SETLK_REMOTE: ::c_int = 14;
2981+
pub const F_KINFO: ::c_int = 22;
29812982

29822983
// for use with F_ADD_SEALS
29832984
pub const F_SEAL_GROW: ::c_int = 4;

src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ s_no_extra_traits! {
9393
#[cfg(libc_union)]
9494
pub a_un: __c_anonymous_elf64_auxv_union,
9595
}
96+
97+
pub struct kinfo_file {
98+
pub kf_structsize: ::c_int,
99+
pub kf_type: ::c_int,
100+
pub kf_fd: ::c_int,
101+
pub kf_ref_count: ::c_int,
102+
pub kf_flags: ::c_int,
103+
_kf_pad0: ::c_int,
104+
pub kf_offset: i64,
105+
_priv: [::uintptr_t; 38], // FIXME if needed
106+
pub kf_status: u16,
107+
_kf_pad1: u16,
108+
_kf_ispare0: ::c_int,
109+
pub kf_cap_rights: ::cap_rights_t,
110+
_kf_cap_spare: u64,
111+
pub kf_path: [::c_char; ::PATH_MAX as usize],
112+
}
96113
}
97114

98115
cfg_if! {
@@ -236,6 +253,52 @@ cfg_if! {
236253
.finish()
237254
}
238255
}
256+
257+
impl PartialEq for kinfo_file {
258+
fn eq(&self, other: &kinfo_file) -> bool {
259+
self.kf_structsize == other.kf_structsize &&
260+
self.kf_type == other.kf_type &&
261+
self.kf_fd == other.kf_fd &&
262+
self.kf_ref_count == other.kf_ref_count &&
263+
self.kf_flags == other.kf_flags &&
264+
self.kf_offset == other.kf_offset &&
265+
self.kf_status == other.kf_status &&
266+
self.kf_cap_rights == other.kf_cap_rights &&
267+
self.kf_path
268+
.iter()
269+
.zip(other.kf_path.iter())
270+
.all(|(a,b)| a == b)
271+
}
272+
}
273+
impl Eq for kinfo_file {}
274+
impl ::fmt::Debug for kinfo_file {
275+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
276+
f.debug_struct("kinfo_file")
277+
.field("kf_structsize", &self.kf_structsize)
278+
.field("kf_type", &self.kf_type)
279+
.field("kf_fd", &self.kf_fd)
280+
.field("kf_ref_count", &self.kf_ref_count)
281+
.field("kf_flags", &self.kf_flags)
282+
.field("kf_offset", &self.kf_offset)
283+
.field("kf_status", &self.kf_status)
284+
.field("kf_cap_rights", &self.kf_cap_rights)
285+
.field("kf_path", &&self.kf_path[..])
286+
.finish()
287+
}
288+
}
289+
impl ::hash::Hash for kinfo_file {
290+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
291+
self.kf_structsize.hash(state);
292+
self.kf_type.hash(state);
293+
self.kf_fd.hash(state);
294+
self.kf_ref_count.hash(state);
295+
self.kf_flags.hash(state);
296+
self.kf_offset.hash(state);
297+
self.kf_status.hash(state);
298+
self.kf_cap_rights.hash(state);
299+
self.kf_path.hash(state);
300+
}
301+
}
239302
}
240303
}
241304

0 commit comments

Comments
 (0)