pub trait FileSystemOperations:
FileOperations
+ DirectoryOperations
+ MountOperations {
Show 26 methods
// Required methods
fn lookup_directory(&self, context: &mut Context, path: &Path) -> Result<()>;
fn lookup_file(
&self,
context: &mut Context,
path: &Path,
flags: Flags,
) -> Result<()>;
fn create_directory(
&self,
path: &Path,
attributes: &Attributes,
) -> Result<()>;
fn create_file(&self, path: &Path, attributes: &Attributes) -> Result<()>;
fn remove(&self, path: &Path) -> Result<()>;
fn rename(&self, source: &Path, destination: &Path) -> Result<()>;
fn get_attributes(
&self,
path: &Path,
attributes: &mut Attributes,
) -> Result<()>;
fn set_attributes(&self, path: &Path, attributes: &Attributes) -> Result<()>;
// Provided methods
fn supports_confined_namespace(&self) -> bool { ... }
fn supports_directory_entry_operations(&self) -> bool { ... }
fn lookup_directory_entry(
&self,
_parent: &Context,
_name: &str,
_context: &mut Context,
) -> Result<()> { ... }
fn lookup_file_entry(
&self,
_parent: &Context,
_name: &str,
_context: &mut Context,
_flags: Flags,
) -> Result<()> { ... }
fn create_directory_entry(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()> { ... }
fn create_file_entry(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()> { ... }
fn remove_entry(&self, _parent: &Context, _name: &str) -> Result<()> { ... }
fn rename_entry(
&self,
_source_parent: &Context,
_source_name: &str,
_destination_parent: &Context,
_destination_name: &str,
) -> Result<()> { ... }
fn link_entry(
&self,
_existing_parent: &Context,
_existing_name: &str,
_new_parent: &Context,
_new_name: &str,
) -> Result<()> { ... }
fn create_symlink_entry(
&self,
_target: &Path,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()> { ... }
fn read_symlink_entry(
&self,
_parent: &Context,
_name: &str,
_buffer: &mut [u8],
) -> Result<usize> { ... }
fn get_entry_attributes(
&self,
_parent: &Context,
_name: &str,
_attributes: &mut Attributes,
) -> Result<()> { ... }
fn set_entry_attributes(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()> { ... }
fn create_symlink(
&self,
_target: &Path,
_link: &Path,
_attributes: &Attributes,
) -> Result<()> { ... }
fn link(&self, _existing: &Path, _new: &Path) -> Result<()> { ... }
fn read_symlink(&self, _link: &Path, _buffer: &mut [u8]) -> Result<usize> { ... }
fn writable_attributes(&self) -> AttributeFlags { ... }
fn persistent_attributes(&self) -> AttributeFlags { ... }
}Required Methods§
fn lookup_directory(&self, context: &mut Context, path: &Path) -> Result<()>
fn lookup_file( &self, context: &mut Context, path: &Path, flags: Flags, ) -> Result<()>
Sourcefn create_directory(&self, path: &Path, attributes: &Attributes) -> Result<()>
fn create_directory(&self, path: &Path, attributes: &Attributes) -> Result<()>
Create a directory at path, persisting attributes with the new
entry in the same commit as the entry creation where the backend can.
attributes.get_mask() selects the fields to persist; callers pass the
mask already intersected with Self::writable_attributes. The backend
must apply or ignore the full mask at creation: the caller no longer
rewrites fields afterwards. An empty mask persists the backend defaults.
LittleFS costs two commits for a directory: the entry commit, then the
attributes commit (lfs_mkdir has no attribute configuration).
Sourcefn create_file(&self, path: &Path, attributes: &Attributes) -> Result<()>
fn create_file(&self, path: &Path, attributes: &Attributes) -> Result<()>
Create a regular file at path, persisting attributes with the new
entry in the same commit as the entry creation where the backend can.
LittleFS costs two commits for a file: the entry commit, then the
struct+attributes commit, which carries the custom attributes
atomically with the file through lfs_file_config.attrs. See
Self::create_directory for the mask contract.
Sourcefn remove(&self, path: &Path) -> Result<()>
fn remove(&self, path: &Path) -> Result<()>
Remove a file or directory from the file system.
Permanently deletes the specified file or directory. For directories, they must be empty before they can be removed.
§Arguments
context- File system contextpath- Path to the file or directory to remove
§Returns
Ok(())- File or directory successfully removedErr(IoErrorKind)- Error during removal
§Errors
crate::IoErrorKind::NotFound- File or directory doesn’t existcrate::IoErrorKind::PermissionDenied- Insufficient permissionscrate::IoErrorKind::DirectoryNotEmpty- Directory contains filescrate::IoErrorKind::ResourceBusy- File is currently in use
Sourcefn rename(&self, source: &Path, destination: &Path) -> Result<()>
fn rename(&self, source: &Path, destination: &Path) -> Result<()>
Rename or move a file or directory.
Changes the name or location of a file or directory. This can be used for both renaming within the same directory and moving between directories.
§Arguments
context- File system contextsource- Current path of the file or directorydestination- New path for the file or directory
§Returns
Ok(())- File or directory successfully renamed/movedErr(IoErrorKind)- Error during rename operation
§Errors
crate::IoErrorKind::NotFound- Source file doesn’t existcrate::IoErrorKind::AlreadyExists- Destination already existscrate::IoErrorKind::PermissionDenied- Insufficient permissions
Sourcefn get_attributes(&self, path: &Path, attributes: &mut Attributes) -> Result<()>
fn get_attributes(&self, path: &Path, attributes: &mut Attributes) -> Result<()>
Populate the requested attributes for a path.
On entry, attributes.get_mask() selects the fields requested by the
caller. On success, the mask must contain only fields that were both
requested and populated with meaningful values. Backends may omit
unavailable fields; they must not fabricate values to satisfy a request.
An empty mask is a successful no-op.
Sourcefn set_attributes(&self, path: &Path, attributes: &Attributes) -> Result<()>
fn set_attributes(&self, path: &Path, attributes: &Attributes) -> Result<()>
Change the fields selected by attributes.get_mask() for a path.
An empty mask is a successful no-op. If any requested field is
unsupported, the operation must return crate::IoErrorKind::Unsupported
before changing any supported field. A later backend I/O or permission
failure may occur after an earlier supported field was changed; this
operation does not promise rollback for such failures.
Provided Methods§
Sourcefn supports_confined_namespace(&self) -> bool
fn supports_confined_namespace(&self) -> bool
Return whether this backend enforces confined, non-following namespace semantics for operations beneath a directory root.
In-process storage backends with no native symlink traversal and
backends that implement Self::supports_directory_entry_operations
satisfy this contract. Backends using the default (false) are rejected
before dispatch during confined lookups.
Sourcefn supports_directory_entry_operations(&self) -> bool
fn supports_directory_entry_operations(&self) -> bool
Return whether this backend operates on single normal entry names
relative to an already-opened directory Context.
When true, the virtual file system traverses components using opened
directory handles and never asks the backend to re-resolve multi-component
parent paths after checks.
Sourcefn lookup_directory_entry(
&self,
_parent: &Context,
_name: &str,
_context: &mut Context,
) -> Result<()>
fn lookup_directory_entry( &self, _parent: &Context, _name: &str, _context: &mut Context, ) -> Result<()>
Open a child directory entry name inside the opened parent
directory into context, without following symbolic links.
name must be a single normal entry name without separators or dot
segments.
Sourcefn lookup_file_entry(
&self,
_parent: &Context,
_name: &str,
_context: &mut Context,
_flags: Flags,
) -> Result<()>
fn lookup_file_entry( &self, _parent: &Context, _name: &str, _context: &mut Context, _flags: Flags, ) -> Result<()>
Open a child regular file name inside the opened parent directory
into context, without following symbolic links.
Sourcefn create_directory_entry(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()>
fn create_directory_entry( &self, _parent: &Context, _name: &str, _attributes: &Attributes, ) -> Result<()>
Create a child directory name inside the opened parent directory,
persisting attributes with the new entry where the backend can.
Sourcefn create_file_entry(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()>
fn create_file_entry( &self, _parent: &Context, _name: &str, _attributes: &Attributes, ) -> Result<()>
Create a child regular file name inside the opened parent directory,
persisting attributes with the new entry where the backend can.
Sourcefn remove_entry(&self, _parent: &Context, _name: &str) -> Result<()>
fn remove_entry(&self, _parent: &Context, _name: &str) -> Result<()>
Remove a child entry name inside the opened parent directory
without following symbolic links.
Sourcefn rename_entry(
&self,
_source_parent: &Context,
_source_name: &str,
_destination_parent: &Context,
_destination_name: &str,
) -> Result<()>
fn rename_entry( &self, _source_parent: &Context, _source_name: &str, _destination_parent: &Context, _destination_name: &str, ) -> Result<()>
Rename source_name inside source_parent to destination_name inside
destination_parent without following symbolic links.
Sourcefn link_entry(
&self,
_existing_parent: &Context,
_existing_name: &str,
_new_parent: &Context,
_new_name: &str,
) -> Result<()>
fn link_entry( &self, _existing_parent: &Context, _existing_name: &str, _new_parent: &Context, _new_name: &str, ) -> Result<()>
Create new_name inside new_parent as a hard link to existing_name
inside existing_parent without following symbolic links.
Sourcefn create_symlink_entry(
&self,
_target: &Path,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()>
fn create_symlink_entry( &self, _target: &Path, _parent: &Context, _name: &str, _attributes: &Attributes, ) -> Result<()>
Create a symbolic link named name inside the opened parent
directory pointing to target, persisting attributes with the new
entry where the backend can.
Sourcefn read_symlink_entry(
&self,
_parent: &Context,
_name: &str,
_buffer: &mut [u8],
) -> Result<usize>
fn read_symlink_entry( &self, _parent: &Context, _name: &str, _buffer: &mut [u8], ) -> Result<usize>
Read the target of symbolic link name inside the opened parent
directory into buffer without following it.
Sourcefn get_entry_attributes(
&self,
_parent: &Context,
_name: &str,
_attributes: &mut Attributes,
) -> Result<()>
fn get_entry_attributes( &self, _parent: &Context, _name: &str, _attributes: &mut Attributes, ) -> Result<()>
Populate attributes for child entry name inside the opened parent
directory without following symbolic links.
Sourcefn set_entry_attributes(
&self,
_parent: &Context,
_name: &str,
_attributes: &Attributes,
) -> Result<()>
fn set_entry_attributes( &self, _parent: &Context, _name: &str, _attributes: &Attributes, ) -> Result<()>
Update attributes for child entry name inside the opened parent
directory without following symbolic links.
Sourcefn create_symlink(
&self,
_target: &Path,
_link: &Path,
_attributes: &Attributes,
) -> Result<()>
fn create_symlink( &self, _target: &Path, _link: &Path, _attributes: &Attributes, ) -> Result<()>
Create a symbolic link without resolving its target, persisting
attributes with the new entry where the backend can. Backends that do
not support native links or a durable Xila link representation may keep
the default implementation.
Sourcefn link(&self, _existing: &Path, _new: &Path) -> Result<()>
fn link(&self, _existing: &Path, _new: &Path) -> Result<()>
Create new as an additional directory entry for the existing,
non-directory object at existing, sharing its data. Backends without
hard links (including LittleFS) keep the default implementation, which
reports crate::IoErrorKind::Unsupported.
Sourcefn read_symlink(&self, _link: &Path, _buffer: &mut [u8]) -> Result<usize>
fn read_symlink(&self, _link: &Path, _buffer: &mut [u8]) -> Result<usize>
Copy the stored target of a symbolic link into a caller-owned buffer. This operation must inspect the final directory entry without following it.
Sourcefn writable_attributes(&self) -> AttributeFlags
fn writable_attributes(&self) -> AttributeFlags
Return the fields this backend can accept through set_attributes.
This is a capability hint for VFS-managed default metadata during file
creation and open. Explicit attribute mutations still call
set_attributes and receive the backend’s normal errors. Existing
implementations default to the historical all-fields behavior.
Sourcefn persistent_attributes(&self) -> AttributeFlags
fn persistent_attributes(&self) -> AttributeFlags
Return the fields that are stored durably by this filesystem.
The VFS uses this to select representations that rely on metadata surviving an unmount and remount. A writable field is not necessarily persistent (for example, a synthesized host attribute).