infrastructure capa

infrastructure-write-blocker

Software write-blocking via blockdev --setro, with mandatory post-set verification -- never claims a device is write-blocked without confirming it

Software write-blocking via blockdev --setro, with mandatory post-set verification -- never claims a device is write-blocked without confirming it

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/write-blocker
Edition2021
Targetsinfrastructure_write_blocker
Public items6 across 0 modules
Tests8

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`

ItemWhat it is
pub enum WriteBlockerErrorEvery 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)
Locationcrates/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.

CrateTierOptionalOnly on
`foundation-bounded-io`foundationnoalways
`infrastructure-host-forensics`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1fullnoalways

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

KindNameSource
libinfrastructure_write_blocker`src/lib.rs`

Error model

Error typeNamed by
WriteBlockerErrorenable_and_verify, get_read_only, parse_getro_output, set_read_only, verify_outcome

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
CARGO_MANIFEST_DIRsrc/lib.rs

1 workspace crate depends on this one: operations-block-imaging.

Verification

KindCount
Unit tests8
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root601

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc66
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 6
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files1
Source lines249
Code lines163
Public API items6
Public modules0
Tests8
Examples0
Cargo features0
Direct runtime dependencies3
Workspace reverse dependencies1
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.

Todas las infrastructure · Manual