Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx {
    pub config: Config,
    pub root: Arc<View>,
    pub cache: Arc<DirCache>,
    pub mem: Mem,
    pub procs: Arc<ProcTable>,
    pub no_ptrace: bool,
    pub mailbox: Option<i32>,
    nested: AtomicBool,
}
Expand description

Everything handlers need, shared read-mostly between all threads.

Fields§

§config: Config§root: Arc<View>

The view of the first tracee, and of every process without one of its own.

§cache: Arc<DirCache>

Directory cache shared by every view.

§mem: Mem§procs: Arc<ProcTable>

Per-process bookkeeping, shared with fs for /proc magic links.

§no_ptrace: bool

True when running without ptrace: the former ptrace tier is served through notifications with in-place rewrites (see syscall::direct).

§mailbox: Option<i32>

The mailbox descriptor of the guest-stub restricted mode, installed into every process that execs (see guest_stub); None elsewhere.

§nested: AtomicBool

Set once any process has a view of its own; until then every lookup answers the root view without touching the process table.

Implementations§

Source§

impl Ctx

Source

pub fn new(config: Config, no_ptrace: bool) -> Ctx

Builds the shared state from a configuration.

§Arguments
  • config - Parsed command line.
  • no_ptrace - Run without a ptrace tier.
Source

pub fn trap_mode(&self) -> bool

Whether guests run the stub of the guest-stub restricted mode.

§Returns

true when a mailbox was set up.

Source

pub fn view(&self, tid: i32) -> Arc<View> ⓘ

The view the process of thread tid lives in.

§Arguments
  • tid - Thread or process id.
Source

pub fn enter_view(&self, tid: i32, view: Arc<View>, cwd: Vec<u8>)

Moves the process of thread tid into view, with cwd as its working directory there when the working directory is virtual.

§Arguments
  • tid - Thread or process id.
  • view - The view to enter.
  • cwd - Working directory as a guest path of view.
Source

pub fn tracee(&self, tid: i32) -> TraceeInfo

Returns a copy of what is known about the process of thread tid.

Source

pub fn set_exe(&self, tid: i32, guest: Vec<u8>, host: Vec<u8>)

Records the executable the process of thread tid is now running.

Source

pub fn ids(&self, tid: i32) -> Ids

The virtual identity of the process of thread tid (root until changed).

Source

pub fn set_ids(&self, tid: i32, ids: Ids)

Replaces the virtual identity of the process of thread tid.

Source

pub fn dumpable(&self, tid: i32) -> bool

Whether the process of thread tid still reads as dumpable.

Source

pub fn set_dumpable(&self, tid: i32, dumpable: bool)

Records the dumpable flag the process of thread tid set.

Source

pub fn groups(&self, tid: i32) -> Option<Vec<u32>>

Supplementary groups of the process of thread tid, if setgroups was called.

Source

pub fn set_groups(&self, tid: i32, groups: Vec<u32>)

Records the supplementary groups of the process of thread tid.

Source

pub fn fork(&self, parent: i32, child: i32)

Copies the bookkeeping of the process of parent to a newly forked child.

Source

pub fn forget(&self, pid: i32)

Forgets a process or thread that exited.

Source

pub fn tgid(&self, tid: i32) -> i32

Thread-group id of a thread.

Auto Trait Implementations§

§

impl !Freeze for Ctx

§

impl RefUnwindSafe for Ctx

§

impl Send for Ctx

§

impl Sync for Ctx

§

impl Unpin for Ctx

§

impl UnsafeUnpin for Ctx

§

impl UnwindSafe for Ctx

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.