Debian Codegraph @

debian/rust-vendor/procfs/src/sys/fs/epoll.rs

raw
1 use crate::{read_value, write_value, ProcResult};
2
3 /// Get the limit on the total number of file descriptors that a user can register across all epoll instances.
4 ///
5 /// The limit is per real user ID. Each registered file descriptor costs roughtly 90 bytes on a 32-bit kernel,
6 /// and roughly 160 bytes on a 64-bit kernel. Currently, the default value for `max_user_watches` is 1/25 (4%)
7 /// of the available low memory, divided by the registration cost in bytes.
8 ///
9 /// (Since Linux 2.6.28)
10 pub fn max_user_watches() -> ProcResult<u64> {
11 read_value("/proc/sys/fs/epoll/max_user_watches")
12 }
13
14 /// Sets the limit on the total number of file descriptors that a user can register across all epoll instances.
15 pub fn set_max_user_watches(val: u64) -> ProcResult<()> {
16 write_value("/proc/sys/fs/epoll/max_user_watches", val)
17 }
18
19 #[cfg(test)]
20 mod tests {
21 use super::*;
22 use crate::KernelVersion;
23
24 #[test]
25 fn test_max_user_watches() {
26 if KernelVersion::current().unwrap() >= KernelVersion::new(2, 6, 28) {
27 println!("{}", max_user_watches().unwrap());
28 }
29 }
30 }