NamespaceNode

Struct NamespaceNode 

Source
pub struct NamespaceNode {
    pub mount: MountInfo,
    pub entry: DirEntryHandle,
}
Expand description

A node in a mount namespace.

This tree is a composite of the mount tree and the FsNode tree.

These nodes are used when traversing paths in a namespace in order to present the client the directory structure that includes the mounted filesystems.

Fields§

§mount: MountInfo

The mount where this namespace node is mounted.

A given FsNode can be mounted in multiple places in a namespace. This field distinguishes between them.

§entry: DirEntryHandle

The FsNode that corresponds to this namespace entry.

Implementations§

Source§

impl NamespaceNode

Source

pub fn new(mount: Arc<Mount>, entry: DirEntryHandle) -> Self

Source

pub fn new_anonymous(entry: DirEntryHandle) -> Self

Create a namespace node that is not mounted in a namespace.

Source

pub fn new_anonymous_unrooted( current_task: &CurrentTask, node: FsNodeHandle, ) -> Self

Create a namespace node that is not mounted in a namespace and that refers to a node that is not rooted in a hierarchy and has no name.

Source

pub fn open( &self, locked: &mut Locked<Unlocked>, current_task: &CurrentTask, flags: OpenFlags, access_check: AccessCheck, ) -> Result<FileHandle, Errno>

Create a FileObject corresponding to this namespace node.

This function is the primary way of instantiating FileObjects. Each FileObject records the NamespaceNode that created it in order to remember its path in the Namespace.

Source

pub fn open_create_node<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, name: &FsStr, mode: FileMode, dev: DeviceType, flags: OpenFlags, ) -> Result<NamespaceNode, Errno>

Create or open a node in the file system.

Works for any type of node other than a symlink.

Will return an existing node unless flags contains OpenFlags::EXCL.

Source

pub fn into_active(self) -> ActiveNamespaceNode

Source

pub fn into_mapping( self, mode: Option<FileWriteGuardMode>, ) -> Result<Arc<FileMapping>, Errno>

Source

pub fn create_node<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, name: &FsStr, mode: FileMode, dev: DeviceType, ) -> Result<NamespaceNode, Errno>

Create a node in the file system.

Works for any type of node other than a symlink.

Does not return an existing node.

Create a symlink in the file system.

To create another type of node, use create_node.

Source

pub fn create_tmpfile<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, mode: FileMode, flags: OpenFlags, ) -> Result<NamespaceNode, Errno>

Creates an anonymous file.

The FileMode::IFMT of the FileMode is always FileMode::IFREG.

Used by O_TMPFILE.

Source

pub fn bind_socket<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, name: &FsStr, socket: SocketHandle, socket_address: SocketAddress, mode: FileMode, ) -> Result<NamespaceNode, Errno>

Source

pub fn lookup_child<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, context: &mut LookupContext, basename: &FsStr, ) -> Result<NamespaceNode, Errno>

Traverse down a parent-to-child link in the namespace.

Source

pub fn parent(&self) -> Option<NamespaceNode>

Traverse up a child-to-parent link in the namespace.

This traversal matches the child-to-parent link in the underlying FsNode except at mountpoints, where the link switches from one filesystem to another.

Source

pub fn parent_within_mount(&self) -> Option<DirEntryHandle>

Returns the parent, but does not escape mounts i.e. returns None if this node is the root of a mount.

Source

pub fn is_descendant_of(&self, ancestor: &NamespaceNode) -> bool

Whether this namespace node is a descendant of the given node.

Walks up the namespace node tree looking for ancestor. If ancestor is found, returns true. Otherwise, returns false.

Source

pub fn mount_if_root(&self) -> Result<&Arc<Mount>, Errno>

If this node is the root of a mount, return it. Otherwise EINVAL.

Source

pub fn path(&self, task: &Task) -> FsString

The path from the task’s root to this node.

Source

pub fn path_escaping_chroot(&self) -> FsString

The path from the root of the namespace to this node.

Source

pub fn path_from_root( &self, root: Option<&NamespaceNode>, ) -> PathWithReachability

Returns the path to this node, accounting for a custom root. A task may have a custom root set by chroot.

Source

pub fn mount(&self, what: WhatToMount, flags: MountFlags) -> Result<(), Errno>

Source

pub fn unmount(&self, flags: UnmountFlags) -> Result<(), Errno>

If this is the root of a filesystem, unmount. Otherwise return EINVAL.

Source

pub fn rename<L>( locked: &mut Locked<L>, current_task: &CurrentTask, old_parent: &NamespaceNode, old_name: &FsStr, new_parent: &NamespaceNode, new_name: &FsStr, flags: RenameFlags, ) -> Result<(), Errno>

Source

pub fn suid_and_sgid( &self, current_task: &CurrentTask, ) -> Result<UserAndOrGroupId, Errno>

Source

pub fn update_atime(&self)

Source

pub fn notify(&self, event_mask: InotifyMask)

Source

pub fn check_access<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, permission_flags: impl Into<PermissionFlags>, reason: CheckAccessReason, ) -> Result<(), Errno>

Check whether the node can be accessed in the current context with the specified access flags (read, write, or exec). Accounts for capabilities and whether the current user is the owner or is in the file’s group.

Source

pub fn check_o_noatime_allowed( &self, current_task: &CurrentTask, ) -> Result<(), Errno>

Checks if O_NOATIME is allowed,

Source

pub fn truncate<L>( &self, locked: &mut Locked<L>, current_task: &CurrentTask, length: u64, ) -> Result<(), Errno>

Trait Implementations§

Source§

impl Clone for NamespaceNode

Source§

fn clone(&self) -> NamespaceNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NamespaceNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a NamespaceNode> for Auditable<'a>

Source§

fn from(value: &'a NamespaceNode) -> Self

Converts to this type from the input type.
Source§

impl Hash for NamespaceNode

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for NamespaceNode

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for NamespaceNode

Auto Trait Implementations§

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
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> Into32<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_32(self) -> U

Source§

impl<T, U> Into64<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_64(self) -> U

Source§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

Source§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
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
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
Source§

impl<T, U> IntoFidl<U> for T
where U: FromFidl<T>,

Source§

fn into_fidl(self) -> U

Source§

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

Source§

fn from_64(value: T) -> U

Source§

fn from_32(value: T) -> U

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

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

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag
Source§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,

Source§

impl<B, A> LockEqualOrBefore<B> for A
where A: LockBefore<B>,

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,