.TH TESTBLOCK P "Manual V2.10 for Program V2.10" "Julian Stacey" "Julian Stacey, http://berklix.com" .UC 4 .SH NAME testblock \- Test block input & output to test for media &/or driver errors. .SH SYNTAX .B testblock [-b block_size] [-d data_byte] [-f fail_size] [-i] [-I] [-l byte_limit] [-n] [-s seconds] [-r] [-v] [-w] [-0] -- or file[s] or special_file[s] .SH DESCRIPTION Writes and/or reads test data blocks from &/or to a special file, normal file(s), or a pipe. Used to test IO on tape cassette, floppy drives, & hard drive partitions etc. Verifes media, dirty heads, faulty device drivers, etc, without the necessity of finding space on disc file systems to store large reference data images (such as tape sized comparison files). (A separate VSL tool `valid' also exists, designed purely for discs.) In the simplest case, data blocks are written till end of medium (or until file system is full), then the written image is read & compared with a .I testblock generated internal equivalent of what the data blocks should contain. The blocks are of a size determined by the .I testblock.c program source, or by option -b. Block size is Not as per default system wide include/ header files. .SH DATA TEST PATTERN Bytes in the first .I testblock data block use an incrementing range of values, where each 256 bytes normaly start 0x00, 0x01, 0x02 etc, up to 0xFF, then the next 256 bytes repeat 0x00 0x01 etc, until the end of block. (The 0x00 start value can be altered with the -d option). .br The next .I testblock data block starts 0x01, 0x02 etc. (The size of the .I testblock block is controlled by the -b option). .SH OPTIONS .PP All parameters may be in any order relative to each other. .br All parameters must precede all file names. .br Parameter default values are shown in brackets. .TP .B \-- [off] .br Pipe usage (off by default). See Output section. .TP .B \-v [off] .br Verbose. .TP .B \-r [on] .br Read mode. On by default, but off if -w is invoked, unless -r is also specifically invoked. .TP .B \-w [on] .br Write mode On by default, but off if -r is invoked, unless -w is also specifically invoked. .TP .B \-i .br Ignore single errors instead of aborting file test immediately. Adjacent (ie double) errors will still cause a file test abort. .\" (after all we have to have some way of detecting end of tape!). .TP .B \-I .br Ignore bursts of read errors. Used to explore a USB ram stick to find another live section beyond a dead section. eg { Light brown wood effect stick labelled HSM: "vendor" "0x0000"; "product" "0x7777"; "devclass" "0x00"; "devsubclass" "0x00"; "release" "0x0101"; "intclass" "0x08"; "intsubclass" "0x06"; http://www.berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/etc/devd/jhs.conf } .TP .B \-n [off] .br - Suppress the rewind that .I testblock normally does both before write and/or read. .br - Essential for both virgin tapes, & tapes previously written with a different block size or density (where the drive can for instance write 150M or 525M density)). .br - If you use this option, you are relying on the tape supplier, &/or drive electronics having correctly rewound the tape after insertion. .br - This option is useful if you want to call .I testblock from a script, to test the remainder of the tape, after initially skipping a tape label or other contents. .br - If -w & -r are both selected with -n, a caution is printed as the action required of .I testblock seems strange. .\" (think of the different scenarios: was the tape rewound before .\" .I testblock .\" was called, is the named device a `no rewind after use' device). .TP .B \-b Block_Size [60k or 8k] .br Change block size. .br ( Default block size if i386 is defined (as it is in FreeBSD) is 60K, else 8K (for Symmetric etc) ). \fB(***)\fR .TP .B \-l max_limit [0 = none] .br Set a maximum byte count limit. \fB(***)\fR .TP .B \-f fail_limit [0 = none] .br Set a fail byte count limit. User specified threshold (in bytes), below which, we dont bother to do a read after write (typically for a suspect/unknown tape being tested before being discarded as too short) (0=unset, ie never inhibit read after write). \fB(***)\fR. .TP .B \-s seconds [0] .br Number of seconds sleep between a write & then a read. (some tape drive need a sleep else will error). .TP .B \-d data_byte [off] .br Every byte in every data block is forced to have the fixed hexadecimal value data_byte (rather than the normal incrementing range of values, where the first .I testblock data block starts 0x00, 0x01, 0x02 etc). -d over-rides -0. .TP .B \-0 [off] .br This option forces each block to start at 0. ( Normally the value of byte zero in each succesive block is incremented by 1 from the value of byte 0 in the previous block, thus block 0 byte 0 has offset 0, block 5 byte 0 has value 5, block 7 byte 3 has value 10. ) To check data created by .I testblock versions prior to V2.0 96.04.02, you must use this flag. .TP \fB(***)\fR Note: If the last character of the size is a 'g' or a 'G' (for Giga), size is multiplied by 1024 * 1024 * 1024; If 'm' or 'M' (for Mega), by 1024 * 1024; If 'k' or 'K' (for Kilo), by 1024; If 'b' or 'B' (for Blocks), by 512; If 'w' or 'W' (for Words), by 2. .SH INPUT and OUTPUT If -r and -w are both specified, then writing is done before reading. You cannot simultaneously use all these three options -- & -w & -r. (as this would first write the output pipe, then read the input pipe, which would be rather weird, and not make much sense). Both and are used by .I testblock. If .I testblock has set itself into `output to pipe mode' (by use of -- & -w), all diagnostic and error reports are sent to , otherwise only syntax/invocation errors are to , and media/file access errors are sent to (to ease error logging under a variety of different command interpreters). .\" This program is not only written to run on Unix that has the luxury of .\" stdout & stderr, but also hopes to run on DOS command.com. .I Testblock rewinds tapes before writing them by opening then closing the file, thus trying to ensure the tape is rewound before use, in case a tape has not been rewound after last use. .SH EXAMPLES Example 1 .in +4 .I testblock -b 1k -l 800k .in -4 Explanation 1 .in +4 Write and then read a standard format Symmetric floppy, of capacity 800k bytes, using a block size of 1k bytes, testing the floppy media (and destroying any previously existing data of course). .in -4 Example 2 .in +4 Under FreeBSD-2.1 (CD Release): .br testblock -n -v -b 256w /dev/rsd2 .in -4 Explanation 2 .in +4 This will write then read /dev/rsd2, using a block size of 512. .br This will test the entire disc, first destroying the MBR / 4 Fdisk slices info, & then continuing to overwrite rest of drive sd2. .I Testblock report back the size of the entire physical disc, in the form of a `fail to write more than (example) 200 Meg. (but if you just want to know the size, on FreeBSD it's much quicker to use .I dmesg instead. .in -4 .SH LIMITATIONS .I Testblock is not a standard Unix command, it is unique to JHS/VSL systems with the Berklix overlay. Msdos users wishing to validate tapes must supply their own device driver, making the drive available as a file name to .I testblock. .I Testblock does not check what sort of name it is given, so do not give it a `non rewind on completion' tape drive special file names, if you intend to do a write+read test. .SH USE IN SYSTEM DEBUGING .I Testblock is a useful system debuging tool. .br .I Testblock was developed because tar & dd wouldn't work reliably with the author's `Symmetric' development host + TEAC cassette streamer. .I Testblock drove the streamer OK, thus proving the streamer was OK, & that the non streaming problem was associated with interaction with winchester drive activity. .\" Symmetric kernel device driver for Cassette Streamer .\" actually writes 8k bytes at a time to .\" /dev/rcst2, regardless of the block size this program passes to the system. .br .I Testblock can be used to prove if your device/driver combination does not do an adequate read after write check (the author's `Symmetric' development host consistently wrote 40M, but could only read 20M byte, on some cassette tapes). .br .I Testblock is being used by the author (04/96) to debug a problem involving FreeBSD sd, Adaptec 1542A, intermittent corruptions of 8 * 0xFF at beginning of 0x1000 boundaries. .SH SECURITY / FAST ERASURE Both DOS & Unix, `del file' & `rm file' do not really delete file data, but merely deallocate blocks, (viz. Norton undelete now available on SCO Unix), so invaders/spies/crackers can still read your `erased' data blocks ... until you erase unused blocks. .I testblock can erase large discs quickly, either used on raw physical devices, or within file systems, to erase all de-allocated spare free-chain blocks. Removable disk packs are a particular instance where .I testblock could be used to pack erase the disc before re-issue to someone else. .sp Making disc devices not readable by normal users is a sensible initial precaution, but deleting data on the free chain is easy with a .I /usr/lib/crontab + .I testblock combination. .sp .I testblock, if used with the correct blocking factor, can be faster on some discs than a low level format. .sp Some systems do not allow low level formatting except from the eprom/monitor, whereas .I testblock can even be run remotely, if your machine has been captured, but not taken off the net (eg embassy invassion perhaps ?) A pre-prepared panic script can obliterates a list of discs rather than just the single disc at a time that system/eprom monitor + human operator interaction requires. ( If one is truly paranoid, even after testblock, I suspect that if discs that are physically captured, they can be read by special disk diagnostic machines, that read marginal edge-of-track data, by increasing read head op amp sensitivity, and realigning heads to read the reduced strength stray field down the edge of old tracks. ) .SH PROGRAM INTERNALS .I Testblock checks its `C' read(2) and write(2) calls not merely looking for a negative return code error, but positively checking that the number of bytes read/written is exactly correct. .in +4 This has been used to remind the author that although a Unix command such as .ce dd if=/dev/rmt1 obs=64k | testblock -r -- -v -b 64k .br might be expected to work, it will not, because a Unix kernel typically only passes up to 4k bytes at a time down pipes, further if you dont know the maximum pipe block size on your system, issuing several different size variants of the above command will determine it. .in -4 .SH EXIT CODE 0 if no errors occur, else number of errors .\" or is it number of failing files ? detected before aborting. .SH BUGS - Not 64 bit clean. Not tested beyond 31 bit ie 2 gig. Only half written to 64 bit so far. Gives ridiculosus large byte count when writing a 50 gig test file with -v. .br - Writes blocks, so .ce .I testblock \ -l 170 -b 100 .br writes 200 bytes, and causes .I testblock to think an error has occured when it can not read the last 30 bytes. .sp On FreeBSD current @ 96.03 , the rwt device stream writes at 16K, but on reading back does not stream, this is perhaps a fault of the wt driver software.) Should (but does not yet) default to the prefered block size of the device (st_blksize), referenced in .I man 2 stat, (as displayed by my .I stat(1) command). .SH HOST OP SYSTEM This utility runs on Unix UCB BSD 4.2 + 50/60M Cassettes, Msdos 3.2 (files only), UNIX SVR4 i486 + Tandberg QIC525, all FreeBSD versions. .TO DO Should work under msdos on tape drives, if integrated with Adaptec ASPI for DOS SCSI Tape Drivers, but not tried. .SH COPYRIGHT Program Copyright Julian H. Stacey, Munich, 14th March 1990. .br Document Copyright Julian H. Stacey, Munich, 15th March 1990. .so author.jhs .SH HISTORY Program written to test suspect hardware & driver software, on my Symmetric 375 BSD4.2 system with bad scsi cassette tape using restore: .in +2 .nf partial block read: 10239 should be 10240 abort? [yn] n partial block read: 1 should be 10240 abort? [yn] .fi .in -2 .SH FILES /dev/rtape Default Unix file to read and write (administrator should create a symbolic link to device name such as rmt8). .SH SEE ALSO valid(p) For tape capacities see: http://www.berklix.com/~jhs/standards/qic .\" End