FsNodeOps

Trait FsNodeOps 

Source
pub trait FsNodeOps:
    Send
    + Sync
    + AsAny
    + 'static {
Show 26 methods // Required methods fn create_file_ops( &self, locked: &mut Locked<FileOpsCore>, node: &FsNode, _current_task: &CurrentTask, flags: OpenFlags, ) -> Result<Box<dyn FileOps>, Errno>; fn mknod( &self, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _dev: DeviceType, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn mkdir( &self, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn create_symlink( &self, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _target: &FsStr, _owner: FsCred, ) -> Result<FsNodeHandle, Errno>; fn unlink( &self, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno>; // Provided methods fn check_access( &self, _locked: &mut Locked<FileOpsCore>, node: &FsNode, current_task: &CurrentTask, access: PermissionFlags, info: &RwLock<FsNodeInfo>, reason: CheckAccessReason, audit_context: Auditable<'_>, ) -> Result<(), Errno> { ... } fn create_dir_entry_ops(&self) -> Box<dyn DirEntryOps> { ... } fn lookup( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, name: &FsStr, ) -> Result<FsNodeHandle, Errno> { ... } fn create_tmpfile( &self, _node: &FsNode, _current_task: &CurrentTask, _mode: FileMode, _owner: FsCred, ) -> Result<FsNodeHandle, Errno> { ... } fn readlink( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, ) -> Result<SymlinkTarget, Errno> { ... } fn link( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno> { ... } fn append_lock_read<'a>( &'a self, locked: &'a mut Locked<BeforeFsNodeAppend>, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<(RwQueueReadGuard<'a, FsNodeAppend>, &'a mut Locked<FsNodeAppend>), Errno> { ... } fn truncate( &self, _locked: &mut Locked<FileOpsCore>, _guard: &AppendLockGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _length: u64, ) -> Result<(), Errno> { ... } fn allocate( &self, _locked: &mut Locked<FileOpsCore>, _guard: &AppendLockGuard<'_>, _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, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, info: &'a RwLock<FsNodeInfo>, ) -> Result<RwLockReadGuard<'a, FsNodeInfo>, Errno> { ... } fn update_attributes( &self, _locked: &mut Locked<FileOpsCore>, _current_task: &CurrentTask, _info: &FsNodeInfo, _has: zxio_node_attr_has_t, ) -> Result<(), Errno> { ... } fn get_xattr( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _max_size: usize, ) -> Result<ValueOrSize<FsString>, Errno> { ... } fn set_xattr( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _value: &FsStr, _op: XattrOp, ) -> Result<(), Errno> { ... } fn remove_xattr( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<(), Errno> { ... } fn list_xattrs( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _max_size: usize, ) -> Result<ValueOrSize<Vec<FsString>>, Errno> { ... } fn forget( self: Box<Self>, _locked: &mut Locked<FileOpsCore>, _current_task: &CurrentTask, _info: FsNodeInfo, ) -> Result<(), Errno> { ... } fn enable_fsverity( &self, _descriptor: &fsverity_descriptor, ) -> Result<(), Errno> { ... } fn get_fsverity_descriptor( &self, _log_blocksize: u8, ) -> Result<fsverity_descriptor, Errno> { ... } fn internal_name(&self, _node: &FsNode) -> Option<FsString> { ... } fn node_key(&self, node: &FsNode) -> ino_t { ... }
}

Required Methods§

Source

fn create_file_ops( &self, locked: &mut Locked<FileOpsCore>, 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, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _mode: FileMode, _dev: DeviceType, _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, locked: &mut Locked<FileOpsCore>, _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, _locked: &mut Locked<FileOpsCore>, node: &FsNode, current_task: &CurrentTask, access: PermissionFlags, info: &RwLock<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, _locked: &mut Locked<FileOpsCore>, _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 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, locked: &'a mut Locked<BeforeFsNodeAppend>, node: &'a FsNode, current_task: &CurrentTask, ) -> Result<(RwQueueReadGuard<'a, FsNodeAppend>, &'a mut Locked<FsNodeAppend>), 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 truncate( &self, _locked: &mut Locked<FileOpsCore>, _guard: &AppendLockGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _length: u64, ) -> Result<(), Errno>

Change the length of the file.

Source

fn allocate( &self, _locked: &mut Locked<FileOpsCore>, _guard: &AppendLockGuard<'_>, _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, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, info: &'a RwLock<FsNodeInfo>, ) -> Result<RwLockReadGuard<'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 update_attributes( &self, _locked: &mut Locked<FileOpsCore>, _current_task: &CurrentTask, _info: &FsNodeInfo, _has: zxio_node_attr_has_t, ) -> Result<(), Errno>

Update node attributes persistently.

Source

fn get_xattr( &self, _locked: &mut Locked<FileOpsCore>, _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, _locked: &mut Locked<FileOpsCore>, _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, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<(), Errno>

Source

fn list_xattrs( &self, _locked: &mut Locked<FileOpsCore>, _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>, _locked: &mut Locked<FileOpsCore>, _current_task: &CurrentTask, _info: FsNodeInfo, ) -> Result<(), Errno>

Called when the FsNode is freed by the Kernel.

Source

fn enable_fsverity( &self, _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 internal_name(&self, _node: &FsNode) -> Option<FsString>

Returns a descriptive name for this node, suitable to report to userspace in situations where the node’s path is unavailable (e.g. because it is anonymous, and has no path). If no name is returned then a default name of the form “<class:[<node_id>]” will be used.

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.

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.

Implementations on Foreign Types§

Source§

impl FsNodeOps for Arc<SimpleDirectory>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl FsNodeOps for Arc<Namespace>

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§