Expand description
This crate provides to an interface into the linux procfs
filesystem, usually mounted at
/proc
.
This is a pseudo-filesystem which is available on most every linux system and provides an interface to kernel data structures.
§Kernel support
Not all fields/data are available in each kernel. Some fields were added in specific kernel
releases, and other fields are only present in certain kernel configuration options are
enabled. These are represented as Option
fields in this crate.
This crate aims to support all 2.6 kernels (and newer). WSL2 is also supported.
§Documentation
In almost all cases, the documentation is taken from the
proc.5
manual page. This means that
sometimes the style of writing is not very “rusty”, or may do things like reference related files
(instead of referencing related structs). Contributions to improve this are welcome.
§Panicing
While previous versions of the library could panic, this current version aims to be panic-free
in a many situations as possible. Whenever the procfs crate encounters a bug in its own
parsing code, it will return an InternalError
error. This should be considered a
bug and should be reported. If you encounter a panic,
please report that as well.
§Cargo features
The following cargo features are available:
chrono
– Default. Optional. This feature enables a few methods that return values asDateTime
objects.flate2
– Default. Optional. This feature enables parsing gzip compressed/proc/config.gz
file via theprocfs::kernel_config
method.backtrace
– Optional. This feature lets you get a stack trace whenever anInternalError
is raised.
§Examples
Examples can be found in the various modules shown below, or in the examples folder of the code repository.
Re-exports§
pub use crate::sys::kernel::BuildInfo as KernelBuildInfo;
pub use crate::sys::kernel::Type as KernelType;
pub use crate::sys::kernel::Version as KernelVersion;
Modules§
- keyring
- net
- Information about the networking layer.
- prelude
- Extension traits useful for importing wholesale.
- process
- Functions and structs related to process information
- sys
- Sysctl is a means of configuring certain aspects of the kernel at run-time,
and the
/proc/sys/
directory is there so that you don’t even need special tools to do it!
Structs§
- Aead
- Ahash
- Block
Device Entry - A block device entry under
/proc/devices
- CGroup
Controller - Container group controller information.
- CGroup
Controllers - Container group controller information.
- Char
Device Entry - A charcter device entry under
/proc/devices
- Cipher
- CpuInfo
- Represents the data from
/proc/cpuinfo
. - CpuPressure
- CPU pressure information
- CpuTime
- The amount of time, measured in ticks, the CPU has been in specific states
- Crypto
Block - Format of a crypto implementation represented in /proc/crypto.
- Crypto
Table - Represents the data from
/proc/crypto
. - Devices
- Device entries under
/proc/devices
- Disk
Stat - Disk IO stat information
- Disk
Stats - A list of disk stats.
- Explicit
System Info - A convenience stuct implementing SystemInfoInterface with explicitly-specified values.
- Internal
Error - An internal error in the procfs crate
- IoPressure
- IO pressure information
- Iomem
- KPage
Count - Parse physical memory references accessing
/proc/kpagecount
- KPage
Flags - Parse physical memory flags accessing
/proc/kpageflags
. - Kernel
Cmdline - A list of the arguments passed to the Linux kernel at boot time.
- Kernel
Config - The kernel configuration.
- Kernel
Module - Details about a loaded kernel module
- Kernel
Modules - A set of loaded kernel modules
- Kernel
Stats - Kernel/system statistics, from
/proc/stat
- Larval
- Load
Average - Load average figures.
- Local
System Info - A type for accessing data about the currently running machine
- Lock
- Details about an individual file lock
- Locks
- Details about file locks
- Meminfo
- This struct reports statistics about memory usage on the system, based on
the
/proc/meminfo
file. - Memory
Pressure - Memory pressure information
- Mount
Entry - A mountpoint entry under
/proc/mounts
- Partition
Entry - A partition entry under
/proc/partitions
- Physical
Memory Map - Physical
Page Flags - Represents the fields and flags in a page table entry for a memory page.
- Pressure
Record - Pressure stall information for either CPU, memory, or IO.
- ProcessC
Group - Information about a process cgroup
- ProcessC
Groups - Information about process cgroups.
- Rng
- Shared
Memory Segments - A set of shared memory segments parsed from
/proc/sysvipc/shm
- Shash
- Shm
- A shared memory segment parsed from
/proc/sysvipc/shm
Relation with crate::process::MMapPath::Vsys - Skcipher
- Unknown
- Uptime
- The uptime of the system, based on the
/proc/uptime
file. - VmStat
- Various virtual memory statistics
Enums§
- Config
Setting - Possible values for a kernel config option
- Lock
Kind - The kind of a lock (read or write)
- Lock
Mode - The mode of a lock (advisory or mandatory)
- Lock
Type - The type of a file lock
- Proc
Error - The various error conditions in the procfs crate.
- Self
Test - Potential results for selftest.
- Type
- Enumeration of potential types and their associated data. Unknown at end to catch unrecognised types.
Traits§
- Current
- Allows associating a specific file to parse.
- CurrentSI
- Allows associating a specific file to parse with system information.
- From
BufRead - Types which can be parsed from a BufRead implementation.
- From
BufReadSI - Types which can be parsed from a BufRead implementation and system info.
- From
Read - Types which can be parsed from a Read implementation.
- From
ReadSI - Types which can be parsed from a Read implementation and system info.
- From
StrRadix - Proc
Error Ext - Extensions for dealing with ProcErrors.
- System
Info Interface - Auxiliary system information interface.
- With
Current System Info - Allows
impl WithSystemInfo
to use the current system info. - With
System Info - Values which can provide an output given the SystemInfo.
Functions§
- boot_
time - The boot time of the system, as a
DateTime
object. - boot_
time_ secs - The boottime of the system, in seconds since the epoch
- cgroups
- Information about the cgroup controllers that are compiled into the kernel
- cmdline
- Get a list of the arguments passed to the Linux kernel at boot time
- crypto
- current_
system_ info - The current SystemInfo.
- diskstats
- Get disk IO stat info from /proc/diskstats
- iomem
- Reads and parses the
/proc/iomem
, returning an error if there are problems. - kernel_
config - Returns a configuration options used to build the currently running kernel
- locks
- Get a list of current file locks and leases
- modules
- Get a list of loaded kernel modules
- mounts
- Get a list of mountpoints from
/proc/mounts
- page_
size - Memory page size, in bytes.
- partitions
- Get a list of partitions from
/proc/partitions
- ticks_
per_ second - Return the number of ticks per second.
- vmstat
- Get various virtual memory statistics
Type Aliases§
- Proc
Result - The main error type for the procfs crate.
- System
Info - Auxiliary system information.