Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Up: Genfile


C.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 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:

--pattern=default
The default pattern as described above.
--pattern=zero
Fills the file with zeroes.

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 in 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:

k
K
The number is expressed in kilobytes.
m
M
The number is expressed in megabytes.
g
G
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 a 2048000-bytes long file of the following structure:

Offset Length Contents
0 4*512=2048 Four 512-byte blocks, filled with letters ‘A’, ‘B’, ‘C’ and ‘D’.
2048 1046528 Zero bytes
1048576 5*512=2560 Five blocks, filled with letters ‘E’, ‘F’, ‘G’, ‘H’, ‘I’.
1051136 996864 Zero bytes

 
 
  Published under the terms of the GNU General Public License Design by Interspire