Skip to main content

MfsFilesystem

Struct MfsFilesystem 

Source
pub struct MfsFilesystem<R: Read + Seek + Send> { /* private fields */ }
Expand description

Live MFS reader. Holds the parsed MDB, the volume bitmap, and a re-decoded directory cache (small — at most a few hundred entries on a 400 KB floppy).

Implementations§

Source§

impl<R: Read + Seek + Send> MfsFilesystem<R>

Source

pub fn open(reader: R, partition_offset: u64) -> Result<Self, FilesystemError>

Open an MFS volume at the given partition offset.

Source

pub fn read_resource_fork( &mut self, entry: &FileEntry, ) -> Result<Vec<u8>, FilesystemError>

Read the resource fork of a directory entry. Returns an empty Vec if the file has no resource fork. Surfaced as a side channel because the trait’s read_file only exposes the data fork; classic Mac apps often live in the resource fork and consumers (e.g. the mac_archive exporter) need access.

Trait Implementations§

Source§

impl<R: Read + Write + Seek + Send> EditableFilesystem for MfsFilesystem<R>

Source§

fn write_resource_fork( &mut self, entry: &FileEntry, data: &mut dyn Read, len: u64, ) -> Result<(), FilesystemError>

Replace a file’s resource fork (used by setrsrc, the batch archive importer, and fork-carrying cp). Frees the old resource chain, then allocates + writes the new one and updates the directory entry. Call sync_metadata to persist. Freeing before allocating means a replacement only needs the delta in free space, not room for both copies.

Source§

fn as_filesystem(&self) -> &dyn Filesystem

Upcast to a read-only Filesystem trait object. Read more
Source§

fn as_filesystem_mut(&mut self) -> &mut dyn Filesystem

Mutable form of as_filesystem.
Source§

fn create_file( &mut self, parent: &FileEntry, name: &str, data: &mut dyn Read, data_len: u64, options: &CreateFileOptions, ) -> Result<FileEntry, FilesystemError>

Create a file in the given parent directory. Read more
Source§

fn create_directory( &mut self, _parent: &FileEntry, _name: &str, _options: &CreateDirectoryOptions, ) -> Result<FileEntry, FilesystemError>

Create a subdirectory in the given parent directory.
Source§

fn delete_entry( &mut self, parent: &FileEntry, entry: &FileEntry, ) -> Result<(), FilesystemError>

Delete a file, empty directory, or symlink. Read more
Source§

fn sync_metadata(&mut self) -> Result<(), FilesystemError>

Flush metadata (superblock, bitmaps, FAT tables, etc.) to disk.
Source§

fn free_space(&mut self) -> Result<u64, FilesystemError>

Returns the number of free bytes available on the filesystem.
Source§

fn repair(&mut self) -> Result<RepairReport, FilesystemError>

Attempt to repair filesystem issues found by fsck. Default returns an error indicating repair is not supported.
Source§

fn set_type_creator( &mut self, entry: &FileEntry, type_code: &str, creator_code: &str, ) -> Result<(), FilesystemError>

Set HFS/HFS+ type and creator codes. Override on HFS/HFS+; other filesystems return Unsupported so callers can branch on capability rather than relying on silent no-ops.
Source§

fn rename( &mut self, parent: &FileEntry, entry: &FileEntry, new_name: &str, ) -> Result<(), FilesystemError>

Rename an entry within its parent directory, in place: the entry keeps its identity and contents (start cluster / CNID / inode and file data are untouched) — only the name in the parent’s directory listing changes. new_name must validate via Filesystem::validate_name and must not already name another entry in parent. Read more
Source§

fn begin_bulk(&mut self)

Enter “bulk” editing mode for a batch of operations whose atomicity the caller guarantees as a whole (e.g. an importer that discards every change if any single op fails). Implementations may use this to skip per-operation rollback bookkeeping — for filesystems that snapshot the whole metadata on each edit (classic HFS clones its multi-megabyte catalog per create_file), that bookkeeping dominates a large import. Read more
Source§

fn end_bulk(&mut self)

Leave bulk editing mode (see begin_bulk). Default is a no-op.
Source§

fn delete_recursive( &mut self, parent: &FileEntry, entry: &FileEntry, ) -> Result<(), FilesystemError>

Recursively delete a directory and all its contents. Read more
Source§

fn set_permissions( &mut self, _entry: &FileEntry, _mode: u32, ) -> Result<(), FilesystemError>

Set Unix permission bits on an entry. mode carries permission bits only — implementations keep the inode’s file-type bits (see [crate::fs::unix_common::inode::with_permission_bits]). Read more
Source§

fn set_owner( &mut self, _entry: &FileEntry, _uid: u32, _gid: u32, ) -> Result<(), FilesystemError>

Set the owning uid and gid on an entry. Read more
Source§

fn set_xattr( &mut self, _entry: &FileEntry, _name: &str, _value: &[u8], ) -> Result<(), FilesystemError>

Set (create or replace) an extended attribute on an entry. Override on xattr-bearing filesystems (ext / XFS / SquashFS); others return Unsupported. name must carry a valid namespace prefix ([crate::fs::xattr::has_valid_namespace]).
Source§

fn remove_xattr( &mut self, _entry: &FileEntry, _name: &str, ) -> Result<(), FilesystemError>

Remove an extended attribute from an entry. Override on xattr-bearing filesystems; others return Unsupported. Removing an absent attribute is not an error.
Source§

fn set_prodos_type( &mut self, _entry: &FileEntry, _type_byte: u8, _aux_type: u16, ) -> Result<(), FilesystemError>

Set ProDOS file type byte and aux type on an existing file. Default returns Unsupported — override on ProDOS.
Source§

fn set_prodos_access( &mut self, _entry: &FileEntry, _access: u8, ) -> Result<(), FilesystemError>

Set the ProDOS access byte on an existing file or directory. Read more
Source§

fn set_blessed_folder( &mut self, _entry: &FileEntry, ) -> Result<(), FilesystemError>

Mark a folder as the blessed (bootable) system folder. Override on HFS/HFS+; other filesystems return Unsupported so the GUI can gate the action and surface unexpected calls.
Source§

fn write_boot_blocks( &mut self, _blocks: &[u8; 1024], ) -> Result<(), FilesystemError>

Stage the 1024-byte HFS boot-block region (sectors 0–1) for the volume, written verbatim at sync_metadata time. Used to make a classic-HFS volume bootable by copying a donor’s boot blocks. Override on HFS/HFS+ (the only filesystems with a Mac boot region); others return Unsupported so the GUI can gate the action.
Source§

fn set_volume_name(&mut self, _new_name: &str) -> Result<(), FilesystemError>

Rename the volume. Override on filesystems where the volume name is stored in metadata that the implementation can rewrite in place (HFS today; others return Unsupported).
Source§

fn set_finder_info( &mut self, _entry: &FileEntry, _finfo: [u8; 16], _fxinfo: [u8; 16], ) -> Result<(), FilesystemError>

Overwrite the full 16-byte FInfo and 16-byte FXInfo Finder metadata on a file’s catalog record. HFS today; others Unsupported. Used by the MacBinary put path to apply Finder flags / location / folder in one shot.
Source§

fn set_amiga_protection( &mut self, _entry: &FileEntry, _protection: u32, ) -> Result<(), FilesystemError>

Overwrite the create/modify/backup dates on a file’s catalog record. Dates are Mac epoch (seconds since 1904-01-01 00:00 UTC). HFS today; others Unsupported. Set the DOS attribute bits on an entry: read-only 0x01, hidden 0x02, system 0x04, archive 0x20. Read more
Source§

fn set_dos_attributes( &mut self, _parent: &FileEntry, _entry: &FileEntry, _attrs: u16, ) -> Result<(), FilesystemError>

Source§

fn set_dates( &mut self, _entry: &FileEntry, _create: u32, _modify: u32, _backup: u32, ) -> Result<(), FilesystemError>

Whether this filesystem can store symbolic links (i.e. Self::create_symlink is actually implemented). Default false; override to true alongside create_symlink. Lets callers (e.g. the tar-import preflight) warn before a lossy import that symlinks will be dropped, rather than discovering it entry-by-entry.
Source§

fn stores_raw_names(&self) -> bool

Whether names are stored as raw bytes via [crate::fs::raw_name] placeholders. Only NeXT UFS volumes say yes; everywhere else a placeholder would land as junk.
Create a symbolic link in parent pointing at target (a path string interpreted by the filesystem’s own resolver semantics). Returns the new symlink’s entry. Default returns Unsupported — override on filesystems that support symlinks (PFS3, AFFS, ext, etc).
Create a hard link in parent pointing at an existing entry already on this filesystem. target must be an entry returned by a previous create_file / create_directory / list_directory call on this same volume — its location identifies the inode / anode / CNID that the new link references. Returns the new hardlink’s entry. Default returns Unsupported — override on filesystems that support hardlinks (PFS3, HFS+, ext, etc).
Source§

impl<R: Read + Seek + Send> Filesystem for MfsFilesystem<R>

Source§

fn allocation_unit(&self) -> Option<u64>

MFS allocates fork storage in fixed-size allocation blocks (drAlBlkSiz), so a fork’s real on-disk footprint is its length rounded up to this unit. Exposing it lets the copy preflight and du model destination consumption exactly instead of falling back to a 512-byte floor.

Source§

fn write_resource_fork_to( &mut self, entry: &FileEntry, writer: &mut dyn Write, ) -> Result<u64, FilesystemError>

Stream a file’s resource fork. MFS files carry a data + resource fork like HFS; consumers (get-binhex, MacBinary / AppleDouble export, cp, the remote daemon) reach it only through this trait method, so it must bridge to the inherent read_resource_fork (which follows the resource fork’s own allocation-block chain).

Source§

fn root(&mut self) -> Result<FileEntry, FilesystemError>

Get the root directory entry.
Source§

fn list_directory( &mut self, entry: &FileEntry, ) -> Result<Vec<FileEntry>, FilesystemError>

List the contents of a directory.
Source§

fn read_file( &mut self, entry: &FileEntry, max_bytes: usize, ) -> Result<Vec<u8>, FilesystemError>

Read file contents (up to max_bytes).
Source§

fn validate_name(&self, name: &str) -> Result<(), FilesystemError>

Validate that name is legal for a new file or directory on this filesystem. Returns Err(InvalidData) with a human-readable reason when the name violates length, character, or encoding rules. Read more
Source§

fn fs_type(&self) -> &str

Filesystem type name (e.g., “FAT16”, “FAT32”).
Source§

fn volume_label(&self) -> Option<&str>

Volume label, if available.
Source§

fn total_size(&self) -> u64

Total filesystem size in bytes.
Source§

fn used_size(&self) -> u64

Used space in bytes.
Source§

fn resource_fork_size(&mut self, entry: &FileEntry) -> u64

Returns the resource fork size for a file entry. Default returns 0.
Source§

fn fsck(&mut self) -> Option<Result<FsckResult, FilesystemError>>

Run filesystem integrity check. Returns None if not supported for this filesystem type. Override in implementations that support fsck.
Source§

fn last_data_byte(&mut self) -> Result<u64, FilesystemError>

Returns the minimum number of bytes from the partition start needed to capture all filesystem data without moving any data on disk — i.e. the position of the last allocated byte. Used for smart backup trimming. Read more
Source§

fn defragmented_minimum_size(&mut self) -> Result<u64, FilesystemError>

Returns the minimum partition size that could host all live filesystem data after a defragmenting clone (data packed from offset 0). Read more
Source§

fn fragmentation_stats( &mut self, ) -> Option<Result<FragmentationStats, FilesystemError>>

Returns per-fork fragmentation statistics for this volume, or None when the filesystem can’t compute them (e.g. cluster-allocation filesystems whose CompactReader already repacks during the backup stream so “fragmentation” doesn’t translate into a backup-time decision the user can make). Read more
Source§

fn write_file_to( &mut self, entry: &FileEntry, writer: &mut dyn Write, ) -> Result<u64, FilesystemError>

Stream file data to a writer. Returns the number of bytes written. Read more
Source§

fn blessed_system_folder(&mut self) -> Option<(u64, String)>

Returns the CNID and name of the blessed (bootable) system folder, if set. Only meaningful for HFS/HFS+.
Source§

fn set_show_deleted(&mut self, _on: bool) -> bool

List deleted-but-readable entries alongside live ones; false when unsupported.
Source§

fn journal_detail( &mut self, ) -> Result<Option<Box<dyn Any + Send>>, FilesystemError>

Decode the journal into per-transaction detail for a history viewer; Ok(None) if unjournaled. The value is the filesystem’s own detail type (HFS+: JournalDetail), for the caller to downcast.
Source§

fn uses_colon_paths(&self) -> bool

True when this filesystem reserves : as its native path separator (classic Mac HFS / HFS+), so : can never appear in a catalog name. Read more
Source§

fn case_insensitive_lookup(&self) -> bool

Whether name lookup falls back to case-insensitive matching, the way the native OS resolves paths on this filesystem; an exact match wins first.
Source§

fn supports_xattrs(&self) -> bool

Whether this filesystem stores POSIX extended attributes (user.*, security.*, …). True on ext / XFS / SquashFS; false on filesystems with no xattr concept (Minix, EFS, FAT, HFS). The UI uses this to show or hide the xattr section rather than probing every file.
Source§

fn list_xattrs( &mut self, _entry: &FileEntry, ) -> Result<Vec<Xattr>, FilesystemError>

Read the extended attributes on entry. Default: none. Override on xattr-bearing filesystems. Returning an empty list is normal — most files carry no xattrs even where the filesystem supports them.

Auto Trait Implementations§

§

impl<R> Freeze for MfsFilesystem<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for MfsFilesystem<R>
where R: RefUnwindSafe,

§

impl<R> Send for MfsFilesystem<R>

§

impl<R> Sync for MfsFilesystem<R>
where R: Sync,

§

impl<R> Unpin for MfsFilesystem<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for MfsFilesystem<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for MfsFilesystem<R>
where R: UnwindSafe,

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

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

fn try_from(value: U) -> Result<T, !>

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.