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§
- event 🔒
- file 🔒
- 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.
- 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 🔒
- poll 🔒
- priority 🔒
- sched 🔒Wrappers for CPU affinity functions.
- shm 🔒
- signalfd 🔒
- terminal 🔒
- timer 🔒
Structs§
- 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
- Used to poll multiple objects that have file descriptors.
- Iterator returning the offset range of data in the file.
- Generic netlink header struct, can be used by netlink consumer
- A set of memfd seals.
- Wraps an anonymous shared memory mapping in the current process. Provides RAII semantics including munmap when no longer needed.
- Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
- Iterator over
struct NlAttr
as received from a netlink socket. - Safe wrapper for
NETLINK_GENERIC
netlink sockets. - A single netlink message, including its header and data.
- Iterator over
struct nlmsghdr
as received from a netlink socket. - Netlink attribute struct, can be used by netlink consumer
- A safe wrapper around a Linux signalfd (man 2 signalfd).
- Used to attempt to clean up a named pipe after it is no longer used.
- Used to attempt to clean up a named pipe after it is no longer used.
Enums§
- The operation to perform with
fallocate
. - The operation to perform with
flock
.
Constants§
- Constant ioctl request number.
Traits§
- A trait used to abstract types that provide a process id that can be operated on.
- Linux specific extensions to
Event
. - Trait for file descriptors that are TTYs, according to
isatty(3)
.
Functions§
- Executes the given callback with extended soft limit of max number of open files. After the callback executed, restore the limit.
- Discards the given range of a block file.
- Drops all capabilities (permitted, inheritable, and effective) from the current process.
- Enable experimental core scheduling for the current thread.
- Returns the last errno as a Result that is always an error.
- Safe wrapper for
fallocate()
. - Find the offset range of the next data in the file.
- Safe wrapper for flock(2) with the operation
op
and optionallynonblocking
. The lock will be dropped automatically whenfile
is dropped. - Safe wrapper for
fstat()
. - Safe wrapper for
getegid(2)
. - Safe wrapper for
geteuid(2)
. - This bypasses
libc
’s cachinggetpid(2)
wrapper which can be invalid if a raw clone was used elsewhere. - Safe wrapper for the geppid Linux systemcall.
- Safe wrapper for the gettid Linux systemcall.
- Checks whether a file is a block device fie or not.
- Kill all processes in the current process group.
- Returns the capacity (measure of performance) of a given logical core.
- Returns the cluster ID of a given logical core.
- Returns a list of supported frequencies in kHz for a given logical core.
- Returns the maximum frequency (in kHz) of a given logical core.
- Get the soft and hard limits of max number of open files allowed by the environment.
- Return the maximum Duration that can be used with libc::timespec.
- Moves the requested PID/TID to a particular cgroup
- 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_full
to test handling of blockingwrite
calls in unit tests. - Open the file with the given path, or if it is of the form
/proc/self/fd/N
then just use the file descriptor. - Queries the property of a specified CPU sysfs node.
- Spawns a pipe pair where the first pipe is the read end and the second pipe is the write end.
- Utility function that returns true if the given FD is readable without blocking.
- Read raw bytes from stdin.
- Reaps a child process that has terminated.
- 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.
- If the given path is of the form /proc/self/fd/N for some N, returns
Ok(Some(N))
. Otherwise returnsOk(None)
. - Set the CPU affinity of the current thread to a given set of CPUs.
- Set the soft and hard limits of max number of open files to the given value.
- Sets the pipe signified with fd to
size
. - Enables real time thread priorities in the current thread up to
limit
. - Sets the current thread to be scheduled using the round robin real time class with
priority
. - Verifies that |raw_descriptor| is actually owned by this process and duplicates it to ensure that we have a unique handle to it.
- Verifies that |raw_fd| is actually owned by this process and duplicates it to ensure that we have a unique handle to it.
- A safe wrapper around waitpid.
Type Aliases§
- Re-export libc types that are part of the API.