Module linux

Source
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Β§

AcpiNotifyEvent
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
EventContext
Used to poll multiple objects that have file descriptors.
FileDataIterator
Iterator returning the offset range of data in the file.
GenlMsgHdr
Generic netlink header struct, can be used by netlink consumer
MemfdSeals
A set of memfd seals.
MemoryMapping
Wraps an anonymous shared memory mapping in the current process. Provides RAII semantics including munmap when no longer needed.
MemoryMappingArena
Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
NetlinkGenericDataIter
Iterator over struct NlAttr as received from a netlink socket.
NetlinkGenericRead
NetlinkGenericSocket
Safe wrapper for NETLINK_GENERIC netlink sockets.
NetlinkMessage
A single netlink message, including its header and data.
NetlinkMessageIter
Iterator over struct nlmsghdr as received from a netlink socket.
NlAttr
Netlink attribute struct, can be used by netlink consumer
NlAttrWithData
SignalFd
A safe wrapper around a Linux signalfd (man 2 signalfd).
UnlinkUnixDatagram
Used to attempt to clean up a named pipe after it is no longer used.
UnlinkUnixListener
Used to attempt to clean up a named pipe after it is no longer used.
sched_attr

EnumsΒ§

AcpiEventError
Error
FallocateMode
The operation to perform with fallocate.
FlockOperation
The operation to perform with flock.
SignalFdError

ConstantsΒ§

BLKDISCARD
Constant ioctl request number.
BLOCK_IO_TYPE πŸ”’

TraitsΒ§

AsRawPid
A trait used to abstract types that provide a process id that can be operated on.
EventExt
Linux specific extensions to Event.
MemoryMappingBuilderUnix
MemoryMappingUnix
SharedMemoryLinux
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 op and optionally nonblocking. The lock will be dropped automatically when file is 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 caching getpid(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_full to test handling of blocking write calls in unit tests.
open_file_or_duplicate
Open the file with the given path, or if it is of the form /proc/self/fd/N then 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 returns Ok(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.

Type AliasesΒ§

Gid
Mode
Result
Result
Result
Uid
Re-export libc types that are part of the API.