devio

The primary difference between devio and other command line utilities, such as dd and cat, is that it is not stream based - it writes directly into the object rather than reading and writing a stream of data.

Building devio

At present devio must be built from the CVS source.  The devio project page on SourceForge contains the information needed to access the CVS source tree.  The source is built using the widely uses GNU autoconf tools.  When building from CVS you must have a full set of these tools installed.  You may then build using the following sequence of commands:

autoreconf -i
./configure
make

This creates the devio program in the src sub-directory, it can be installed (by default into /sbin) by typing make install.

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. For more information, including examples, read the devio manual.

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 additional features of the devio commands are 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.

SourceForge.net Logo