1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Linux block-layer I/O trace capture, straight from the kernel.
//!
//! `blktrace_rs` drives the kernel block tracing interface directly (the
//! `BLKTRACESETUP`/`BLKTRACESTART`/`BLKTRACESTOP`/`BLKTRACETEARDOWN` ioctls
//! plus the per-CPU relay channels under debugfs), so it needs neither the
//! `blktrace` nor the `blkparse` command line tools.
//!
//! Capturing requires root and a kernel with debugfs. Building this crate
//! requires `libclang` and the kernel UAPI headers
//! (`linux/blktrace_api.h`).
//!
//! # Example
//! ```no_run
//! use blktrace_rs::BlkTrace;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let session = BlkTrace::monitor("/dev/sda")?;
//! // ... do I/O on the device while the tracer runs ...
//! let report = session.shutdown()?;
//! for event in &report.events {
//! if event.is_read() {
//! println!("read {} bytes at sector {}", event.event.bytes, event.event.sector);
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # The `async` feature
//! The tracing core is inherently blocking (relay channel reads and ioctl
//! waits). With `features = ["async"]` the crate adds `monitor_async` and
//! `shutdown_async`, which run that core on the tokio blocking pool so
//! async callers never stall their executor.
// On docs.rs builds this shows feature-gated items (the async API) with
// cfg badges instead of hiding them.
compile_error!;
pub use *;
pub use BlktraceError;
pub use BlkTraceEvent;
pub use ;