Cross-platform disk/volume resolver — given a path, tells you which disk it's on, its mount point, and the relative path
Installation
As a library
[]
= "0.1"
As a CLI tool
CLI Usage
# Resolve the current working directory
# Resolve a specific path
# Output as JSON
# Output as YAML
# Combine options
Default output:
device="/dev/disk3s5"
mount_point="/System/Volumes/Data"
relative_path="Users/user/Develop/personal/whichdisk"
JSON output (-o json):
YAML output (-o yaml):
device: /dev/disk3s5
mount_point: /System/Volumes/Data
relative_path: Users/user/Develop/personal/whichdisk
Library Example
use which_disk;
Supported Platforms
| Platform | Backend |
|---|---|
| macOS, iOS, watchOS, tvOS, visionOS | statfs via rustix |
| FreeBSD, OpenBSD, DragonFlyBSD | statfs via rustix |
| Linux | /proc/self/mountinfo parsing |
| Windows | GetVolumePathNameW / GetVolumeNameForVolumeMountPointW via windows-sys |
Performance
- Thread-local cache — repeated lookups for paths on the same device skip the underlying syscall/file read entirely
- Small-buffer optimization — mount points and device names (typically < 56 bytes) are stored inline on the stack; longer values use reference-counted
bytes::Bytes(clone is a pointer copy) - SIMD-accelerated scanning — uses
memchrfor null-terminator and newline searches in the BSDstatfsbuffers and Linux mountinfo parsing
MSRV
The minimum supported Rust version is 1.85.
License
whichdisk is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2026 Al Liu.