FaultInjectingDevice

Wraps a 512-byte-sector block device and injects hardware-like faults into it.

Declared in src/libs/libfs/fuzzer/FaultInjectingDevice.hpp
Inherits BlockDeviceTemplate
Group fuzzer

Detailed description

The filesystem fuzzer puts a FaultInjectingDevice between the exFAT code and the real block device, to test how the filesystem survives bad hardware. FuzzerEngine creates one over its device and keeps it in a std::unique_ptr. The wrapper does not own the underlying device, which must stay valid for its lifetime.

Two kinds of fault are available:

  • Immediate corruption: bit flips, zeroed bytes, noise and byte shifts read a sector, change it and write it back at once.
  • Armed faults that change later I/O: bad sectors fail every read and write, ignored writes report success but write nothing (power loss), a partial write stores only its first bytes, and a wrong-sector mapping returns another sector once.

faultedOperationCount() counts every fault that took effect, and clearAllFaults() disarms the pending ones.

See also SemanticCorruptifier.

In this section