Lines Matching defs:proc

1 //! Utilities for working with `/proc`, where Linux's `procfs` is typically
2 //! mounted. `/proc` serves as an adjunct to Linux's main syscall surface area,
5 //! This module does a considerable amount of work to determine whether `/proc`
36 // Identify an entry within "/proc", to determine which anomalies to check for.
45 /// Check a subdirectory of "/proc" for anomalies.
55 /// Check a subdirectory of "/proc" for anomalies, using the provided `Stat`.
71 // "/proc" directories are typically mounted r-xr-xr-x.
72 // "/proc/self/fd" is r-x------. Allow them to have fewer permissions, but
81 // Check that the "/proc/self/fd" directory doesn't have any extraneous
88 // Check that the "/proc" and "/proc/self" directories aren't empty.
106 // We use `O_DIRECTORY` for proc directories, so open should fail if we
121 // Check that "/proc" is a mountpoint.
134 // We use `O_DIRECTORY` for proc directories, so open should fail if we
140 // Check that subdirectories of "/proc" are not mount points.
160 // Check that we haven't been linked back to the root of "/proc".
196 /// Open a directory in `/proc`, mapping all errors to `io::Errno::NOTSUP`.
204 /// Returns a handle to Linux's `/proc` directory.
206 /// This ensures that `/proc` is procfs, that nothing is mounted on top of it,
207 /// and that it looks normal. It also returns the `Stat` of `/proc`.
212 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
213 fn proc() -> io::Result<(BorrowedFd<'static>, &'static Stat)> {
220 // Open "/proc".
221 let proc = proc_opendirat(cwd(), cstr!("/proc"))?;
223 check_proc_entry(Kind::Proc, proc.as_fd(), None).map_err(|_err| io::Errno::NOTSUP)?;
225 Ok(new_static_fd(proc, proc_stat))
230 /// Returns a handle to Linux's `/proc/self` directory.
232 /// This ensures that `/proc/self` is procfs, that nothing is mounted on top of
233 /// it, and that it looks normal. It also returns the `Stat` of `/proc/self`.
238 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
245 let (proc, proc_stat) = proc()?;
249 // Open "/proc/self". Use our pid to compute the name rather than literally
251 let proc_self = proc_opendirat(proc, DecInt::new(pid.as_raw_nonzero().get()))?;
260 /// Returns a handle to Linux's `/proc/self/fd` directory.
262 /// This ensures that `/proc/self/fd` is `procfs`, that nothing is mounted on
268 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
276 let (_, proc_stat) = proc()?;
280 // Open "/proc/self/fd".
298 /// Returns a handle to Linux's `/proc/self/fdinfo` directory.
300 /// This ensures that `/proc/self/fdinfo` is `procfs`, that nothing is mounted
302 /// `/proc/self/fd`.
307 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
313 let (_, proc_stat) = proc()?;
317 // Open "/proc/self/fdinfo".
328 /// Returns a handle to a Linux `/proc/self/fdinfo/<fd>` file.
330 /// This ensures that `/proc/self/fdinfo/<fd>` is `procfs`, that nothing is
336 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
349 /// Returns a handle to a Linux `/proc/self/pagemap` file.
351 /// This ensures that `/proc/self/pagemap` is `procfs`, that nothing is
358 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
366 /// Returns a handle to a Linux `/proc/self/maps` file.
368 /// This ensures that `/proc/self/maps` is `procfs`, that nothing is
374 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
381 /// Returns a handle to a Linux `/proc/self/status` file.
383 /// This ensures that `/proc/self/status` is `procfs`, that nothing is
389 /// [Linux]: https://man7.org/linux/man-pages/man5/proc.5.html
396 /// Open a file under `/proc/self`.
404 let (_, proc_stat) = proc()?;
408 // `/proc/<pid>` files [to root:root].
411 // [to root:root]: https://man7.org/linux/man-pages/man5/proc.5.html