Software write-blocking via blockdev --setro, with mandatory post-set verification -- never claims a device is write-blocked without confirming it
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/write-blocker |
| Edition | 2021 |
| Targets | infrastructure_write_blocker |
| Public items | 6 across 0 modules |
| Tests | 8 |
What it is for
Software write-blocking via blockdev --setro/--getro, with mandatory post-set verification. A write blocker that can silently fail to block is worse than no write blocker at all — this crate never emits a "write-blocked" citation without confirming the kernel actually reports the device read-only afterward.
Real behavior verified on this machine before writing this parser (not assumed): blockdev --getro <dev> always exits 0 regardless of state — the read-only/ read-write flag is only in stdout ("0\n" writable, "1\n" read-only). Exit code alone cannot be trusted to reflect device state, only whether the ioctl call itself succeeded.
No kernel patch required — this is the standard BLKROSET ioctl via blockdev, distinct from and much smaller in scope than a full custom write-blocking kernel patch (e.g. msuhanov/Linux-write-blocker).
Capabilities
WriteBlockerError
Software write-blocking via blockdev --setro/--getro, with mandatory
| Item |
|---|
pub enum WriteBlockerError |
fn parse_getro_output(stdout : & str) -> Result <bool, WriteBlockerError> |
async fn get_read_only(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <bool, WriteBlockerError> |
async fn set_read_only(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <(), WriteBlockerError> |
async fn enable_and_verify(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <Observation, WriteBlockerError> |
fn verify_outcome(device : & str, reported_read_only : bool,) -> Result <Observation, WriteBlockerError> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum WriteBlockerError | Every way a write-block operation can fail. |
fn parse_getro_output(stdout : & str) -> Result <bool, WriteBlockerError> | Parse blockdev --getro's stdout ("0\n" writable, "1\n" read-only) into a bool |
async fn get_read_only(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <bool, WriteBlockerError> | Query current read-only state via blockdev --getro <device>. |
async fn set_read_only(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <(), WriteBlockerError> | Set a device read-only via blockdev --setro <device> |
async fn enable_and_verify(blockdev_bin : impl Into <PathBuf>, device : & str, limits : ExecLimits,) -> Result <Observation, WriteBlockerError> | The forensic entrypoint: set read-only, then verify it actually took effect before citing anything |
fn verify_outcome(device : & str, reported_read_only : bool,) -> Result <Observation, WriteBlockerError> | The verification decision itself: what a post-set --getro reading means |
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into foundation.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/write-blocker |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_infrastructure["infrastructure"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-bounded-io` | foundation | no | always |
| `infrastructure-host-forensics` | infrastructure | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
thiserror | ^2 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_operations_block_imaging["operations-block-imaging"] -->|uses| SELF SELF["infrastructure-write-blocker"] SELF -->|runtime| n_foundation_bounded_io["foundation-bounded-io"] SELF -->|runtime| n_infrastructure_host_forensics["infrastructure-host-forensics"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_write_blocker | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
WriteBlockerError | enable_and_verify, get_read_only, parse_getro_output, set_read_only, verify_outcome |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CARGO_MANIFEST_DIR | src/lib.rs |
Related capabilities
1 workspace crate depends on this one: operations-block-imaging.
Verification
| Kind | Count |
|---|---|
| Unit tests | 8 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 6 | 0 | 1 |
What the tests establish, by name:
a_confirmed_read_only_device_yields_a_citable_observation—src/lib.rsa_device_the_kernel_still_reports_writable_fails_verification—src/lib.rsenable_and_verify_fails_loud_when_getro_disagrees—src/lib.rsenable_and_verify_succeeds_when_getro_confirms_readonly—src/lib.rsget_read_only_wires_stdout_through_the_parser—src/lib.rsparse_getro_output_reads_readonly—src/lib.rsparse_getro_output_reads_writable—src/lib.rsparse_getro_output_rejects_unexpected_values—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 6 | 6 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 6
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 249 |
| Code lines | 163 |
| Public API items | 6 |
| Public modules | 0 |
| Tests | 8 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 3 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 1
"function" : 5
pie showData
title Rust source composition
"Code" : 163
"Blank or comment" : 86
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.