Introduction

devio is a command line tool designed to read and write data to block devices.  It allows random access to the device.  Read and write operations occur in complete device blocks and are optimised to avoid a write if the data has not changed.

Using devio

devio is controlled by a sequence of commands given on the devio command line.  These commands support a number of different operations:

  1. Opening files and devices for read or write.
  2. Moving the "file pointer" within an open file to allow read or write from different locations.
  3. Reading bytes from the current input.
  4. Evaluation of numeric expressions using the byte values read from the script.
  5. Built in support for reading a sequence of bytes (up to four) as a big or little endian value.
  6. Printing values to the standard output.
  7. Formatted output to the standard output.
  8. Writing bytes and mult-byte big or little endian values to the current output.
  9. Copying bytes from input to output.
  10. Filling the output with copies of a byte value.
  11. Conditional and loop execution of commands and conditional and looping expressions.

The command syntax is designed to be easy to parse, reducing the size of devio, but is consequently somewhat cryptic.  By default the devio build compiles in help.  devio with no arguments outputs a very basic usage message.

devio -h commands

Gives a list of the commands.

devio IO

IO in devio is optimised for reading and writing sections of block devices.  The main consideration is to restrict all accesses to the device to whole device blocks aligned to a device block boundary.  Standard stdio implementations do the same thing, however this is not guaranteed by the stdio API.  In addition devio performs all write operations as read-modify-write, with the write only being done if the modify really changed some data.  This is important with flash (MTD) devices where a write requires an erase and reduces the life of the flash device.

devio write operations are fully synced, using the fdatasync(2) system call, and fully checked for error conditions.

The byte reading and formatting support in the devio commands is intended to facilitate operations where it is necessary to interpret information contained within the device.  This frequently happens during system bootstrap of embedded systems where the flash memory contains important configuration data.

home contents previous devio SourceForge.net Logo next