Next: , Up: Custom Scripts



5.1 Using Script Hooks to Add New Functionality

Auto-pilot's benchmarking scripts include nine points in which you can insert your own code without modifying the original scripts. These hooks allow you to benchmark new file systems, compile new programs, and measure new quantities. The first three hooks are generic, and not related to file systems:

measure (premeasure|start|end|final)
The first argument to a measurement hook describes at what point the hook is being executed. premeasure indicates that it is before the measurement is actually taking place. start indicates that measurement should begin, and end indicates that measurement should complete. For example, during start a measurement hook could save important system state (e.g., the number of I/O operations to date), and during end the same quantity could be measured and the original value subtracted from the current value. During end, the hook must print a line of the format name = value, which is added to the measurement block. During final new blocks can be added.

The remaining arguments are the command that is being measured.

compilecommand PACKAGE PKGFILE
The compilecommand hook allows a series of compilation commands to be defined for new packages. The first argument is the name of the package to be compiled, and the second argument is the package file that is being compiled. If the hook returns success, then it must set the environment variable CMDLIST to an array containing each command to execute. For example, to compile GCC the following statements are used:
          I=0
          CMDLIST[$((I++))]=./configure
          CMDLIST[$((I++))]=make
     

apremote
To execute remote commands on another machine, some Auto-pilot scripts execute apremote.sh. To add new commands to apremote.sh, you can define an apremote hook. The first argument is the command passed to apremote.sh, and the remaining arguments are the arguments for that command.

The remaining hooks are used by the file system setup scripts.

mkfsopts FS TESTDEV BLOCKSIZE FSSIZE
The mkfsopts hook is called before mkfs. This hook takes four arguments, the file system time, the device, the block size, and the file system size. It should print any additional options to pass to mkfs on stdout.


mkfs FS TESTDEV BLOCKSIZE FSSIZE
For Ext2, Ext3, and Reiserfs, fs-setup.sh executes the appropriate mkfs command, but for other types of file systems it relies on the mkfs hook to properly format the file system. The mkfs hook takes the same arguments as mkfsopts, and formats the file system according to the arguments and environment variables.


tunefs FS TESTDEV
After the file system is formatted, a tunefs hook is called with two arguments: the file system type and the device. The tunefs hook can modify file system properties. For example, a tunefs hook can toggle directory indexing on an Ext2 or Ext3 partition.


mount FSTYPE TESTDEV TESTROOT
Before a file system is mounted, a mount hook is called with arguments of $FSTYPE $TESTDEV $TESTROOT. This hook can perform pre-mount operations, or mount the file system itself. To suppress fs-setup.sh from mounting the file system, the hook can set DOMOUNT to zero.


postmount FSTYPE TESTDEV TESTROOT
After a file system is mounted, a postmount hook is called with the same arguments as the mount hook.


unmount TESTDEV TESTROOT
The unmount hook should unmount the file system mounted on TESTROOT and the file system located on TESTDEV.