Skip to main content

ArchiveFs

Struct ArchiveFs 

Source
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

Source

pub fn from_index(index: ArchiveIndex) -> Self

Read-only handle over an already-scanned index.

Source

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).

Source

pub fn scaffold(kind: &'static str) -> Self

Detection-only handle for a format whose reader isn’t built yet.

Source

pub fn kind(&self) -> &'static str

The format’s short identifier.

Trait Implementations§

Source§

impl Filesystem for ArchiveFs

Source§

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<()>

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<()>

Create a directory at path.
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<()>

Create a device node / FIFO / socket.
Source§

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>>

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>>

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>>

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 more
Source§

fn flush(&mut self, dev: &mut dyn BlockDevice) -> Result<()>

Persist outstanding dirty state to the device.
Source§

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 more
Source§

fn mutation_capability(&self) -> MutationCapability

Capability of this filesystem with respect to mutating an already-flushed image. Three cases: Read more
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>

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 more
Source§

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 more
Source§

fn 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>>

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 more
Source§

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

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<()>

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 more
Source§

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 more
Source§

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 more
Source§

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 more
Add a new directory entry at new_path that points at the existing inode at target_path — a POSIX hard link. Read more
Source§

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 more
Source§

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<()>

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<()>

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>

Filesystem-level capacity stats. The FUSE adapter calls this to answer statfs; the CLI’s info command could too. Read more
Source§

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 more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.