can1357/oh-my-pi · error · io::Error

truncated getattrlistbulk record length

Error message

truncated getattrlistbulk record length

What it means

On macOS, pi-walker parses fixed-size records returned by getattrlistbulk; if a record header claims a length that would run past the buffer or below the minimum size, the walker treats the buffer as corrupt and returns InvalidData with this static message. It protects against kernel/libc contract violations rather than user input.

Source

Thrown at crates/pi-walker/src/lib.rs:3657

	const fn file_type_from_vtype(value: u32) -> Option<FileType> {
		match value {
			VREG => Some(FileType::File),
			VDIR => Some(FileType::Dir),
			VLNK => Some(FileType::Symlink),
			_ => None,
		}
	}

	fn is_unsupported_dir_scan(err: &io::Error) -> bool {
		matches!(err.raw_os_error(), Some(libc::ENOTSUP | libc::EINVAL))
	}

	fn is_skippable_entry_error(err: &io::Error) -> bool {
		matches!(err.kind(), io::ErrorKind::NotFound | io::ErrorKind::PermissionDenied)
	}

	fn invalid_data(message: &'static str) -> io::Error {
		io::Error::new(io::ErrorKind::InvalidData, message)
	}
}

#[cfg(target_os = "linux")]
mod platform {
	use std::{
		ffi::{CString, OsStr},
		io,
		mem::{size_of, zeroed},
		os::unix::ffi::OsStrExt,
		path::Path,
	};

	use super::{
		FileType, RawDirEntry, ReadDirControl, ReadDirError, WalkDetail, WalkError, mtime_millis,
	};

	pub const CHEAP_SIZE_HINTS: bool = false;

View on GitHub (pinned to 9690622007)

Solutions

  1. Retry the directory listing once; transient buffer corruption on network filesystems may clear.
  2. Fall back to a portable readdir-based walker (the no-special-casing std::fs::read_dir path) for that filesystem.
  3. Report the filesystem type and macOS version — this indicates a platform-level defect, not caller error.
Defensive patterns

Strategy: fallback

Try / catch

match fast_walk(dir) {
  Err(e) if e.kind() == io::ErrorKind::InvalidData => std_walk(dir), // read_dir fallback
  other => other,
}

Prevention

When it happens

Trigger: getattrlistbulk returns a buffer whose record's attr_length is smaller than the fixed header or larger than the remaining buffer, during directory enumeration on macOS.

Common situations: OS/driver bugs, exotic filesystems (network mounts, FUSE) whose getattrlistbulk response is malformed, or hardware/memory corruption.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/8c5653b7f8ca4ec2. Report an issue: GitHub.