Skip to main content

FsNodeOps

Trait FsNodeOps 

Source
pub trait FsNodeOps:
    Send
    + Sync
    + AsAny
    + 'static {
Show 30 methods // Required methods fn create_file_ops( &self, node: &FsNode, _current_task: &CurrentTask, flags: OpenFlags, ) -> Result<Box<dyn FileOps>, Errno>; fn mknod( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _dev: DeviceId, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn mkdir( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn create_symlink( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _target: &FsStr, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn unlink( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno>; // Provided methods fn check_access( &self, node: &FsNode, current_task: &CurrentTask, access: PermissionFlags, info: &DynamicLockDepRwLock<FsNodeInfo>, reason: CheckAccessReason, audit_context: Auditable<'_>, ) -> Result<(), Errno> { ... } fn create_dir_entry_ops(&self) -> Box<dyn DirEntryOps> { ... } fn lookup( &self, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, ) -> Result<FsNodeHandle, Errno> { ... } fn has_lookup_pipelined(&self) -> bool { ... } fn lookup_pipelined( &self, _node: &FsNode, _current_task: &CurrentTask, _names: &[&FsStr], ) -> LookupVec<Result<FsNodeHandle, Errno>> { ... } fn create_tmpfile( &self, _node: &FsNode, _current_task: &CurrentTask, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno> { ... } fn readlink( &self, _node: &FsNode, _current_task: &CurrentTask, ) -> Result<SymlinkTarget, Errno> { ... } fn link( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno> { ... } fn append_lock_read<'a>( &'a self, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<AppendLockGuard<'a>, Errno> { ... } fn append_lock_write<'a>( &'a self, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<AppendLockWriteGuard<'a>, Errno> { ... } fn truncate( &self, _guard: &AppendLockWriteGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _length: u64, ) -> Result<(), Errno> { ... } fn allocate( &self, _guard: &AppendLockWriteGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _mode: FallocMode, _offset: u64, _length: u64, ) -> Result<(), Errno> { ... } fn initial_info(&self, _info: &mut FsNodeInfo) { ... } fn fetch_and_refresh_info<'a>( &self, _node: &FsNode, _current_task: &CurrentTask, info: &'a DynamicLockDepRwLock<FsNodeInfo>, ) -> Result<LockDepReadGuard<'a, FsNodeInfo>, Errno> { ... } fn sync( &self, _node: &FsNode, _current_task: &CurrentTask, ) -> Result<(), Errno> { ... } fn update_attributes( &self, _node: &FsNode, _current_task: &CurrentTask, _info: &FsNodeInfo, _has: zxio_node_attr_has_t, ) -> Result<(), Errno> { ... } fn get_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _max_size: usize, ) -> Result<ValueOrSize<FsString>, Errno> { ... } fn set_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _value: &FsStr, _op: XattrOp, ) -> Result<(), Errno> { ... } fn remove_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<(), Errno> { ... } fn list_xattrs( &self, _node: &FsNode, _current_task: &CurrentTask, _max_size: usize, ) -> Result<ValueOrSize<Vec<FsString>>, Errno> { ... } fn forget( self: Box<Self>, _current_task: &CurrentTask, _info: FsNodeInfo, ) -> Result<(), Errno> { ... } fn enable_fsverity( &self, _node: &FsNode, _current_task: &CurrentTask, _descriptor: &fsverity_descriptor, ) -> Result<(), Errno> { ... } fn get_fsverity_descriptor( &self, _log_blocksize: u8, ) -> Result<fsverity_descriptor, Errno> { ... } fn node_key(&self, node: &FsNode) -> ino_t { ... } fn get_size( &self, node: &FsNode, current_task: &CurrentTask, ) -> Result<usize, Errno> { ... }
}

Required Methods§

Source

fn create_file_ops( &self, node: &FsNode, _current_task: &CurrentTask, flags: OpenFlags, ) -> Result<Box<dyn FileOps>, Errno>

Build the FileOps for the file associated to this node.

The returned FileOps will be used to create a FileObject, which might be assigned an FdNumber.

Source

fn mknod( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _dev: DeviceId, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Create and return the given child node.

The mode field of the FsNodeInfo indicates what kind of child to create.

This function is never called with FileMode::IFDIR. The mkdir function is used to create directories instead.

Source

fn mkdir( &self, node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Create and return the given child node as a subdirectory.

Creates a symlink with the given target path.

Remove the child with the given name, if the child exists.

The UnlinkKind parameter indicates whether the caller intends to unlink a directory or a non-directory child.

Provided Methods§

Source

fn check_access( &self, node: &FsNode, current_task: &CurrentTask, access: PermissionFlags, info: &DynamicLockDepRwLock<FsNodeInfo>, reason: CheckAccessReason, audit_context: Auditable<'_>, ) -> Result<(), Errno>

Delegate the access check to the node.

Source

fn create_dir_entry_ops(&self) -> Box<dyn DirEntryOps>

Build the DirEntryOps for a new [DirEntry] that will be associated to this node.

Source

fn lookup( &self, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, ) -> Result<FsNodeHandle, Errno>

Find an existing child node and populate the child parameter. Return the node.

The child parameter is an empty node. Operations other than initialize may panic before initialize is called.

Source

fn has_lookup_pipelined(&self) -> bool

Returns whether this node supports pipelined lookups.

Source

fn lookup_pipelined( &self, _node: &FsNode, _current_task: &CurrentTask, _names: &[&FsStr], ) -> LookupVec<Result<FsNodeHandle, Errno>>

Find multiple children nodes in sequence.

This can be used to pipeline lookups in filesystems that support it.

Source

fn create_tmpfile( &self, _node: &FsNode, _current_task: &CurrentTask, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Creates an anonymous file.

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

Used by O_TMPFILE.

Reads the symlink from this node.

Create a hard link with the given name to the given child.

Source

fn append_lock_read<'a>( &'a self, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<AppendLockGuard<'a>, Errno>

Acquire the necessary append lock for the operations that depend on them. Should be done before calling allocate or truncate to avoid lock ordering issues.

Source

fn append_lock_write<'a>( &'a self, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<AppendLockWriteGuard<'a>, Errno>

Acquire the necessary append lock for operations that need exclusive access (e.g., write append).

Source

fn truncate( &self, _guard: &AppendLockWriteGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _length: u64, ) -> Result<(), Errno>

Change the length of the file.

Source

fn allocate( &self, _guard: &AppendLockWriteGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _mode: FallocMode, _offset: u64, _length: u64, ) -> Result<(), Errno>

Manipulate allocated disk space for the file.

Source

fn initial_info(&self, _info: &mut FsNodeInfo)

Update the supplied info with initial state (e.g. size) for the node.

FsNode calls this method when created, to allow the FsNodeOps to set appropriate initial values in the FsNodeInfo.

Source

fn fetch_and_refresh_info<'a>( &self, _node: &FsNode, _current_task: &CurrentTask, info: &'a DynamicLockDepRwLock<FsNodeInfo>, ) -> Result<LockDepReadGuard<'a, FsNodeInfo>, Errno>

Update node.info as needed.

FsNode calls this method before converting the FsNodeInfo struct into the uapi::stat struct to give the file system a chance to update this data before it is used by clients.

File systems that keep the FsNodeInfo up-to-date do not need to override this function.

Return a read guard for the updated information.

Source

fn sync(&self, _node: &FsNode, _current_task: &CurrentTask) -> Result<(), Errno>

Syncs cached data to persistent storage.

Source

fn update_attributes( &self, _node: &FsNode, _current_task: &CurrentTask, _info: &FsNodeInfo, _has: zxio_node_attr_has_t, ) -> Result<(), Errno>

Update node attributes persistently.

Source

fn get_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _max_size: usize, ) -> Result<ValueOrSize<FsString>, Errno>

Get an extended attribute on the node.

An implementation can systematically return a value. Otherwise, if max_size is 0, it can instead return the size of the attribute, and can return an ERANGE error if max_size is not 0, and lesser than the required size.

Source

fn set_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _value: &FsStr, _op: XattrOp, ) -> Result<(), Errno>

Set an extended attribute on the node.

Source

fn remove_xattr( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<(), Errno>

Source

fn list_xattrs( &self, _node: &FsNode, _current_task: &CurrentTask, _max_size: usize, ) -> Result<ValueOrSize<Vec<FsString>>, Errno>

An implementation can systematically return a value. Otherwise, if max_size is 0, it can instead return the size of the 0 separated string needed to represent the value, and can return an ERANGE error if max_size is not 0, and lesser than the required size.

Source

fn forget( self: Box<Self>, _current_task: &CurrentTask, _info: FsNodeInfo, ) -> Result<(), Errno>

Called when the FsNode is freed by the Kernel.

Source

fn enable_fsverity( &self, _node: &FsNode, _current_task: &CurrentTask, _descriptor: &fsverity_descriptor, ) -> Result<(), Errno>

Marks that FS-Verity is being built. Writes fsverity descriptor and merkle tree, the latter computed by the filesystem. This should ensure there are no writable file handles. Returns EEXIST if the file was already fsverity-enabled. Returns EBUSY if this ioctl was already running on this file.

Source

fn get_fsverity_descriptor( &self, _log_blocksize: u8, ) -> Result<fsverity_descriptor, Errno>

Read fsverity descriptor, if the node is fsverity-enabled. Else returns ENODATA.

Source

fn node_key(&self, node: &FsNode) -> ino_t

The key used to identify this node in the file system’s node cache.

For many file systems, this will be the same as the inode number. However, some file systems, such as FUSE, sometimes use different node_key and inode numbers.

Source

fn get_size( &self, node: &FsNode, current_task: &CurrentTask, ) -> Result<usize, Errno>

Returns the size of the file.

Trait Implementations§

Source§

impl<T> From<T> for Box<dyn FsNodeOps>
where T: FsNodeOps,

Source§

fn from(ops: T) -> Box<dyn FsNodeOps>

Converts to this type from the input type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FsNodeOps for Arc<Namespace>

Source§

fn lookup( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<FsNodeHandle, Errno>

Source§

fn mknod( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _dev: DeviceId, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Source§

fn mkdir( &self, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Source§

fn create_file_ops( &self, _node: &FsNode, _current_task: &CurrentTask, _flags: OpenFlags, ) -> Result<Box<dyn FileOps>, Errno>

Source§

impl FsNodeOps for Arc<SimpleDirectory>

Source§

fn check_access( &self, node: &FsNode, current_task: &CurrentTask, permission_flags: PermissionFlags, info: &DynamicLockDepRwLock<FsNodeInfo>, reason: CheckAccessReason, audit_context: Auditable<'_>, ) -> Result<(), Errno>

Source§

fn mkdir( &self, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Source§

fn mknod( &self, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, _mode: FileMode, _dev: DeviceId, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>

Source§

fn create_file_ops( &self, _node: &FsNode, _current_task: &CurrentTask, _flags: OpenFlags, ) -> Result<Box<dyn FileOps>, Errno>

Source§

fn lookup( &self, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, ) -> Result<FsNodeHandle, Errno>

Implementors§