From 6b14cfbf936edc2f663f66e331a5e8011fdb7591 Mon Sep 17 00:00:00 2001
From: Simonas Kazlauskas <git@kazlauskas.me>
Date: Sun, 5 Jul 2020 19:27:54 +0300
Subject: [PATCH] Add some missing fcntl flags for freebsd

---
 libc-test/build.rs                      | 12 ++++++++++++
 src/unix/bsd/freebsdlike/freebsd/mod.rs | 17 +++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/libc-test/build.rs b/libc-test/build.rs
index 48b7d7a2..696f1949 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1762,6 +1762,18 @@ fn test_freebsd(target: &str) {
 
     cfg.skip_const(move |name| {
         match name {
+            // These constants are to be introduced in yet-unreleased FreeBSD 12.2.
+            "F_ADD_SEALS"
+            | "F_GET_SEALS"
+            | "F_SEAL_SEAL"
+            | "F_SEAL_SHRINK"
+            | "F_SEAL_GROW"
+            | "F_SEAL_WRITE"
+                if Some(12) == freebsd_ver =>
+            {
+                true
+            }
+
             // These constants were introduced in FreeBSD 12:
             "SF_USER_READAHEAD"
             | "EVFILT_EMPTY"
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 6b10a95b..f35d2834 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -1154,6 +1154,23 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
 pub const UF_HIDDEN: ::c_ulong = 0x00008000;
 pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
 
+pub const F_OGETLK: ::c_int = 7;
+pub const F_OSETLK: ::c_int = 8;
+pub const F_OSETLKW: ::c_int = 9;
+pub const F_DUP2FD: ::c_int = 10;
+pub const F_SETLK_REMOTE: ::c_int = 14;
+pub const F_READAHEAD: ::c_int = 15;
+pub const F_RDAHEAD: ::c_int = 16;
+pub const F_DUP2FD_CLOEXEC: ::c_int = 18;
+pub const F_ADD_SEALS: ::c_int = 19;
+pub const F_GET_SEALS: ::c_int = 20;
+
+pub const F_SEAL_SEAL: ::c_int = 0x0001;
+pub const F_SEAL_SHRINK: ::c_int = 0x0002;
+pub const F_SEAL_GROW: ::c_int = 0x0004;
+pub const F_SEAL_WRITE: ::c_int = 0x0008;
+
+
 fn _ALIGN(p: usize) -> usize {
     (p + _ALIGNBYTES) & !_ALIGNBYTES
 }
-- 
GitLab