{"record":{"id":"f6530939190faddd","repo":"sxyazi/yazi","slug":"cannot-get-the-name-property","errorCode":null,"errorMessage":"Cannot get the name property","messagePattern":"Cannot get the name property","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"yazi-fs/src/mounts/macos.rs","lineNumber":164,"sourceCode":"\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefer! { unsafe { IOObjectRelease(service); } };\n\t\t\tif let Some(name) = Self::bsd_name(service).ok().filter(|s| s.as_bytes().starts_with(b\"disk\"))\n\t\t\t{\n\t\t\t\tnames.push(name);\n\t\t\t}\n\t\t}\n\n\t\tnames.sort_unstable_by(|a, b| natsort(a.as_bytes(), b.as_bytes(), false));\n\t\tOk(names)\n\t}\n\n\tfn bsd_name(service: mach_port_t) -> Result<CString> {\n\t\tlet key = CFString::new(\"BSD Name\")?;\n\t\tlet property =\n\t\t\tunsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };\n\t\tif property.is_null() {\n\t\t\tbail!(\"Cannot get the name property\");\n\t\t}\n\t\tdefer! { unsafe { CFRelease(property) } };\n\n\t\t#[allow(unexpected_cfgs)]\n\t\tlet cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };\n\t\tOk(if cstr.is_null() {\n\t\t\tbail!(\"Invalid value for the name property\");\n\t\t} else {\n\t\t\tCString::from(unsafe { CStr::from_ptr(cstr) })\n\t\t})\n\t}\n}\n","sourceCodeStart":146,"sourceCodeEnd":177,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/mounts/macos.rs#L146-L177","documentation":"`bsd_name(service)` reads the \"BSD Name\" registry property of an IOKit service via `IORegistryEntryCreateCFProperty`. If the returned CFPropertyRef is NULL, the service has no \"BSD Name\" entry (i.e. it is not a disk backed by a BSD device node like disk0/disk1), so the function bails. It reflects a missing IOKit registry key, not a corrupted value.","triggerScenarios":"Calling `bsd_name(service)` with a mach_port_t for an IOKit service whose IORegistry has no \"BSD Name\" property — e.g. non-disk IOService entries, controllers, or virtual services enumerated by the broad `IOServiceMatching(c\"IOService\")` iterator.","commonSituations":"Enumerating all IOService entries on a Mac and encountering services that legitimately have no BSD device (RAM disks not yet attached, ACPI/platform nodes, network interfaces); running on Apple Silicon where some disk services expose the key differently.","solutions":["Skip services without \"BSD Name\" instead of treating them as errors — they are not disk partitions.","Narrow the service matching (e.g. match IOMedia or specific disk classes) so only disk-backed services are inspected.","If debugging, dump the service's registry entry (ioreg) to confirm the property really is absent."],"exampleFix":"// before\nif property.is_null() {\n    bail!(\"Cannot get the name property\");\n}\n// after: treat missing BSD Name as 'not a disk'\nif property.is_null() {\n    return Ok(None); // caller skips non-BSD services\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn has_bsd_name(service: mach_port_t) -> bool {\n    let key = match CFString::new(\"BSD Name\") { Ok(k) => k, Err(_) => return false };\n    let p = unsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };\n    if p.is_null() { return false; }\n    unsafe { CFRelease(p) };\n    true\n}","tryCatchPattern":"match bsd_name(service) {\n    Ok(name) => Some(name),\n    Err(_) => None, // not a BSD-backed disk; skip\n}","preventionTips":["Skip IOService entries lacking \"BSD Name\" instead of failing — they are not disks.","Use a narrower IOServiceMatching class (e.g. IOMedia) to enumerate only disk-backed services.","Design the enumeration loop to continue past individual service errors."],"tags":["macos","iokit","iokegit-registry","ffi"],"backgroundTag":"iokegit-registry-property-missing","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}