add new fcntl operation for freebsd 14.

This commit is contained in:
David CARLIER 2021-12-07 19:10:31 +00:00 committed by David Carlier
parent e81e0685bc
commit ed010bfd38
3 changed files with 67 additions and 0 deletions

View file

@ -2160,6 +2160,9 @@ fn test_freebsd(target: &str) {
// Added in FreeBSD 14.
"PT_COREDUMP" | "PC_ALL" | "PC_COMPRESS" if Some(14) > freebsd_ver => true,
// Added in FreeBSD 14.
"F_KINFO" => true, // FIXME: depends how frequent freebsd 14 is updated on CI, this addition went this week only.
_ => false,
}
});

View file

@ -2978,6 +2978,7 @@ pub const F_OSETLKW: ::c_int = 9;
pub const F_RDAHEAD: ::c_int = 16;
pub const F_READAHEAD: ::c_int = 15;
pub const F_SETLK_REMOTE: ::c_int = 14;
pub const F_KINFO: ::c_int = 22;
// for use with F_ADD_SEALS
pub const F_SEAL_GROW: ::c_int = 4;

View file

@ -93,6 +93,23 @@ s_no_extra_traits! {
#[cfg(libc_union)]
pub a_un: __c_anonymous_elf64_auxv_union,
}
pub struct kinfo_file {
pub kf_structsize: ::c_int,
pub kf_type: ::c_int,
pub kf_fd: ::c_int,
pub kf_ref_count: ::c_int,
pub kf_flags: ::c_int,
_kf_pad0: ::c_int,
pub kf_offset: i64,
_priv: [::uintptr_t; 38], // FIXME if needed
pub kf_status: u16,
_kf_pad1: u16,
_kf_ispare0: ::c_int,
pub kf_cap_rights: ::cap_rights_t,
_kf_cap_spare: u64,
pub kf_path: [::c_char; ::PATH_MAX as usize],
}
}
cfg_if! {
@ -236,6 +253,52 @@ cfg_if! {
.finish()
}
}
impl PartialEq for kinfo_file {
fn eq(&self, other: &kinfo_file) -> bool {
self.kf_structsize == other.kf_structsize &&
self.kf_type == other.kf_type &&
self.kf_fd == other.kf_fd &&
self.kf_ref_count == other.kf_ref_count &&
self.kf_flags == other.kf_flags &&
self.kf_offset == other.kf_offset &&
self.kf_status == other.kf_status &&
self.kf_cap_rights == other.kf_cap_rights &&
self.kf_path
.iter()
.zip(other.kf_path.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for kinfo_file {}
impl ::fmt::Debug for kinfo_file {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("kinfo_file")
.field("kf_structsize", &self.kf_structsize)
.field("kf_type", &self.kf_type)
.field("kf_fd", &self.kf_fd)
.field("kf_ref_count", &self.kf_ref_count)
.field("kf_flags", &self.kf_flags)
.field("kf_offset", &self.kf_offset)
.field("kf_status", &self.kf_status)
.field("kf_cap_rights", &self.kf_cap_rights)
.field("kf_path", &&self.kf_path[..])
.finish()
}
}
impl ::hash::Hash for kinfo_file {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.kf_structsize.hash(state);
self.kf_type.hash(state);
self.kf_fd.hash(state);
self.kf_ref_count.hash(state);
self.kf_flags.hash(state);
self.kf_offset.hash(state);
self.kf_status.hash(state);
self.kf_cap_rights.hash(state);
self.kf_path.hash(state);
}
}
}
}