manpagez: man pages & more
info tar
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

E.1 Generate Mode

In this mode genfile creates a data file for the test suite. The size of the file is given with the ‘--length’ (‘-l’) option. By default the file contents is written to the standard output, this can be changed using ‘--file’ (‘-f’) command line option. Thus, the following two commands are equivalent:

genfile --length 100 > outfile
genfile --length 100 --file outfile

If ‘--length’ is not given, genfile will generate an empty (zero-length) file.

The command line option ‘--seek=N’ istructs genfile to skip the given number of bytes (N) in the output file before writing to it. It is similar to the ‘seek=N’ of the dd utility.

You can instruct genfile to create several files at one go, by giving it ‘--files-from’ (‘-T’) option followed by a name of file containing a list of file names. Using dash (‘-’) instead of the file name causes genfile to read file list from the standard input. For example:

# Read file names from file ‘file.list’
genfile --files-from file.list
# Read file names from standard input
genfile --files-from -

The list file is supposed to contain one file name per line. To use file lists separated by ASCII NUL character, use ‘--null’ (‘-0’) command line option:

genfile --null --files-from file.list

The default data pattern for filling the generated file consists of first 256 letters of ASCII code, repeated enough times to fill the entire file. This behavior can be changed with ‘--pattern’ option. This option takes a mandatory argument, specifying pattern name to use. Currently two patterns are implemented:


The default pattern as described above.


Fills the file with zeroes.

If no file name was given, the program exits with the code 0. Otherwise, it exits with 0 only if it was able to create a file of the specified length.

Special option ‘--sparse’ (‘-s’) instructs genfile to create a sparse file. Sparse files consist of data fragments, separated by holes or blocks of zeros. On many operating systems, actual disk storage is not allocated for holes, but they are counted in the length of the file. To create a sparse file, genfile should know where to put data fragments, and what data to use to fill them. So, when ‘--sparse’ is given the rest of the command line specifies a so-called file map.

The file map consists of any number of fragment descriptors. Each descriptor is composed of two values: a number, specifying fragment offset from the end of the previous fragment or, for the very first fragment, from the beginning of the file, and contents string, i.e., a string of characters, specifying the pattern to fill the fragment with. File offset can be suffixed with the following quantifiers:


The number is expressed in kilobytes.


The number is expressed in megabytes.


The number is expressed in gigabytes.

For each letter in contents string genfile will generate a block of data, filled with this letter and will write it to the fragment. The size of block is given by ‘--block-size’ option. It defaults to 512. Thus, if the string consists of n characters, the resulting file fragment will contain n*block-size of data.

Last fragment descriptor can have only file offset part. In this case genfile will create a hole at the end of the file up to the given offset.

For example, consider the following invocation:

genfile --sparse --file sparsefile 0 ABCD 1M EFGHI 2000K

It will create 3101184-bytes long file of the following structure:

04*512=2048Four 512-byte blocks, filled with letters ‘A’, ‘B’, ‘C’ and ‘D’.
20481046528Zero bytes
10506245*512=2560Five blocks, filled with letters ‘E’, ‘F’, ‘G’, ‘H’, ‘I’.
10531842048000Zero bytes

The exit code of genfile --status command is 0 only if created file is actually sparse.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on November 1, 2013 using texi2html 5.0.

© 2000-2018
Individual documents may contain additional copyright information.