[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5

tctl Command

Purpose

Gives subcommands to a streaming tape device.

Syntax

tctl-f Device ] [  eof | weof | fsf | bsf | fsr | bsr | rewind | offline rewoffl | erase | retension | reset | status ] [ Count ]

tctl-b BlockSize ] [  -f Device ] [  -p BufferSize ] [  -v ] [  -n ] [  -B ] {  read | write }

Description

The tctl command gives subcommands to a streaming tape device. If you do not specify the Device variable with the -f flag, the TAPE environment variable is used. If the environment variable does not exist, the tctl command uses the /dev/rmt0.1 device. (When the tctl command gives the status subcommand, the default device is /dev/rmt0.) The Device variable must specify a raw (not block) tape device. The Count parameter specifies the number of end-of-file markers, number of file marks, or number of records. If the Count parameter is not specified, the default count is 1.

Subcommands

eof or weof Writes the number of end-of-file markers specified by the Count parameter at the current position on the tape. On an 8 mm tape drive, an end-of-file marker can be written in three places:
  • Before blank tape
  • Before an extended file mark
  • At the beginning-of-tape mark

On a 9-track tape drive, the end-of-tape marker can be written at any location on the tape. However, this subcommand does not support overwriting single blocks of data.

fsf Moves the tape forward the number of file marks specified by the Count parameter and positions it on the end-of-tape (EOT) side of the file mark.
bsf Moves the tape backward the number of file marks specified by the Count parameter and positions it on the beginning-of-tape (BOT) side of the file mark.
  If the bsf subcommand moves the tape past the beginning, the tape rewinds, and the tctl command returns EIO.
fsr Moves the tape forward the number of records specified by the Count parameter.
bsr Moves the tape backwards the number of records specified by the Count parameter.
rewind Rewinds the tape. The Count parameter is ignored.
offline or rewoffl Rewinds the tape and takes the tape drive offline. This will unload the tape when appropriate. The tape must be re-inserted before the device can be used again.
erase Erases all contents on the tape and rewinds it.
read Reads from the specified tape device (using the specified block size) until the internal buffer is full, and then writes the data to standard output, continuing to read and write this way until an end-of-file (EOF) mark is reached.
reset Sends a bus device reset (BDR) to the tape device. The BDR will only be sent if the device cannot be opened and is not busy.
retension Moves the tape to the beginning, then to the end, and then back to the beginning of the tape. If you have excessive read errors during a restore operation, you should run the retension subcommand. If the tape has been exposed to environmental extremes, you should run the retension subcommand before writing to tape. The 8 mm tape drive will not respond to this command.
status Prints status information about the specified tape device.
write Opens the tape device, reads from standard input, and writes the data to the tape device.

Notes:
  1. When you specify the read or write subcommand, the tctl command opens the tape device and sets up the tape block size as specified by the -b or -n flag. If neither flag is specified, the tctl command uses a default block size of 512 bytes.
  2. The -b, -n, -p, and -v flags apply only when using the read and write subcommands.
  3. The -B flag applies only when using the read subcommand.

Flags

-b BlockSize Specifies, in bytes, the size of buffer used to read and write to the tape device, and also specifies, in the absence of the -n flag, the tape block size. If the block size is 0, variable-length blocks are used and the size of the tape buffer is 32,768. If the -b flag is not specified, the default block size and the size of the tape buffer is 512 bytes.
-B Writes the contents of the buffer each time the tape is read. Set this flag when reading variable-length records that are not of a regular and consistent size.
-f Device Specifies the tape device.
-p BufferSize Specifies the size of the buffer to be used on standard input and standard output. The default buffer size is 32,768 bytes. The BufferSize value must be a multiple of the tape block size.
-v Verbose. Prints the sizes of each read and write to standard error.
-n Specifies variable-length records when reading or writing to tape with the read or write subcommand.

Exit Status

This command returns the following exit values:

0 Successful completion.
>0 An error occurred.

Examples

  1. To rewind the rmt1 tape device, enter:
    tctl  -f /dev/rmt1  rewind
  2. To move forward two file marks on the default tape device, enter:
    tctl  fsf 2
  3. To write two end-of-file markers on the tape in /dev/rmt0.6, enter:
    tctl  -f /dev/rmt0.6  weof 2
  4. To read a tape device formatted in 80-byte blocks and put the result in a file, enter:
    tctl -b 80  read > file
  5. To read variable-length records from a tape device formatted in 80-byte blocks and put the result in a file, enter:
    tctl -b 80  -n read > file
  6. To write variable-length records to a tape device using a buffer size of 1024 byes, enter:
    cat file | tctl -b 1024 -n -f/dev/rmt1 write
  7. To write to a tape device in 512-byte blocks and use a 5120-byte buffer for standard input, enter:
    cat file | tctl -v -f /dev/rmt1 -p 5120 -b 512 write

    Note: The only valid block sizes for quarter-inch (QIC) tape drives are 0 and 512.
  8. To write over one of several backups on an 8 mm tape, position the tape at the start of the backup file and issue these commands:
    tctl bsf 1

    tctl eof 1

The first command moves the tape to the beginning-of-tape side of the file mark. The second command rewrites the file mark, because writing is allowed before extended file marks. The erase head of the drive erases data before the write head reaches it, so the write subroutines can write over data already in the tape. However, all old data following is lost because its file markers are meaningless.

Note: The write subroutines cannot write over a short file mark unless blank tape follows the short file mark. To write over existing data, as in the case of this example, the tape must be written with extended file marks (as specified through the SMIT interface).

Files

/dev/rmtn Specifies the raw streaming tape interface.
/usr/bin/tctl Contains the tctl command.

Related Information

The dd command, mt command.

The environment file, rmt special file.

The ioctl subroutine.

Backup Files and Storage Media Overview in AIX 5L Version 5.2 System User's Guide: Operating System and Devices.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]