{"record":{"id":"6f4e7d5756db134e","repo":"ClementTsang/bottom","slug":"could-not-get-volume-name-for-mount-point-err","errorCode":null,"errorMessage":"Could not get volume name for mount point: {err:?}","messagePattern":"Could not get volume name for mount point: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/collection/disks/windows/bindings.rs","lineNumber":176,"sourceCode":"    let mount = {\n        let mount_path = Path::new(mount);\n        let mut wide_path = mount_path.as_os_str().encode_wide().collect::<Vec<_>>();\n\n        // Always push on a \\0 character, without this it will occasionally\n        // break.\n        wide_path.push(0x0000);\n\n        wide_path\n    };\n    let mut buffer = [0_u16; VOLUME_MAX_LEN];\n\n    // SAFETY: API call, we must check the result for validating safety.\n    let result = unsafe {\n        GetVolumeNameForVolumeMountPointW(windows::core::PCWSTR(mount.as_ptr()), &mut buffer)\n    };\n\n    if let Err(err) = result {\n        bail!(\"Could not get volume name for mount point: {err:?}\");\n    } else {\n        Ok(current_volume(&buffer).to_string_lossy().to_string())\n    }\n}\n","sourceCodeStart":158,"sourceCodeEnd":181,"githubUrl":"https://github.com/ClementTsang/bottom/blob/b77d3175028849824e987c35177e8f61450d72e7/src/collection/disks/windows/bindings.rs#L158-L181","documentation":"volume_name_from_mount calls GetVolumeNameForVolumeMountPointW to translate a mount point (e.g. C:\\mount) into its \\\\?\\Volume{guid}\\ name, and bails if the API returns Err. The library cannot proceed to disk-usage collection without the canonical volume name. Failure means the mount point does not map to a resolvable volume.","triggerScenarios":"GetVolumeNameForVolumeMountPointW fails — the mount point path is malformed (missing trailing backslash), the path is not a mounted volume/junction, the volume is offline, or access is denied.","commonSituations":"Passing a plain drive letter without a trailing backslash (\"C:\" instead of \"C:\\\"); dangling junctions or mount points pointing at removed volumes; enumerating disk usage on network drives that have no volume GUID name.","solutions":["Ensure the mount point string ends with a trailing backslash (e.g. \"C:\\\\\" not \"C:\")","Verify the path is actually a mount point of a local volume via 'mountvol' before calling","Skip paths that fail resolution (network shares, dangling junctions) in get_disk_usage","Check the wrapped err's Win32 code — ERROR_ACCESS_DENIED vs ERROR_INVALID_NAME indicates privilege vs path-format problems"],"exampleFix":"// before\nlet result = unsafe {\n    GetVolumeNameForVolumeMountPointW(windows::core::PCWSTR(mount.as_ptr()), &mut buffer)\n};\n// after\nlet mut mount = mount; // ensure trailing backslash\nif !mount.ends_with('\\\\') {\n    mount.push('\\\\');\n}\nlet result = unsafe {\n    GetVolumeNameForVolumeMountPointW(windows::core::PCWSTR(mount.as_ptr()), &mut buffer)\n};","handlingStrategy":"validation","validationCode":"// ensure mount point ends with a backslash and looks like a local mount\nfn valid_mount_point(p: &str) -> bool {\n    p.ends_with('\\\\') && !p.starts_with(\"\\\\\\\\\")\n}","typeGuard":null,"tryCatchPattern":"match volume_name_from_mount(mp) {\n    Ok(name) => name,\n    Err(e) => { log::debug!(\"skipping mount {mp}: {e:?}\"); continue; }\n}","preventionTips":["Always append a trailing backslash to mount point paths","Filter out network shares and dangling junctions before resolving volume names","Validate mount points with `mountvol` output during setup"],"tags":["windows","win32","volumes","mount-point"],"backgroundTag":"invalid-argument-format","analyzedSha":"b77d3175028849824e987c35177e8f61450d72e7","analyzedAt":"2026-09-07T14:53:21.246Z","contentChangedAt":"2026-09-07T14:53:21.246Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}