/*	@(#)mtio.h	13.1 (Tolerant) 91/02/02	*/

/*
 * mtio.h -- structures and definitions for mag tape I/O control commands
 */

#define	MAX_MTBLOCK	(64 * 1024)	/* 64k is the max. tape block size */

/* structure for MTIOCTOP - mag tape op command */
struct mtop
{
	short	mt_op;		/* operations defined below */
	daddr_t	mt_count;	/* how many of them */
};

/* operations */
#define MTWEOF	0	/* write an end-of-file record */
#define MTFSF	1	/* forward space file */
#define MTBSF	2	/* backward space file */
#define MTFSR	3	/* forward space record */
#define MTBSR	4	/* backward space record */
#define MTREW	5	/* rewind */
#define MTOFFL	6	/* rewind and put the drive offline */
#define MTNOP	7	/* no operation, sets status only */

		    /* the following are non-standard functions */
		    /* and are subject to change */
#define	MTRETEN	10	/* retension tape */
#define	MTERASE	11	/* erase whole tape */
#define	MTDISPL	12	/* change display indicator */
#define	MTNOREW	13	/* do not rewind at close */
#define	MTRESET	14	/* reset error status */
#define	MT6250	15	/* set density to 6250 BPI */
#define	MT1600	16	/* set density to 1600 BPI */

/* structure for MTIOCGET - mag tape get status command */
/* ***subject to change*** */

struct mtget
{
	short	mt_type;	/* type of magtape device */
/* the following two registers are grossly device dependent */
	short	mt_dsreg;	/* ``drive status'' register */
	short	mt_erreg;	/* ``error'' register */
/* end device-dependent registers */
	short	mt_resid;	/* residual count */
/* the following two are not yet implemented */
	daddr_t	mt_fileno;	/* file number of current position */
	daddr_t	mt_blkno;	/* block number of current position */
/* end not yet implemented */
/* the following are non-standard totals (only cleared by MTIOCZERO) */
	long	mt_skips;	/* files skipped */
	long	mt_reads;	/* blocks successfully read */
	long	mt_writes;	/* blocks successfully written */
	long	mt_readerrors;	/* unrecoverable read errors */
	long	mt_writeerrors;	/* unrecoverable write errors */
	long	mt_retries;	/* retries performed (read and write) */
};

/*
 * Constants for mt_type byte
 */
#define MT_CIPHER	01	/* 1600/3200 bpi Cipher streaming drive */

/* structure for MTIOBUFFERED - mag tape using bufferred tape i/o command */
struct mtbuf
{
    u_long	mt_block_size;	/* tape block size (in bytes) */
    short	mt_rw;		/* MTREAD or MTWRITE */
};

#define	MTREAD		01	/* bufferred tape i/o on read */
#define	MTWRITE		02	/* bufferred tape i/o on write */

/* mag tape io control commands */
#define	MTIOCTOP	_IOW('m', 1, struct mtop)	/* do a mag tape op */
#define	MTIOCGET	_IOR('m', 2, struct mtget)	/* get tape status */
#define	MTIOBUFFERED	_IOW('m', 3, struct mtbuf)	/* bufferred tape i/o */
