Expand description
Small system utility modules for usage by other modules.
Re-exportsΒ§
pub use ioctl::*;pub use signal::*;pub use crate::sys::unix::descriptor::*;
ModulesΒ§
- acpi_
event π - capabilities π
- descriptor π
- event π
- file π
- file_
traits π - This module exposes Linuxβs off64_t, pread64, and pwrite64 identifiers as the non-64 POSIX versions, similar to defining _FILE_OFFSET_BITS=64 in a C program.
- ioctl
- Macros and wrapper functions for dealing with ioctls.
- linux π
- Linux-specific utility modules.
- mmap π
- The mmap module provides a safe interface to mmap memory and ensures unmap is called when the mmap object leaves scope.
- net π
- netlink π
- notifiers π
- platform_
timer_ resolution - poll π
- priority π
- sched π
- Wrappers for CPU affinity functions.
- shm π
- signal
- signalfd π
- syslog
- terminal π
- timer π
- vsock
- write_
zeroes π
StructsΒ§
- Acpi
Notify Event - Error
- A system error In Unix systems, retrieved from errno (man 3 errno), set by a libc function that returned an error. On Windows, retrieved from GetLastError, set by a Windows function that returned an error
- Event
Context - Used to poll multiple objects that have file descriptors.
- File
Data Iterator - Iterator returning the offset range of data in the file.
- Genl
MsgHdr - Generic netlink header struct, can be used by netlink consumer
- Memfd
Seals - A set of memfd seals.
- Memory
Mapping - Wraps an anonymous shared memory mapping in the current process. Provides RAII semantics including munmap when no longer needed.
- Memory
Mapping Arena - Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
- Netlink
Generic Data Iter - Iterator over
struct NlAttras received from a netlink socket. - Netlink
Generic Read - Netlink
Generic Socket - Safe wrapper for
NETLINK_GENERICnetlink sockets. - Netlink
Message - A single netlink message, including its header and data.
- Netlink
Message Iter - Iterator over
struct nlmsghdras received from a netlink socket. - NlAttr
- Netlink attribute struct, can be used by netlink consumer
- NlAttr
With Data - Signal
Fd - A safe wrapper around a Linux signalfd (man 2 signalfd).
- Unlink
Unix Datagram - Used to attempt to clean up a named pipe after it is no longer used.
- Unlink
Unix Listener - Used to attempt to clean up a named pipe after it is no longer used.
- sched_
attr
EnumsΒ§
- Acpi
Event Error - Error
- Fallocate
Mode - The operation to perform with
fallocate. - Flock
Operation - The operation to perform with
flock. - Signal
FdError
ConstantsΒ§
- BLKDISCARD
- Constant ioctl request number.
- BLOCK_
IO_ πTYPE
TraitsΒ§
- AsRaw
Pid - A trait used to abstract types that provide a process id that can be operated on.
- Event
Ext - Linux specific extensions to
Event. - Memory
Mapping Builder Unix - Memory
Mapping Unix - Shared
Memory Linux - Terminal
- Trait for file descriptors that are TTYs, according to
isatty(3).
FunctionsΒ§
- call_
with_ extended_ max_ files - Executes the given callback with extended soft limit of max number of open files. After the callback executed, restore the limit.
- discard_
block - Discards the given range of a block file.
- drop_
capabilities - Drops all capabilities (permitted, inheritable, and effective) from the current process.
- enable_
core_ scheduling - Enable experimental core scheduling for the current thread.
- errno_
result - Returns the last errno as a Result that is always an error.
- fallocate
- Safe wrapper for
fallocate(). - find_
next_ data - Find the offset range of the next data in the file.
- flock
- Safe wrapper for flock(2) with the operation
opand optionallynonblocking. The lock will be dropped automatically whenfileis dropped. - fstat
- Safe wrapper for
fstat(). - get_
cpu_ affinity - getegid
- Safe wrapper for
getegid(2). - geteuid
- Safe wrapper for
geteuid(2). - getpid
- This bypasses
libcβs cachinggetpid(2)wrapper which can be invalid if a raw clone was used elsewhere. - getppid
- Safe wrapper for the geppid Linux systemcall.
- gettid
- Safe wrapper for the gettid Linux systemcall.
- is_
block_ file - Checks whether a file is a block device fie or not.
- kill_
process_ group - Kill all processes in the current process group.
- logical_
core_ capacity - Returns the capacity (measure of performance) of a given logical core.
- logical_
core_ cluster_ id - Returns the cluster ID of a given logical core.
- logical_
core_ frequencies_ khz - Returns a list of supported frequencies in kHz for a given logical core.
- logical_
core_ max_ freq_ khz - Returns the maximum frequency (in kHz) of a given logical core.
- max_
open_ files - Get the soft and hard limits of max number of open files allowed by the environment.
- max_
timeout - Return the maximum Duration that can be used with libc::timespec.
- move_
proc_ to_ cgroup - move_
task_ to_ cgroup - move_
to_ cgroup - Moves the requested PID/TID to a particular cgroup
- new_
pipe_ full - Test-only function used to create a pipe that is full. The pipe is created, has its size set to
the minimum and then has that much data written to it. Use
new_pipe_fullto test handling of blockingwritecalls in unit tests. - open_
file_ or_ duplicate - Open the file with the given path, or if it is of the form
/proc/self/fd/Nthen just use the file descriptor. - parse_
sysfs_ πcpu_ info - parse_
sysfs_ πcpu_ info_ vec - Queries the property of a specified CPU sysfs node.
- pipe
- Spawns a pipe pair where the first pipe is the read end and the second pipe is the write end.
- poll_in
- Utility function that returns true if the given FD is readable without blocking.
- read_
raw_ stdin - Read raw bytes from stdin.
- reap_
child - Reaps a child process that has terminated.
- safe_
descriptor_ from_ cmdline_ fd - Check FD is not opened by crosvm and returns a FD that is freshly DUPFD_CLOEXECβs. A SafeDescriptor is created from the duplicated fd. It does not take ownership of fd passed by argument.
- safe_
descriptor_ from_ path - If the given path is of the form /proc/self/fd/N for some N, returns
Ok(Some(N)). Otherwise returnsOk(None). - sched_
setattr - set_
cpu_ affinity - Set the CPU affinity of the current thread to a given set of CPUs.
- set_
max_ πopen_ files - Set the soft and hard limits of max number of open files to the given value.
- set_
pipe_ size - Sets the pipe signified with fd to
size. - set_
rt_ prio_ limit - Enables real time thread priorities in the current thread up to
limit. - set_
rt_ round_ robin - Sets the current thread to be scheduled using the round robin real time class with
priority. - set_
thread_ name - Safe wrapper for PR_SET_NAME(2const)
- validate_
raw_ descriptor - Verifies that |raw_descriptor| is actually owned by this process and duplicates it to ensure that we have a unique handle to it.
- validate_
raw_ fd - Verifies that |raw_fd| is actually owned by this process and duplicates it to ensure that we have a unique handle to it.
- wait_
for_ pid - A safe wrapper around waitpid.