sxyazi/yazi · warning
Cannot get the name property
Error message
Cannot get the name property
What it means
`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.
Source
Thrown at yazi-fs/src/mounts/macos.rs:164
break;
}
defer! { unsafe { IOObjectRelease(service); } };
if let Some(name) = Self::bsd_name(service).ok().filter(|s| s.as_bytes().starts_with(b"disk"))
{
names.push(name);
}
}
names.sort_unstable_by(|a, b| natsort(a.as_bytes(), b.as_bytes(), false));
Ok(names)
}
fn bsd_name(service: mach_port_t) -> Result<CString> {
let key = CFString::new("BSD Name")?;
let property =
unsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };
if property.is_null() {
bail!("Cannot get the name property");
}
defer! { unsafe { CFRelease(property) } };
#[allow(unexpected_cfgs)]
let cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };
Ok(if cstr.is_null() {
bail!("Invalid value for the name property");
} else {
CString::from(unsafe { CStr::from_ptr(cstr) })
})
}
}
View on GitHub (pinned to 5f901b886b)
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.
Example fix
// before
if property.is_null() {
bail!("Cannot get the name property");
}
// after: treat missing BSD Name as 'not a disk'
if property.is_null() {
return Ok(None); // caller skips non-BSD services
} Defensive patterns
Strategy: type-guard
Type guard
fn has_bsd_name(service: mach_port_t) -> bool {
let key = match CFString::new("BSD Name") { Ok(k) => k, Err(_) => return false };
let p = unsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };
if p.is_null() { return false; }
unsafe { CFRelease(p) };
true
} Try / catch
match bsd_name(service) {
Ok(name) => Some(name),
Err(_) => None, // not a BSD-backed disk; skip
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot get the IO matching services
- Cannot take a null pointer
- Cannot get the value for the key `{key}`
- Allocation failed while creating CFString
- Failed to get the C string from CFString
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/f6530939190faddd.
Report an issue: GitHub.