Skip to content

Commit 2043bce

Browse files
bors[bot]schctlrtzoeller
authored
Merge #1596 #1621
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 <[email protected]> Co-authored-by: Ryan Zoeller <[email protected]>
3 parents 83cd1da + a0e2f19 + 1eeccb9 commit 2043bce

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1919
(#[1581](https://github.com/nix-rust/nix/pull/1581))
2020
- Added `sched_setaffinity` and `sched_getaffinity` on DragonFly.
2121
(#[1537](https://github.com/nix-rust/nix/pull/1537))
22+
- Added `posix_fallocate` on DragonFly.
23+
(#[1621](https://github.com/nix-rust/nix/pull/1621))
2224
- Added the `SO_TIMESTAMPING` support
2325
(#[1547](https://github.com/nix-rust/nix/pull/1547))
2426

src/fcntl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ mod posix_fadvise {
749749
#[cfg(any(
750750
target_os = "linux",
751751
target_os = "android",
752+
target_os = "dragonfly",
752753
target_os = "emscripten",
753754
target_os = "fuchsia",
754755
any(target_os = "wasi", target_env = "wasi"),

src/sys/resource.rs

+26-10
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ cfg_if! {
2424
}
2525

2626
libc_enum! {
27+
/// Types of process resources.
28+
///
2729
/// The Resource enum is platform dependent. Check different platform
28-
/// manuals for more details. Some platform links has been provided for
29-
/// earier reference (non-exhaustive).
30+
/// manuals for more details. Some platform links have been provided for
31+
/// easier reference (non-exhaustive).
3032
///
3133
/// * [Linux](https://man7.org/linux/man-pages/man2/getrlimit.2.html)
3234
/// * [FreeBSD](https://www.freebsd.org/cgi/man.cgi?query=setrlimit)
35+
/// * [NetBSD](https://man.netbsd.org/setrlimit.2)
3336
3437
// linux-gnu uses u_int as resource enum, which is implemented in libc as
3538
// well.
@@ -49,11 +52,7 @@ libc_enum! {
4952
), repr(i32))]
5053
#[non_exhaustive]
5154
pub enum Resource {
52-
#[cfg(not(any(
53-
target_os = "freebsd",
54-
target_os = "netbsd",
55-
target_os = "openbsd"
56-
)))]
55+
#[cfg(not(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))]
5756
#[cfg_attr(docsrs, doc(cfg(all())))]
5857
/// The maximum amount (in bytes) of virtual memory the process is
5958
/// allowed to map.
@@ -83,7 +82,13 @@ libc_enum! {
8382
/// this process may establish.
8483
RLIMIT_LOCKS,
8584

86-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))]
85+
#[cfg(any(
86+
target_os = "android",
87+
target_os = "freebsd",
88+
target_os = "openbsd",
89+
target_os = "linux",
90+
target_os = "netbsd"
91+
))]
8792
#[cfg_attr(docsrs, doc(cfg(all())))]
8893
/// The maximum size (in bytes) which a process may lock into memory
8994
/// using the mlock(2) system call.
@@ -101,7 +106,13 @@ libc_enum! {
101106
/// setpriority or nice.
102107
RLIMIT_NICE,
103108

104-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))]
109+
#[cfg(any(
110+
target_os = "android",
111+
target_os = "freebsd",
112+
target_os = "netbsd",
113+
target_os = "openbsd",
114+
target_os = "linux",
115+
))]
105116
#[cfg_attr(docsrs, doc(cfg(all())))]
106117
/// The maximum number of simultaneous processes for this user id.
107118
RLIMIT_NPROC,
@@ -112,7 +123,12 @@ libc_enum! {
112123
/// create.
113124
RLIMIT_NPTS,
114125

115-
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "linux"))]
126+
#[cfg(any(target_os = "android",
127+
target_os = "freebsd",
128+
target_os = "netbsd",
129+
target_os = "openbsd",
130+
target_os = "linux",
131+
))]
116132
#[cfg_attr(docsrs, doc(cfg(all())))]
117133
/// When there is memory pressure and swap is available, prioritize
118134
/// eviction of a process' resident pages beyond this amount (in bytes).

test/test_fcntl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ mod test_posix_fadvise {
488488

489489
#[cfg(any(target_os = "linux",
490490
target_os = "android",
491+
target_os = "dragonfly",
491492
target_os = "emscripten",
492493
target_os = "fuchsia",
493494
any(target_os = "wasi", target_env = "wasi"),

0 commit comments

Comments
 (0)