#alignment #direct-io #dio #block-alignment

dio-align

Query direct I/O alignment requirements for a filesystem path

1 unstable release

Uses new Rust 2024

new 0.1.0 Jan 30, 2026

#827 in Filesystem

MIT/Apache

27KB
480 lines

dio-align

Query direct I/O alignment requirements for a filesystem path.

github LoC Build codecov

docs.rs crates.io crates.io license

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 statfs and reports f_bsize and f_iosize.
  • Windows: uses GetDiskFreeSpaceW for 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