{"record":{"id":"7df3b6aa9235480f","repo":"sxyazi/yazi","slug":"cannot-get-the-io-matching-services","errorCode":null,"errorMessage":"Cannot get the IO matching services","messagePattern":"Cannot get the IO matching services","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/mounts/macos.rs","lineNumber":138,"sourceCode":"\t\t\t\tlabel: dict.os_string(\"DAVolumeName\").ok(),\n\t\t\t\tcapacity: dict.integer(\"DAMediaSize\").unwrap_or_default() as u64,\n\t\t\t\texternal: dict.bool(\"DADeviceInternal\").ok().map(|b| !b),\n\t\t\t\tremovable: dict.bool(\"DAMediaRemovable\").ok(),\n\t\t\t\t..partition\n\t\t\t});\n\t\t}\n\n\t\tOk(disks)\n\t}\n\n\tfn all_names() -> Result<Vec<CString>> {\n\t\tlet mut iterator: mach_port_t = 0;\n\t\tlet result = unsafe {\n\t\t\tIOServiceGetMatchingServices(0, IOServiceMatching(c\"IOService\".as_ptr()), &mut iterator)\n\t\t};\n\n\t\tif result != 0 {\n\t\t\tbail!(\"Cannot get the IO matching services\");\n\t\t}\n\t\tdefer! { unsafe { IOObjectRelease(iterator); } };\n\n\t\tlet mut names = vec![];\n\t\tloop {\n\t\t\tlet service = unsafe { IOIteratorNext(iterator) };\n\t\t\tif service == 0 {\n\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)","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/mounts/macos.rs#L120-L156","documentation":"In `all_names` (yazi-fs macOS mounts), `IOServiceGetMatchingServices(0, IOServiceMatching(c\"IOService\"), &mut iterator)` must return 0 (KERN_SUCCESS). Any nonzero kern_return_t means IOKit could not produce the service iterator, so BSD name discovery aborts. This is the first step of enumerating disks via the IOKit registry.","triggerScenarios":"Calling `all_names()` on macOS when `IOServiceGetMatchingServices` returns a nonzero kern_return_t — IOKit service matching failed, typically because the IOKit master port / IOMasterPort is unavailable or the process lacks access to IOKit.","commonSituations":"Running inside macOS sandboxes or containers without IOKit access; non-standard environments (iOS-adjacent runtimes, hardened runtimes without entitlements); rare IOKit initialization failures at early boot or in restricted CI VMs.","solutions":["Run in an environment with full IOKit access (normal macOS user session, no sandbox denying IOKit).","Check that the process isn't running under a sandbox profile blocking IOKit lookups.","Handle the error by skipping disk-name discovery and using a fallback partition listing.","Retry once; transient IOKit failures can occur before system services are fully up."],"exampleFix":"// before\nif result != 0 {\n    bail!(\"Cannot get the IO matching services\");\n}\n// after: log and degrade\nif result != 0 {\n    tracing::warn!(\"IOServiceGetMatchingServices failed: {result}\");\n    return Ok(Vec::new());\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match all_names() {\n    Ok(names) => names,\n    Err(e) if e.to_string().contains(\"IO matching services\") => Vec::new(),\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure the process is not sandboxed away from IOKit (check sandbox profiles/entitlements).","Retry once on nonzero kern_return_t — early-boot IOKit can be transiently unavailable.","Treat IOKit name discovery as best-effort and always have a fallback mount source."],"tags":["macos","iokit","ffi","mounts"],"backgroundTag":"iokit-service-lookup-failed","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"}