Files
cloud-hypervisor/vmm/src/clone3.rs
Philipp Schuster c3a809696a docs: add Safety section to unsafe functions
This step was done manually by searching for "unsafe fn" in
the code base and adding corresponding Safety sections.
`clippy::missing_safety_doc` only works for public functions
but none of the corresponding functions is public.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
2025-09-02 16:31:25 +00:00

38 lines
897 B
Rust

// Copyright 2021 Alyssa Ross <hi@alyssa.is>
// SPDX-License-Identifier: Apache-2.0
use libc::{c_long, size_t, syscall, SYS_clone3};
pub const CLONE_CLEAR_SIGHAND: u64 = 0x100000000;
#[repr(C)]
#[derive(Default)]
#[allow(non_camel_case_types)]
pub struct clone_args {
pub flags: u64,
pub pidfd: u64,
pub child_tid: u64,
pub parent_tid: u64,
pub exit_signal: u64,
pub stack: u64,
pub stack_size: u64,
pub tls: u64,
pub set_tid: u64,
pub set_tid_size: u64,
pub cgroup: u64,
}
/// # Safety
/// `size` must have the proper size to match `args`.
/// Further, the caller needs to check the return value.
///
/// # Return
/// - On success:
/// - Parent: child PID (`c_long`)
/// - Child: `0`
/// - On error: `-1` and `errno` is set
#[must_use]
pub unsafe fn clone3(args: &mut clone_args, size: size_t) -> c_long {
syscall(SYS_clone3, args, size)
}