DirEntry

Struct DirEntry 

Source
pub struct DirEntry {
    pub node: FsNodeHandle,
    /* private fields */
}
Expand description

An entry in a directory.

This structure assigns a name to an FsNode in a given file system. An FsNode might have multiple directory entries, for example if there are more than one hard link to the same FsNode. In those cases, each hard link will have a different parent and a different local_name because each hard link has its own DirEntry object.

A directory cannot have more than one hard link, which means there is a single DirEntry for each Directory FsNode. That invariant lets us store the children for a directory in the DirEntry rather than in the FsNode.

Fields§

§node: FsNodeHandle

The FsNode referenced by this DirEntry.

A given FsNode can be referenced by multiple DirEntry objects, for example if there are multiple hard links to a given FsNode.

Implementations§

Source§

impl DirEntry

Source

pub fn read<'a>(self: &'a DirEntry) -> DirEntryReadGuard<'a>

Source

pub fn write<'a>(self: &'a DirEntry) -> DirEntryWriteGuard<'a>

Source

pub fn new_uncached( node: FsNodeHandle, parent: Option<DirEntryHandle>, local_name: FsString, ) -> DirEntryHandle

Source

pub fn new( node: FsNodeHandle, parent: Option<DirEntryHandle>, local_name: FsString, ) -> DirEntryHandle

Source

pub fn new_unrooted(node: FsNodeHandle) -> DirEntryHandle

Returns a new DirEntry for the given node without parent. The entry has no local name and is not cached.

Source

pub fn new_deleted( node: FsNodeHandle, parent: Option<DirEntryHandle>, local_name: FsString, ) -> DirEntryHandle

Returns a new DirEntry that is ready marked as having been deleted.

Source

pub fn open_anonymous<L>( self: &DirEntryHandle, locked: &mut Locked<L>, current_task: &CurrentTask, flags: OpenFlags, ) -> Result<FileHandle, Errno>

Returns a file handle to this entry, associated with an anonymous namespace.

Source

pub fn set_children( self: &DirEntryHandle, children: BTreeMap<FsString, DirEntryHandle>, )

Set the children of this DirEntry to the given children. This should only ever be called when children is empty.

Source

pub fn parent_or_self(self: &DirEntryHandle) -> DirEntryHandle

The parent DirEntry object or this DirEntry if this entry is the root.

Useful when traversing up the tree if you always want to find a parent (e.g., for “..”).

Be aware that the root of one file system might be mounted as a child in another file system. For that reason, consider walking the NamespaceNode tree (which understands mounts) rather than the DirEntry tree.

Source

pub fn is_reserved_name(name: &FsStr) -> bool

Whether the given name has special semantics as a directory entry.

Specifically, whether the name is empty (which means “self”), dot (which also means “self”), or dot dot (which means “parent”).

Source

pub fn component_lookup<L>( self: &DirEntryHandle, locked: &mut Locked<L>, current_task: &CurrentTask, mount: &MountInfo, name: &FsStr, ) -> Result<DirEntryHandle, Errno>

Look up a directory entry with the given name as direct child of this entry.

Source

pub fn create_entry<L>( self: &DirEntryHandle, locked: &mut Locked<L>, current_task: &CurrentTask, mount: &MountInfo, name: &FsStr, create_node_fn: impl FnOnce(&mut Locked<L>, &FsNodeHandle, &MountInfo, &FsStr) -> Result<FsNodeHandle, Errno>, ) -> Result<DirEntryHandle, Errno>

Creates a new DirEntry

The create_node_fn function is called to create the underlying FsNode for the DirEntry.

If the entry already exists, create_node_fn is not called, and EEXIST is returned.

Source

pub fn get_or_create_entry<L>( self: &DirEntryHandle, locked: &mut Locked<L>, current_task: &CurrentTask, mount: &MountInfo, name: &FsStr, create_node_fn: impl FnOnce(&mut Locked<L>, &FsNodeHandle, &MountInfo, &FsStr) -> Result<FsNodeHandle, Errno>, ) -> Result<DirEntryHandle, Errno>

Creates a new DirEntry. Works just like create_entry, except if the entry already exists, it is returned.

Source

pub fn create_dir_for_testing<L>( self: &DirEntryHandle, locked: &mut Locked<L>, current_task: &CurrentTask, name: &FsStr, ) -> Result<DirEntryHandle, Errno>

Source

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

Creates an anonymous file.

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

Used by O_TMPFILE.

Source

pub fn is_descendant_of(self: &DirEntryHandle, other: &DirEntryHandle) -> bool

Returns whether this entry is a descendant of |other|.

Source

pub fn rename<L>( locked: &mut Locked<L>, current_task: &CurrentTask, old_parent: &DirEntryHandle, old_mount: &MountInfo, old_basename: &FsStr, new_parent: &DirEntryHandle, new_mount: &MountInfo, new_basename: &FsStr, flags: RenameFlags, ) -> Result<(), Errno>

Rename the file with old_basename in old_parent to new_basename in new_parent.

old_parent and new_parent must belong to the same file system.

Source

pub fn get_children<F, T>(&self, callback: F) -> T
where F: FnOnce(&BTreeMap<FsString, Weak<DirEntry>>) -> T,

Source

pub fn remove_child(&self, name: &FsStr, mounts: &Mounts)

Remove the child with the given name from the children cache. The child must not have any mounts.

Source

pub fn notify(&self, event_mask: InotifyMask)

Notifies watchers on the current node and its parent about an event.

Notifies watchers on the current node and its parent about an event.

Used for FSNOTIFY_EVENT_INODE events, which ignore IN_EXCL_UNLINK.

Source

pub fn has_mounts(&self) -> bool

Returns true if this entry has mounts.

Source

pub fn set_has_mounts(&self, v: bool)

Records whether or not the entry has mounts.

Trait Implementations§

Source§

impl Debug for DirEntry

Source§

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

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

impl Drop for DirEntry

The Drop trait for DirEntry removes the entry from the child list of the parent entry, which means we cannot drop DirEntry objects while holding a lock on the parent’s child list.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Source§

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

Converts to this type from the input type.

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, 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<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, 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>,