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: MountInfoThe 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: DirEntryHandleThe FsNode that corresponds to this namespace entry.
Implementations§
Source§impl NamespaceNode
impl NamespaceNode
pub fn new(mount: Arc<Mount>, entry: DirEntryHandle) -> Self
Sourcepub fn new_anonymous(entry: DirEntryHandle) -> Self
pub fn new_anonymous(entry: DirEntryHandle) -> Self
Create a namespace node that is not mounted in a namespace.
Sourcepub fn new_anonymous_unrooted(
current_task: &CurrentTask,
node: FsNodeHandle,
) -> Self
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.
Sourcepub fn open(
&self,
locked: &mut Locked<Unlocked>,
current_task: &CurrentTask,
flags: OpenFlags,
access_check: AccessCheck,
) -> Result<FileHandle, Errno>
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.
Sourcepub fn open_create_node<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
mode: FileMode,
dev: DeviceType,
flags: OpenFlags,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
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>where
L: LockEqualOrBefore<FileOpsCore>,
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.
pub fn into_active(self) -> ActiveNamespaceNode
pub fn into_mapping( self, mode: Option<FileWriteGuardMode>, ) -> Result<Arc<FileMapping>, Errno>
Sourcepub fn create_node<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
mode: FileMode,
dev: DeviceType,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn create_node<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
mode: FileMode,
dev: DeviceType,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Create a node in the file system.
Works for any type of node other than a symlink.
Does not return an existing node.
Sourcepub fn create_symlink<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
target: &FsStr,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn create_symlink<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
target: &FsStr,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Create a symlink in the file system.
To create another type of node, use create_node.
Sourcepub fn create_tmpfile<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
mode: FileMode,
flags: OpenFlags,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn create_tmpfile<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
mode: FileMode,
flags: OpenFlags,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Creates an anonymous file.
The FileMode::IFMT of the FileMode is always FileMode::IFREG.
Used by O_TMPFILE.
pub fn link<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
child: &FsNodeHandle,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
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>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn unlink<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
name: &FsStr,
kind: UnlinkKind,
must_be_directory: bool,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Sourcepub fn lookup_child<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
context: &mut LookupContext,
basename: &FsStr,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn lookup_child<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
context: &mut LookupContext,
basename: &FsStr,
) -> Result<NamespaceNode, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
Traverse down a parent-to-child link in the namespace.
Sourcepub fn parent(&self) -> Option<NamespaceNode>
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.
Sourcepub fn parent_within_mount(&self) -> Option<DirEntryHandle>
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.
Sourcepub fn is_descendant_of(&self, ancestor: &NamespaceNode) -> bool
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.
Sourcepub fn mount_if_root(&self) -> Result<&Arc<Mount>, Errno>
pub fn mount_if_root(&self) -> Result<&Arc<Mount>, Errno>
If this node is the root of a mount, return it. Otherwise EINVAL.
Sourcepub fn path_escaping_chroot(&self) -> FsString
pub fn path_escaping_chroot(&self) -> FsString
The path from the root of the namespace to this node.
Sourcepub fn path_from_root(
&self,
root: Option<&NamespaceNode>,
) -> PathWithReachability
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.
pub fn mount(&self, what: WhatToMount, flags: MountFlags) -> Result<(), Errno>
Sourcepub fn unmount(&self, flags: UnmountFlags) -> Result<(), Errno>
pub fn unmount(&self, flags: UnmountFlags) -> Result<(), Errno>
If this is the root of a filesystem, unmount. Otherwise return EINVAL.
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>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn suid_and_sgid( &self, current_task: &CurrentTask, ) -> Result<UserAndOrGroupId, Errno>
pub fn update_atime(&self)
pub fn readlink<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
) -> Result<SymlinkTarget, Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn notify(&self, event_mask: InotifyMask)
Sourcepub fn check_access<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
permission_flags: impl Into<PermissionFlags>,
reason: CheckAccessReason,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
pub fn check_access<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
permission_flags: impl Into<PermissionFlags>,
reason: CheckAccessReason,
) -> Result<(), Errno>where
L: LockEqualOrBefore<FileOpsCore>,
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.
Sourcepub fn check_o_noatime_allowed(
&self,
current_task: &CurrentTask,
) -> Result<(), Errno>
pub fn check_o_noatime_allowed( &self, current_task: &CurrentTask, ) -> Result<(), Errno>
Checks if O_NOATIME is allowed,
pub fn truncate<L>(
&self,
locked: &mut Locked<L>,
current_task: &CurrentTask,
length: u64,
) -> Result<(), Errno>where
L: LockBefore<BeforeFsNodeAppend>,
Trait Implementations§
Source§impl Clone for NamespaceNode
impl Clone for NamespaceNode
Source§fn clone(&self) -> NamespaceNode
fn clone(&self) -> NamespaceNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NamespaceNode
impl Debug for NamespaceNode
Source§impl<'a> From<&'a NamespaceNode> for Auditable<'a>
impl<'a> From<&'a NamespaceNode> for Auditable<'a>
Source§fn from(value: &'a NamespaceNode) -> Self
fn from(value: &'a NamespaceNode) -> Self
Source§impl Hash for NamespaceNode
impl Hash for NamespaceNode
Source§impl PartialEq for NamespaceNode
impl PartialEq for NamespaceNode
impl Eq for NamespaceNode
Auto Trait Implementations§
impl Freeze for NamespaceNode
impl !RefUnwindSafe for NamespaceNode
impl Send for NamespaceNode
impl Sync for NamespaceNode
impl Unpin for NamespaceNode
impl !UnwindSafe for NamespaceNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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