{"record":{"id":"96eb842aac16d87f","repo":"can1357/oh-my-pi","slug":"no-such-device-or-address","errorCode":null,"errorMessage":"No such device or address","messagePattern":"No such device or address","errorType":"exception","errorClass":"CatError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/cat.rs","lineNumber":81,"sourceCode":"\t\twriter.write_all(self.to_str())\n\t}\n}\n\n#[derive(Error, Debug)]\nenum CatError {\n\t/// Wrapper around `io::Error`.\n\t#[error(\"{}\", strip_errno(.0))]\n\tIo(io::Error),\n\t/// The downstream reader closed its pipe; this ends the copy quietly.\n\t#[error(\"broken pipe\")]\n\tBrokenPipe,\n\t/// Unknown file type; it is not a regular file, socket, or known device.\n\t#[error(\"unknown filetype: {ft_debug}\")]\n\tUnknownFiletype { ft_debug: String },\n\t#[error(\"Is a directory\")]\n\tIsDirectory,\n\t#[cfg(unix)]\n\t#[error(\"No such device or address\")]\n\tNoSuchDeviceOrAddress,\n\t#[error(\"Too many levels of symbolic links\")]\n\tTooManySymlinks,\n}\n\nimpl From<io::Error> for CatError {\n\tfn from(error: io::Error) -> Self {\n\t\tif error.kind() == ErrorKind::BrokenPipe {\n\t\t\tSelf::BrokenPipe\n\t\t} else {\n\t\t\tSelf::Io(error)\n\t\t}\n\t}\n}\n\nfn strip_errno(error: &io::Error) -> String {\n\tlet mut message = error.to_string();\n\tif let Some(position) = message.find(\" (os error \") {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/cat.rs#L63-L99","documentation":"`CatError::NoSuchDeviceOrAddress` (unix-only) reports ENXIO — the path refers to a device special file but no device exists at that address, or the device cannot be opened in the requested mode. It is raised when opening/reading a character/block device yields this specific errno, letting `cat` print coreutils' exact wording instead of Rust's raw error string.","triggerScenarios":"`cat /dev/ttyX` where the tty has no controlling process; opening a device node whose driver/module is not loaded; `cat` on a unix socket path or special file that resolves to no live device (ENXIO from open/read).","commonSituations":"Scripts referencing /dev entries that only exist conditionally (missing kernel module, container without the device mounted); cat-ing device nodes that require exclusive or special open semantics; stale /dev paths after hardware changes.","solutions":["Verify the device node is valid and its driver is loaded (`ls -l /dev/...`, `lsof`, kernel module list).","In containers, mount/prepare the required device (e.g. --device with docker) before reading it.","Don't cat device special files expecting data; use the appropriate tool (dd, socat) if you need device I/O."],"exampleFix":"// before\n$ cat /dev/video0\ncat: /dev/video0: No such device or address\n// after\n$ ls /dev/video*    # ensure driver loaded / device attached\n$ dd if=/dev/video0 bs=1 count=1   # or use a v4l tool instead","handlingStrategy":"validation","validationCode":"// shell: confirm the device node is present and readable before cat-ing\nDEV=/dev/video0\nif [ ! -c \"$DEV\" ]; then echo \"no such device node: $DEV\" >&2; exit 1; fi\nif ! dd if=\"$DEV\" of=/dev/null count=1 2>/dev/null; then\n  echo \"device not accessible: $DEV\" >&2; exit 1\nfi","typeGuard":"// Rust caller: match the specific errno variant\nif matches!(err, CatError::NoSuchDeviceOrAddress) {\n    eprintln!(\"device not available at that address\");\n}","tryCatchPattern":"// shell: degrade gracefully when a device is unavailable\nif ! cat -- \"$DEV\" 2>/dev/null; then\n  echo \"warning: $DEV unavailable, continuing\" >&2\nfi","preventionTips":["Verify device nodes exist (driver loaded, device mounted in containers) before scripted access.","Don't use cat for device I/O; prefer dd/socat with proper block sizes.","In containers, explicitly pass through required devices at launch time."],"tags":["shell","builtin","device","unix","errno"],"backgroundTag":"no-such-device","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}