1 unstable release
Uses new Rust 2024
| new 0.1.0 | Jan 30, 2026 |
|---|
#827 in Filesystem
27KB
480 lines
dio-align
Overview
dio-align reports the logical and physical block sizes required for direct I/O alignment on the
filesystem backing a given path. On Linux 6.1+ it also reports the required memory alignment when
statx(DIOALIGN) is available.
Installation
[dependencies]
dio-align = "0.1"
Usage
use dio_align::fetch;
fn main() -> std::io::Result<()> {
let info = fetch("src/lib.rs")?;
println!("logical: {}", info.logical_block_size());
println!("physical: {}", info.physical_block_size());
Ok(())
}
Platform notes
- Linux 6.1+: uses
statx(DIOALIGN)for memory and logical alignment and sysfs for physical size. - Linux < 6.1: uses block device ioctls and sysfs; memory alignment is not available.
- macOS and other Apple OSes: uses
statfsand reportsf_bsizeandf_iosize. - Windows: uses
GetDiskFreeSpaceWfor logical size and storage property queries for physical size. Physical size may fall back to the logical size if the query is not supported.
License
dio-align is under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.
Copyright (c) 2026 Al Liu.
Dependencies
~2–35MB
~597K SLoC