Simulating I/O errors [was: assume, assert, enforce, @safe]

Assaf Gordon via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 1 08:18:47 PDT 2014


Sorry to hijack the thread, but:

On 07/31/2014 09:27 PM, Walter Bright via Digitalmars-d wrote:
>
> If you're brave and want to have some fun, fill up your hard disk so
> it is nearly full. Now run your favorite programs that read and write
> files. Sit back and watch the crazy results (far too many programs
> assume that writes succeed). Operating systems also behave
> erratically in this scenario, hence the 'brave' suggestion.
>

If anyone is interested in simulating I/O errors and nearly-full file system on Linux,
I can suggest the following scripts:
  http://git.savannah.gnu.org/cgit/datamash.git/tree/build-aux/create_corrupted_file_system.sh
  http://git.savannah.gnu.org/cgit/datamash.git/tree/build-aux/create_small_file_system.sh

The scripts create two ext3 images which can be mounted, and simulate I/O errors.
One simulate file system with corrupted files (so "open" and the first "read" will succeed, but later "read" will fail with EIO),
and the other simulate a tiny filesystem, so that the first few "writes" will succeed, but "write" of >40KB will fail with ENOSPC.

The scripts themselves don't require root, but you'll need root to mount the images.

As Walter said, it's alarming how many programs fail to handle such cases (though D is pretty solid in that regard).

Hope this helps,
  - Assaf


More information about the Digitalmars-d mailing list