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§
Sourcefn create_file_ops(
&self,
locked: &mut Locked<FileOpsCore>,
node: &FsNode,
_current_task: &CurrentTask,
flags: OpenFlags,
) -> Result<Box<dyn FileOps>, Errno>
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.
Sourcefn mknod(
&self,
locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_mode: FileMode,
_dev: DeviceType,
_owner: FsCred,
) -> Result<FsNodeHandle, Errno>
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.
Sourcefn mkdir(
&self,
locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_mode: FileMode,
_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>
Create and return the given child node as a subdirectory.
Sourcefn create_symlink(
&self,
locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_target: &FsStr,
_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>
Creates a symlink with the given target path.
Sourcefn unlink(
&self,
locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_child: &FsNodeHandle,
) -> Result<(), Errno>
fn unlink( &self, locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno>
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§
Sourcefn 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 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.
Sourcefn create_dir_entry_ops(&self) -> Box<dyn DirEntryOps>
fn create_dir_entry_ops(&self) -> Box<dyn DirEntryOps>
Build the DirEntryOps for a new [DirEntry] that will be associated
to this node.
Sourcefn lookup(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
name: &FsStr,
) -> Result<FsNodeHandle, Errno>
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.
Sourcefn create_tmpfile(
&self,
_node: &FsNode,
_current_task: &CurrentTask,
_mode: FileMode,
_owner: FsCred,
) -> Result<FsNodeHandle, Errno>
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.
Sourcefn readlink(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
) -> Result<SymlinkTarget, Errno>
fn readlink( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, ) -> Result<SymlinkTarget, Errno>
Reads the symlink from this node.
Sourcefn link(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_child: &FsNodeHandle,
) -> Result<(), Errno>
fn link( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, _child: &FsNodeHandle, ) -> Result<(), Errno>
Create a hard link with the given name to the given child.
Sourcefn 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 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.
Sourcefn truncate(
&self,
_locked: &mut Locked<FileOpsCore>,
_guard: &AppendLockGuard<'_>,
_node: &FsNode,
_current_task: &CurrentTask,
_length: u64,
) -> Result<(), Errno>
fn truncate( &self, _locked: &mut Locked<FileOpsCore>, _guard: &AppendLockGuard<'_>, _node: &FsNode, _current_task: &CurrentTask, _length: u64, ) -> Result<(), Errno>
Change the length of the file.
Sourcefn allocate(
&self,
_locked: &mut Locked<FileOpsCore>,
_guard: &AppendLockGuard<'_>,
_node: &FsNode,
_current_task: &CurrentTask,
_mode: FallocMode,
_offset: u64,
_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>
Manipulate allocated disk space for the file.
Sourcefn initial_info(&self, _info: &mut FsNodeInfo)
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.
Sourcefn 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 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.
Sourcefn update_attributes(
&self,
_locked: &mut Locked<FileOpsCore>,
_current_task: &CurrentTask,
_info: &FsNodeInfo,
_has: zxio_node_attr_has_t,
) -> Result<(), Errno>
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.
Sourcefn get_xattr(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_max_size: usize,
) -> Result<ValueOrSize<FsString>, Errno>
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.
Sourcefn set_xattr(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_name: &FsStr,
_value: &FsStr,
_op: XattrOp,
) -> Result<(), Errno>
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.
fn remove_xattr( &self, _locked: &mut Locked<FileOpsCore>, _node: &FsNode, _current_task: &CurrentTask, _name: &FsStr, ) -> Result<(), Errno>
Sourcefn list_xattrs(
&self,
_locked: &mut Locked<FileOpsCore>,
_node: &FsNode,
_current_task: &CurrentTask,
_max_size: usize,
) -> Result<ValueOrSize<Vec<FsString>>, Errno>
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.
Sourcefn forget(
self: Box<Self>,
_locked: &mut Locked<FileOpsCore>,
_current_task: &CurrentTask,
_info: FsNodeInfo,
) -> Result<(), Errno>
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.
Sourcefn enable_fsverity(
&self,
_descriptor: &fsverity_descriptor,
) -> Result<(), Errno>
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.
Sourcefn get_fsverity_descriptor(
&self,
_log_blocksize: u8,
) -> Result<fsverity_descriptor, Errno>
fn get_fsverity_descriptor( &self, _log_blocksize: u8, ) -> Result<fsverity_descriptor, Errno>
Read fsverity descriptor, if the node is fsverity-enabled. Else returns ENODATA.
Sourcefn internal_name(&self, _node: &FsNode) -> Option<FsString>
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.