Skip to content

Commit

Permalink
Merge #1596 #1621
Browse files Browse the repository at this point in the history
1596: Add NetBSD configuration for supported process resources r=asomers a=schctl

In addition to existing resources, NetBSD supports `RLIMIT_MEMLOCK`, `RLIMIT_NPROC` and `RLIMIT_RSS`.

https://man.netbsd.org/setrlimit.2

`RLIMIT_AS` is also supported, but it looks like it was added [after version 5.0](https://mail-index.netbsd.org/tech-kern/2009/03/28/msg004702.html), so I'm not sure if that should be enabled.

1621: Add posix_fallocate on DragonFly r=asomers a=rtzoeller

Enable the existing `posix_fallocate()` tests as they are passing locally.

Co-authored-by: Sachin Cherian <sachinctl@protonmail.com>
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
  • Loading branch information
3 people authored Dec 27, 2021
3 parents 83cd1da + a0e2f19 + 1eeccb9 commit 2043bce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
36 changes: 26 additions & 10 deletions src/sys/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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).
Expand Down
1 change: 1 addition & 0 deletions test/test_fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 2043bce

Please sign in to comment.