pub struct ArchiveFs { /* private fields */ }Expand description
Generic archive filesystem: one implementation of the read side of
Filesystem over an ArchiveIndex, plus
an optional ArchiveBuilder for the write (repack) path.
Implementations§
Source§impl ArchiveFs
impl ArchiveFs
Sourcepub fn from_index(index: ArchiveIndex) -> Self
pub fn from_index(index: ArchiveIndex) -> Self
Read-only handle over an already-scanned index.
Sourcepub fn writer(kind: &'static str, builder: Box<dyn ArchiveBuilder>) -> Self
pub fn writer(kind: &'static str, builder: Box<dyn ArchiveBuilder>) -> Self
Write handle: an empty index plus a format-specific builder.
kind is the format’s short id (for errors).
Trait Implementations§
Source§impl Filesystem for ArchiveFs
impl Filesystem for ArchiveFs
Source§fn streams_immediately(&self) -> bool
fn streams_immediately(&self) -> bool
The builder writes each entry’s header + body straight to the
device cursor as create_file is called, so the streaming repack
path can hand us a body without spooling it to a temp file first
(small bodies buffer in RAM; larger ones spill, same as every other
stream-through backend).
Source§fn create_file(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
src: FileSource,
meta: FileMeta,
) -> Result<()>
fn create_file( &mut self, dev: &mut dyn BlockDevice, path: &Path, src: FileSource, meta: FileMeta, ) -> Result<()>
Create a regular file at
path populated from src with metadata meta.Source§fn create_dir(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
meta: FileMeta,
) -> Result<()>
fn create_dir( &mut self, dev: &mut dyn BlockDevice, path: &Path, meta: FileMeta, ) -> Result<()>
Create a directory at
path.Source§fn create_symlink(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
target: &Path,
meta: FileMeta,
) -> Result<()>
fn create_symlink( &mut self, dev: &mut dyn BlockDevice, path: &Path, target: &Path, meta: FileMeta, ) -> Result<()>
Create a symbolic link at
path pointing at target.Source§fn create_device(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
kind: DeviceKind,
major: u32,
minor: u32,
meta: FileMeta,
) -> Result<()>
fn create_device( &mut self, dev: &mut dyn BlockDevice, path: &Path, kind: DeviceKind, major: u32, minor: u32, meta: FileMeta, ) -> Result<()>
Create a device node / FIFO / socket.
Source§fn remove(&mut self, _dev: &mut dyn BlockDevice, _path: &Path) -> Result<()>
fn remove(&mut self, _dev: &mut dyn BlockDevice, _path: &Path) -> Result<()>
Remove a file, directory, or special entry. Returns
Error::InvalidArgument for a
non-empty directory.Source§fn list(
&mut self,
_dev: &mut dyn BlockDevice,
path: &Path,
) -> Result<Vec<DirEntry>>
fn list( &mut self, _dev: &mut dyn BlockDevice, path: &Path, ) -> Result<Vec<DirEntry>>
List the entries of a directory.
Source§fn read_file<'a>(
&'a mut self,
dev: &'a mut dyn BlockDevice,
path: &Path,
) -> Result<Box<dyn Read + 'a>>
fn read_file<'a>( &'a mut self, dev: &'a mut dyn BlockDevice, path: &Path, ) -> Result<Box<dyn Read + 'a>>
Open a regular file for reading. Returns a boxed streaming reader
that borrows both
self (for filesystem metadata) and dev (for
actual block reads), so it must outlive both.Source§fn open_file_ro<'a>(
&'a mut self,
dev: &'a mut dyn BlockDevice,
path: &Path,
) -> Result<Box<dyn FileReadHandle + 'a>>
fn open_file_ro<'a>( &'a mut self, dev: &'a mut dyn BlockDevice, path: &Path, ) -> Result<Box<dyn FileReadHandle + 'a>>
Open a regular file for random-access reads with no
writes. The returned handle is
Read + Seek and reports the
file’s total length via len(). Every backend that can
surface file contents should implement this — including the
immutable formats (ISO 9660 / SquashFS / tar / GRF) where
open_file_rw is unsupported but seeking inside a file is
still meaningful. Read moreSource§fn flush(&mut self, dev: &mut dyn BlockDevice) -> Result<()>
fn flush(&mut self, dev: &mut dyn BlockDevice) -> Result<()>
Persist outstanding dirty state to the device.
Source§fn image_len(&self) -> Option<u64>
fn image_len(&self) -> Option<u64>
For archive / streaming writers backed by a pre-sized device:
the exact number of bytes the output occupies after
flush.
The backing file is provisioned generously (and sparsely), so
the caller truncates it to this length — an archive must be
exactly its own size, not padded with a zero tail. Read moreSource§fn mutation_capability(&self) -> MutationCapability
fn mutation_capability(&self) -> MutationCapability
Capability of this filesystem with respect to mutating an
already-flushed image. Three cases: Read more
Source§fn read_symlink(
&mut self,
_dev: &mut dyn BlockDevice,
path: &Path,
) -> Result<PathBuf>
fn read_symlink( &mut self, _dev: &mut dyn BlockDevice, path: &Path, ) -> Result<PathBuf>
Read a symbolic link’s target. Default returns
Unsupported
— filesystems that have symlinks (ext, tar, xfs, hfs+, ntfs,
squashfs, iso 9660 via Rock Ridge) override.Source§fn getattr(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
) -> Result<FileAttrs>
fn getattr( &mut self, dev: &mut dyn BlockDevice, path: &Path, ) -> Result<FileAttrs>
Full attributes for
path. Used by the FUSE adapter to populate
getattr and lookup replies; also handy for any consumer that
wants a complete stat-like result without juggling
Self::list + the file handle. Read moreSource§fn set_attrs(
&mut self,
_dev: &mut dyn BlockDevice,
_path: &Path,
_attrs: SetAttrs,
) -> Result<()>
fn set_attrs( &mut self, _dev: &mut dyn BlockDevice, _path: &Path, _attrs: SetAttrs, ) -> Result<()>
Update attributes on
path. Fields set to None in attrs
are left unchanged. Backends that can’t change a given field
silently ignore it (FAT, for example, has no uid/gid concept). Read morefn create_file_streaming( &mut self, dev: &mut dyn BlockDevice, path: &Path, body: &mut dyn Read, len: u64, meta: FileMeta, ) -> Result<()>
Source§fn open_file_rw<'a>(
&'a mut self,
_dev: &'a mut dyn BlockDevice,
_path: &Path,
_flags: OpenFlags,
_meta: Option<FileMeta>,
) -> Result<Box<dyn FileHandle + 'a>>
fn open_file_rw<'a>( &'a mut self, _dev: &'a mut dyn BlockDevice, _path: &Path, _flags: OpenFlags, _meta: Option<FileMeta>, ) -> Result<Box<dyn FileHandle + 'a>>
Open a regular file for in-place reads + writes at byte
granularity. The returned handle is
Read + Write + Seek;
dropping it persists any pending bytes (each implementation
chooses whether Write::write is eager or buffered). Read moreSource§fn supports_mutation(&self) -> bool
fn supports_mutation(&self) -> bool
Convenience shortcut: can this filesystem satisfy
create_file / remove? Equivalent to
mutation_capability().supports_add_remove(). Returns true
for both MutationCapability::Mutable and
MutationCapability::WholeFileOnly — callers that need
finer detail (e.g. “can I patch byte N?”) should query
Self::mutation_capability directly.Source§fn clone_capability(&self) -> CloneCapability
fn clone_capability(&self) -> CloneCapability
Reflink / clone capability of this filesystem — does it natively
share extents, and at what granularity? Read more
Source§fn clone_file(
&mut self,
dev: &mut dyn BlockDevice,
src: &Path,
dst: &Path,
) -> Result<()>
fn clone_file( &mut self, dev: &mut dyn BlockDevice, src: &Path, dst: &Path, ) -> Result<()>
Clone the file at
src into a new file at dst. Reflink-capable
backends share extents (zero data copy, refcount-btree updates);
everything else falls back to the default byte-copy. Read moreSource§fn clone_range(
&mut self,
_dev: &mut dyn BlockDevice,
_src: &Path,
_src_off: u64,
_dst: &Path,
_dst_off: u64,
_len: u64,
) -> Result<()>
fn clone_range( &mut self, _dev: &mut dyn BlockDevice, _src: &Path, _src_off: u64, _dst: &Path, _dst_off: u64, _len: u64, ) -> Result<()>
Clone an arbitrary byte range
src[src_off..src_off+len] into
dst[dst_off..dst_off+len]. Reflink-capable backends share the
underlying extents (BTRFS_IOC_CLONE_RANGE / FICLONERANGE
semantics: writes through either side trigger COW). Read moreSource§fn truncate(
&mut self,
_dev: &mut dyn BlockDevice,
_path: &Path,
_new_size: u64,
) -> Result<()>
fn truncate( &mut self, _dev: &mut dyn BlockDevice, _path: &Path, _new_size: u64, ) -> Result<()>
Resize
path to new_size bytes. Equivalent to
FileHandle::set_len reached through a path. Growing fills
with zeros; shrinking discards trailing bytes and frees blocks. Read moreSource§fn rename(
&mut self,
_dev: &mut dyn BlockDevice,
_old_path: &Path,
_new_path: &Path,
) -> Result<()>
fn rename( &mut self, _dev: &mut dyn BlockDevice, _old_path: &Path, _new_path: &Path, ) -> Result<()>
Rename
old_path to new_path. Cross-directory moves and
directory renames are both in scope — the operation must
preserve the target inode (so hardlinks survive). Read moreSource§fn hardlink(
&mut self,
_dev: &mut dyn BlockDevice,
_target_path: &Path,
_new_path: &Path,
) -> Result<()>
fn hardlink( &mut self, _dev: &mut dyn BlockDevice, _target_path: &Path, _new_path: &Path, ) -> Result<()>
Add a new directory entry at
new_path that points at the
existing inode at target_path — a POSIX hard link. Read moreSource§fn list_xattrs(
&mut self,
_dev: &mut dyn BlockDevice,
_path: &Path,
) -> Result<Vec<XattrPair>>
fn list_xattrs( &mut self, _dev: &mut dyn BlockDevice, _path: &Path, ) -> Result<Vec<XattrPair>>
List the extended attributes attached to
path, with both
names and values. The FUSE adapter splits this into
listxattr / getxattr itself; we surface both at once so
backends don’t need two parallel walkers. Read moreSource§fn set_xattr(
&mut self,
_dev: &mut dyn BlockDevice,
_path: &Path,
_name: &str,
_value: &[u8],
) -> Result<()>
fn set_xattr( &mut self, _dev: &mut dyn BlockDevice, _path: &Path, _name: &str, _value: &[u8], ) -> Result<()>
Write or replace the xattr
name on path. Returns
Unsupported when the backend can’t store xattrs.Source§fn set_xattrs(
&mut self,
dev: &mut dyn BlockDevice,
path: &Path,
xattrs: &[XattrPair],
) -> Result<()>
fn set_xattrs( &mut self, dev: &mut dyn BlockDevice, path: &Path, xattrs: &[XattrPair], ) -> Result<()>
Write a whole set of xattrs onto
path at once, replacing any
existing set. Backends that store xattrs in a single on-disk
structure (ext’s external attribute block) override this to write
them atomically — applying them one at a time via set_xattr
would orphan the previous block on each call. The default applies
them individually.Source§fn remove_xattr(
&mut self,
_dev: &mut dyn BlockDevice,
_path: &Path,
_name: &str,
) -> Result<()>
fn remove_xattr( &mut self, _dev: &mut dyn BlockDevice, _path: &Path, _name: &str, ) -> Result<()>
Remove the xattr
name from path. Returns Unsupported
when the backend can’t store xattrs.Source§fn statfs(&mut self, _dev: &mut dyn BlockDevice) -> Result<StatFs>
fn statfs(&mut self, _dev: &mut dyn BlockDevice) -> Result<StatFs>
Filesystem-level capacity stats. The FUSE adapter calls this
to answer
statfs; the CLI’s info command could too. Read moreSource§fn total_file_bytes(&mut self, dev: &mut dyn BlockDevice) -> Result<u64>
fn total_file_bytes(&mut self, dev: &mut dyn BlockDevice) -> Result<u64>
Recursive sum of all regular-file sizes in the filesystem.
Uses the
size field on DirEntry returned by Self::list
— filesystems that don’t surface size from a listing return 0
for those entries, in which case the total is best-effort. Read moreAuto Trait Implementations§
impl Freeze for ArchiveFs
impl !RefUnwindSafe for ArchiveFs
impl Send for ArchiveFs
impl !Sync for ArchiveFs
impl Unpin for ArchiveFs
impl UnsafeUnpin for ArchiveFs
impl !UnwindSafe for ArchiveFs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more