Skip to main content

KernelVm

Struct KernelVm 

Source
pub struct KernelVm<F> { /* private fields */ }

Implementations§

Source§

impl<F: VirtualFileSystem + 'static> KernelVm<F>

Source

pub fn new(filesystem: F, config: KernelVmConfig) -> Self

Source

pub fn vm_id(&self) -> &str

Source

pub fn state(&self) -> LifecycleState

Source

pub fn commands(&self) -> BTreeMap<String, String>

Source

pub fn filesystem(&self) -> &PermissionedFileSystem<DeviceLayer<F>>

Source

pub fn filesystem_mut(&mut self) -> &mut PermissionedFileSystem<DeviceLayer<F>>

Source

pub fn user_manager(&self) -> &UserManager

Source

pub fn process_identity( &self, requester_driver: &str, pid: u32, ) -> KernelResult<ProcessIdentity>

Source

pub fn user_profile(&self) -> UserManager

Source

pub fn getuid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn getgid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn geteuid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn getegid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn getgroups( &self, requester_driver: &str, pid: u32, ) -> KernelResult<Vec<u32>>

Source

pub fn getpwuid(&self, uid: u32) -> KernelResult<String>

Source

pub fn getgrgid(&self, gid: u32) -> KernelResult<String>

Source

pub fn resource_snapshot(&self) -> ResourceSnapshot

Source

pub fn resource_limits(&self) -> &ResourceLimits

Source

pub fn resolve_dns( &self, hostname: &str, policy: DnsLookupPolicy, ) -> KernelResult<DnsResolution>

Source

pub fn resolve_dns_records( &self, hostname: &str, record_type: RecordType, policy: DnsLookupPolicy, ) -> KernelResult<DnsRecordResolution>

Source

pub fn register_driver(&mut self, driver: CommandDriver) -> KernelResult<()>

Source

pub fn exec( &mut self, command: &str, options: ExecOptions, ) -> KernelResult<KernelProcessHandle>

Source

pub fn open_shell( &mut self, options: OpenShellOptions, ) -> KernelResult<OpenShellHandle>

Source

pub fn read_file(&mut self, path: &str) -> KernelResult<Vec<u8>>

Source

pub fn pread_file( &mut self, path: &str, offset: u64, length: usize, ) -> KernelResult<Vec<u8>>

Source

pub fn read_file_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<Vec<u8>>

Source

pub fn write_file( &mut self, path: &str, content: impl Into<Vec<u8>>, ) -> KernelResult<()>

Source

pub fn write_file_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, content: impl Into<Vec<u8>>, mode: Option<u32>, ) -> KernelResult<()>

Source

pub fn create_dir(&mut self, path: &str) -> KernelResult<()>

Source

pub fn create_dir_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, mode: Option<u32>, ) -> KernelResult<()>

Source

pub fn mkdir(&mut self, path: &str, recursive: bool) -> KernelResult<()>

Source

pub fn mkdir_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, recursive: bool, mode: Option<u32>, ) -> KernelResult<()>

Source

pub fn umask( &self, requester_driver: &str, pid: u32, new_mask: Option<u32>, ) -> KernelResult<u32>

Source

pub fn exists(&self, path: &str) -> KernelResult<bool>

Source

pub fn exists_for_process( &self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<bool>

Source

pub fn stat(&mut self, path: &str) -> KernelResult<VirtualStat>

Source

pub fn stat_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<VirtualStat>

Source

pub fn lstat(&self, path: &str) -> KernelResult<VirtualStat>

Source

pub fn lstat_for_process( &self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<VirtualStat>

Source

pub fn read_dir(&mut self, path: &str) -> KernelResult<Vec<String>>

Source

pub fn read_dir_for_process( &mut self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<Vec<String>>

Source

pub fn remove_file(&mut self, path: &str) -> KernelResult<()>

Source

pub fn remove_dir(&mut self, path: &str) -> KernelResult<()>

Source

pub fn rename(&mut self, old_path: &str, new_path: &str) -> KernelResult<()>

Source

pub fn realpath(&self, path: &str) -> KernelResult<String>

Source

pub fn realpath_for_process( &self, requester_driver: &str, pid: u32, path: &str, ) -> KernelResult<String>

Source

pub fn chmod(&mut self, path: &str, mode: u32) -> KernelResult<()>

Source

pub fn chown(&mut self, path: &str, uid: u32, gid: u32) -> KernelResult<()>

Source

pub fn utimes( &mut self, path: &str, atime_ms: u64, mtime_ms: u64, ) -> KernelResult<()>

Source

pub fn utimes_spec( &mut self, path: &str, atime: VirtualUtimeSpec, mtime: VirtualUtimeSpec, ) -> KernelResult<()>

Source

pub fn lutimes( &mut self, path: &str, atime: VirtualUtimeSpec, mtime: VirtualUtimeSpec, ) -> KernelResult<()>

Source

pub fn futimes( &mut self, requester_driver: &str, pid: u32, fd: u32, atime: VirtualUtimeSpec, mtime: VirtualUtimeSpec, ) -> KernelResult<()>

Source

pub fn truncate(&mut self, path: &str, length: u64) -> KernelResult<()>

Source

pub fn list_processes(&self) -> BTreeMap<u32, ProcessInfo>

Source

pub fn zombie_timer_count(&self) -> usize

Source

pub fn spawn_process( &mut self, command: &str, args: Vec<String>, options: SpawnOptions, ) -> KernelResult<KernelProcessHandle>

Source

pub fn create_virtual_process( &mut self, requester_driver: &str, driver: &str, command: &str, args: Vec<String>, options: VirtualProcessOptions, ) -> KernelResult<KernelProcessHandle>

Source

pub fn read_process_stdin( &mut self, requester_driver: &str, pid: u32, length: usize, timeout: Option<Duration>, ) -> KernelResult<Option<Vec<u8>>>

Source

pub fn write_process_stdout( &mut self, requester_driver: &str, pid: u32, data: &[u8], ) -> KernelResult<usize>

Source

pub fn write_process_stderr( &mut self, requester_driver: &str, pid: u32, data: &[u8], ) -> KernelResult<usize>

Source

pub fn exit_process( &mut self, requester_driver: &str, pid: u32, exit_code: i32, ) -> KernelResult<()>

Source

pub fn waitpid(&mut self, pid: u32) -> KernelResult<WaitPidResult>

Source

pub fn waitpid_with_options( &mut self, requester_driver: &str, waiter_pid: u32, pid: i32, flags: WaitPidFlags, ) -> KernelResult<Option<WaitPidEventResult>>

Source

pub fn wait_and_reap(&mut self, pid: u32) -> KernelResult<(u32, i32)>

Source

pub fn open_pipe( &mut self, requester_driver: &str, pid: u32, ) -> KernelResult<(u32, u32)>

Source

pub fn open_pty( &mut self, requester_driver: &str, pid: u32, ) -> KernelResult<(u32, u32, String)>

Source

pub fn socket_create( &mut self, requester_driver: &str, pid: u32, spec: SocketSpec, ) -> KernelResult<SocketId>

Source

pub fn socket_get(&self, socket_id: SocketId) -> Option<SocketRecord>

Source

pub fn socket_bind_inet( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, address: InetSocketAddress, ) -> KernelResult<()>

Source

pub fn socket_bind_unix( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, path: impl Into<String>, ) -> KernelResult<()>

Source

pub fn socket_listen( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, backlog: usize, ) -> KernelResult<()>

Source

pub fn socket_queue_incoming_tcp_connection( &mut self, requester_driver: &str, pid: u32, listener_socket_id: SocketId, peer_address: InetSocketAddress, ) -> KernelResult<()>

Source

pub fn socket_accept( &mut self, requester_driver: &str, pid: u32, listener_socket_id: SocketId, ) -> KernelResult<SocketId>

Source

pub fn socket_connect_pair( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, peer_socket_id: SocketId, ) -> KernelResult<()>

Source

pub fn socket_connect_unix( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, target_path: impl Into<String>, ) -> KernelResult<()>

Source

pub fn socket_connect_inet_loopback( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, target_address: InetSocketAddress, ) -> KernelResult<()>

Source

pub fn socket_send_to_inet_loopback( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, target_address: InetSocketAddress, data: &[u8], ) -> KernelResult<usize>

Source

pub fn socket_recv_datagram( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, max_bytes: usize, ) -> KernelResult<Option<ReceivedDatagram>>

Source

pub fn socket_set_datagram_option( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, option: DatagramSocketOption, enabled: bool, ) -> KernelResult<()>

Source

pub fn socket_add_membership( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, membership: SocketMulticastMembership, ) -> KernelResult<()>

Source

pub fn socket_drop_membership( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, membership: SocketMulticastMembership, ) -> KernelResult<()>

Source

pub fn socket_set_state( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, state: SocketState, ) -> KernelResult<()>

Source

pub fn socket_write( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, data: &[u8], ) -> KernelResult<usize>

Source

pub fn socket_read( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, max_bytes: usize, ) -> KernelResult<Option<Vec<u8>>>

Source

pub fn socket_shutdown( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, how: SocketShutdown, ) -> KernelResult<()>

Source

pub fn socket_close( &mut self, requester_driver: &str, pid: u32, socket_id: SocketId, ) -> KernelResult<()>

Source

pub fn fd_open( &mut self, requester_driver: &str, pid: u32, path: &str, flags: u32, mode: Option<u32>, ) -> KernelResult<u32>

Source

pub fn fd_read( &mut self, requester_driver: &str, pid: u32, fd: u32, length: usize, ) -> KernelResult<Vec<u8>>

Source

pub fn fd_read_with_timeout_result( &mut self, requester_driver: &str, pid: u32, fd: u32, length: usize, timeout: Option<Duration>, ) -> KernelResult<Option<Vec<u8>>>

Source

pub fn fd_write( &mut self, requester_driver: &str, pid: u32, fd: u32, data: &[u8], ) -> KernelResult<usize>

Source

pub fn poll_fds( &self, requester_driver: &str, pid: u32, fds: Vec<PollFd>, timeout_ms: i32, ) -> KernelResult<PollResult>

Source

pub fn poll_targets( &self, requester_driver: &str, pid: u32, targets: Vec<PollTargetEntry>, timeout_ms: i32, ) -> KernelResult<PollTargetResult>

Source

pub fn fd_seek( &mut self, requester_driver: &str, pid: u32, fd: u32, offset: i64, whence: u8, ) -> KernelResult<u64>

Source

pub fn fd_pread( &mut self, requester_driver: &str, pid: u32, fd: u32, length: usize, offset: u64, ) -> KernelResult<Vec<u8>>

Source

pub fn fd_pwrite( &mut self, requester_driver: &str, pid: u32, fd: u32, data: &[u8], offset: u64, ) -> KernelResult<usize>

Source

pub fn fd_dup( &mut self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<u32>

Source

pub fn fd_dup2( &mut self, requester_driver: &str, pid: u32, old_fd: u32, new_fd: u32, ) -> KernelResult<()>

Source

pub fn fd_close( &mut self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<()>

Source

pub fn fd_fcntl( &mut self, requester_driver: &str, pid: u32, fd: u32, command: u32, arg: u32, ) -> KernelResult<u32>

Source

pub fn fd_flock( &self, requester_driver: &str, pid: u32, fd: u32, operation: u32, ) -> KernelResult<()>

Source

pub fn fd_stat( &self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<FdStat>

Source

pub fn fd_path( &self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<String>

Source

pub fn isatty( &self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<bool>

Source

pub fn pty_set_discipline( &self, requester_driver: &str, pid: u32, fd: u32, config: LineDisciplineConfig, ) -> KernelResult<()>

Source

pub fn pty_set_foreground_pgid( &self, requester_driver: &str, pid: u32, fd: u32, pgid: u32, ) -> KernelResult<()>

Source

pub fn tcgetattr( &self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<Termios>

Source

pub fn tcsetattr( &self, requester_driver: &str, pid: u32, fd: u32, termios: PartialTermios, ) -> KernelResult<()>

Source

pub fn tcgetpgrp( &self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<u32>

Source

pub fn pty_resize( &self, requester_driver: &str, pid: u32, fd: u32, cols: u16, rows: u16, ) -> KernelResult<()>

Source

pub fn signal_process( &self, requester_driver: &str, pid: i32, signal: i32, ) -> KernelResult<()>

Source

pub fn kill_process( &self, requester_driver: &str, pid: u32, signal: i32, ) -> KernelResult<()>

Source

pub fn setpgid( &self, requester_driver: &str, pid: u32, pgid: u32, ) -> KernelResult<()>

Source

pub fn getpgid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn getpid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn sigprocmask( &self, requester_driver: &str, pid: u32, how: SigmaskHow, set: SignalSet, ) -> KernelResult<SignalSet>

Source

pub fn sigpending( &self, requester_driver: &str, pid: u32, ) -> KernelResult<SignalSet>

Source

pub fn getppid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn setsid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn getsid(&self, requester_driver: &str, pid: u32) -> KernelResult<u32>

Source

pub fn dev_fd_read_dir( &self, requester_driver: &str, pid: u32, ) -> KernelResult<Vec<String>>

Source

pub fn dev_fd_stat( &mut self, requester_driver: &str, pid: u32, fd: u32, ) -> KernelResult<VirtualStat>

Source

pub fn dispose(&mut self) -> KernelResult<()>

Source§

impl KernelVm<MountTable>

Source

pub fn mount_filesystem( &mut self, path: &str, filesystem: impl VirtualFileSystem + 'static, options: MountOptions, ) -> KernelResult<()>

Source

pub fn mount_boxed_filesystem( &mut self, path: &str, filesystem: Box<dyn MountedFileSystem>, options: MountOptions, ) -> KernelResult<()>

Source

pub fn unmount_filesystem(&mut self, path: &str) -> KernelResult<()>

Source

pub fn mounted_filesystems(&self) -> Vec<MountEntry>

Source

pub fn root_filesystem_mut(&mut self) -> Option<&mut RootFileSystem>

Source

pub fn snapshot_root_filesystem( &mut self, ) -> KernelResult<RootFilesystemSnapshot>

Trait Implementations§

Source§

impl<F> Drop for KernelVm<F>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<F> !RefUnwindSafe for KernelVm<F>

§

impl<F> !UnwindSafe for KernelVm<F>

§

impl<F> Freeze for KernelVm<F>
where F: Freeze,

§

impl<F> Send for KernelVm<F>
where F: Send,

§

impl<F> Sync for KernelVm<F>
where F: Sync,

§

impl<F> Unpin for KernelVm<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for KernelVm<F>
where F: UnsafeUnpin,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more