pub fn read_block<'a>(
partition: &'a [u8],
sb: &Superblock,
addr: u64,
len: usize,
) -> Result<&'a [u8], UfsError>Expand description
Read len bytes of a file’s block addr from partition (the filesystem
partition bytes, filesystem byte 0). addr is a fragment address as
stored in an inode’s di_db[]/di_ib[]; the byte offset is
addr * fs_fsize.
A directory’s data lives in whole blocks; the tail block may be a partial
fragment run, so len bounds how much is read (typically fs_bsize, or the
remaining di_size for the last block). Reading past the partition end is
not an error here — the returned slice is clamped to what is present, so
a truncated image yields a short (possibly empty) block rather than a
failure, and the caller’s d_reclen/di_size bounds still hold.
§Errors
UfsError::ImpossibleGeometry if fs_fsize <= 0 (the multiplier for the
byte offset), so the address cannot be computed — never a panic.