The Ftape Installation and Usage Guide - Ioctls
MTIOCRDFTSEG
and MTIOCWRFTSEG
are provided by the driver
to allow implementation of a really QIC-113 conforming backup
program in user space without having to write a new kernel level device
driver (refer to the QIC-113 standard, QIC Organisations Home Page). Such a program
should use the `/dev/rawft*
' and `/dev/nrawft*
' devices
only, because ftape-3.04d (and later versions) omits manipulation of the volume
table when used with this devices such that the user level program gains
complete control over the logical data structure of the floppy tape
cartridge (see Raw tape access devices).
Such a `QIC-113 Backup Program
' still should use the normal
read()
and write()
system calls to read and write most of
the data to the tape and use the ioctls only to manipulate the header
segments and the volume table segment.
Note that the return value of the ioctl command is not the
result of the ft_read_segment()
or ft_write_segment()
functions, but indicates only ioctl command failure or success. If the
calling program likes to read or write damaged segments, let it do
that. The result of the read/write operation is stored in the
`mt_result
' field of struct mtftseg
.
The following simple structure is used to read or write a single segment. One may also read and write the header segments, but that means that one has to act really carefully, because neither ftape-3.04d (and later versions) nor any other tape program will be able to read or write to a tape any longer if garbage is written to the header segments.
The mt_mode
component controls how the data is read and
written. MT_FT_RD_AHEAD
causes the driver to read as much data
from the tape as fits into the dma buffers such that subsequent calls
with incremented segment number will result in continuous tape motion.
MT_FT_WR_ASYNC
will only result in data transfer when all dma
buffers are full. The data is also flushed to tape when the state of the
driver changes or when the device is closed. MT_FT_WR_SINGLE
and
MT_FT_RD_SINGLE
will stop the tape after the desired segment has
been read or written. MT_FT_WR_MULTI
causes the tape to write the
segment. The tape drive will continue streaming if more data is provided
but subsequent ioctls.
The volume table manipulation tools vtblc
(1)
(See Vtblc (info file ftape-tools)) makes use of this ioctl to read the
volume table and write it back to tape after modifying it.
#define MT_FT_RD_SINGLE 0 #define MT_FT_RD_AHEAD 1 #define MT_FT_WR_ASYNC 0 /* start tape only when all buffers are full */ #define MT_FT_WR_MULTI 1 /* start tape, continue until buffers are empty */ #define MT_FT_WR_SINGLE 2 /* write a single segment and stop afterwards */ #define MT_FT_WR_DELETE 3 /* write deleted data marks, one segment at time */ struct mtftseg { unsigned mt_segno; /* the segment to read or write */ unsigned mt_mode; /* modes for read/write (sync/async etc.) */ int mt_result; /* result of r/w request, not of the ioctl */ void *mt_data; /* User space buffer: must be 29kb */ }; #define MTIOCRDFTSEG _IOWR('m', 6, struct mtftseg) /* read a segment */ #define MTIOCWRFTSEG _IOWR('m', 7, struct mtftseg) /* write a segment */
(1) You can download it as part of the ftape-tools
package from the
Ftape Home Page
or from ftp://sunsite.unc.edu/pub/Linux/kernel/tapes/
![]() |
Use these buttons to jump to the top menu |