From a0e2f199f5c9031f28c0174e43e21276bd595808 Mon Sep 17 00:00:00 2001 From: Sachin Cherian Date: Fri, 24 Dec 2021 11:23:52 +0530 Subject: [PATCH 1/2] Add NetBSD configuration for supported process resources --- src/sys/resource.rs | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/sys/resource.rs b/src/sys/resource.rs index 80473e583c..7f2927b4a0 100644 --- a/src/sys/resource.rs +++ b/src/sys/resource.rs @@ -24,12 +24,15 @@ cfg_if! { } libc_enum! { + /// Types of process resources. + /// /// The Resource enum is platform dependent. Check different platform - /// manuals for more details. Some platform links has been provided for - /// earier reference (non-exhaustive). + /// manuals for more details. Some platform links have been provided for + /// easier reference (non-exhaustive). /// /// * [Linux](https://man7.org/linux/man-pages/man2/getrlimit.2.html) /// * [FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=setrlimit) + /// * [NetBSD](https://man.netbsd.org/setrlimit.2) // linux-gnu uses u_int as resource enum, which is implemented in libc as // well. @@ -49,11 +52,7 @@ libc_enum! { ), repr(i32))] #[non_exhaustive] pub enum Resource { - #[cfg(not(any( - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" - )))] + #[cfg(not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))] #[cfg_attr(docsrs, doc(cfg(all())))] /// The maximum amount (in bytes) of virtual memory the process is /// allowed to map. @@ -83,7 +82,13 @@ libc_enum! { /// this process may establish. RLIMIT_LOCKS, - #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))] + #[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "openbsd", + target_os = "linux", + target_os = "netbsd" + ))] #[cfg_attr(docsrs, doc(cfg(all())))] /// The maximum size (in bytes) which a process may lock into memory /// using the mlock(2) system call. @@ -101,7 +106,13 @@ libc_enum! { /// setpriority or nice. RLIMIT_NICE, - #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))] + #[cfg(any( + target_os = "android", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", + target_os = "linux", + ))] #[cfg_attr(docsrs, doc(cfg(all())))] /// The maximum number of simultaneous processes for this user id. RLIMIT_NPROC, @@ -112,7 +123,12 @@ libc_enum! { /// create. RLIMIT_NPTS, - #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))] + #[cfg(any(target_os = "android", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", + target_os = "linux", + ))] #[cfg_attr(docsrs, doc(cfg(all())))] /// When there is memory pressure and swap is available, prioritize /// eviction of a process' resident pages beyond this amount (in bytes). From 1eeccb942e9cde89d96a927c2a19622b213e4bfd Mon Sep 17 00:00:00 2001 From: Ryan Zoeller Date: Mon, 27 Dec 2021 02:50:55 -0600 Subject: [PATCH 2/2] Add posix_fallocate on DragonFly --- CHANGELOG.md | 2 ++ src/fcntl.rs | 1 + test/test_fcntl.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0d9e1227..6b3075073f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](https://semver.org/). (#[1581](https://github.com/nix-rust/nix/pull/1581)) - Added `sched_setaffinity` and `sched_getaffinity` on DragonFly. (#[1537](https://github.com/nix-rust/nix/pull/1537)) +- Added `posix_fallocate` on DragonFly. + (#[1621](https://github.com/nix-rust/nix/pull/1621)) - Added the `SO_TIMESTAMPING` support (#[1547](https://github.com/nix-rust/nix/pull/1547)) diff --git a/src/fcntl.rs b/src/fcntl.rs index 74d9eb9c38..c02a81a9a6 100644 --- a/src/fcntl.rs +++ b/src/fcntl.rs @@ -749,6 +749,7 @@ mod posix_fadvise { #[cfg(any( target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "emscripten", target_os = "fuchsia", any(target_os = "wasi", target_env = "wasi"), diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index db2acfbf52..b24a49eef5 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -488,6 +488,7 @@ mod test_posix_fadvise { #[cfg(any(target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "emscripten", target_os = "fuchsia", any(target_os = "wasi", target_env = "wasi"),