static char *sccsid
= "@(#)mt.c 4.3 (Berkeley) 81/11/12";
* magnetic tape manipulation program
#define equal(s1,s2) (strcmp(s1, s2) == 0)
#define DEFTAPE "/dev/rmt12"
{ "offline", MTOFFL
, 1 },
{ "rewoffl", MTOFFL
, 1 },
char line
[80], *getenv();
register struct commands
*comp
;
fprintf(stderr
, "usage: mt [ -f device ] command [ count ]\n");
if ((equal(argv
[1], "-t") || equal(argv
[1], "-f")) && argc
> 2) {
if ((tape
= getenv("TAPE")) == NULL
)
for (comp
= com
; comp
->c_name
!= NULL
; comp
++)
if (strncmp(cp
, comp
->c_name
, strlen(cp
)) == 0)
if (comp
->c_name
== NULL
) {
fprintf(stderr
, "mt: don't grok \"%s\"\n", cp
);
if ((mtfd
= open(tape
, comp
->c_ronly
? 0 : 2)) < 0) {
if (comp
->c_code
!= MTNOP
) {
mt_com
.mt_op
= comp
->c_code
;
mt_com
.mt_count
= (argc
> 2 ? atoi(argv
[2]) : 1);
if (mt_com
.mt_count
< 0) {
fprintf(stderr
, "mt: negative repeat count\n");
if (ioctl(mtfd
, MTIOCTOP
, &mt_com
) < 0) {
fprintf(stderr
, "%s %d ", comp
->c_name
,
if (ioctl(mtfd
, MTIOCGET
, (char *)&mt_status
) < 0) {
#undef b_repcnt /* argh */
short t_type
; /* type of magtape device */
char *t_name
; /* printing name */
char *t_dsbits
; /* "drive status" register */
char *t_erbits
; /* "error" register */
{ MT_ISTS
, "ts11", 0, TSXS0_BITS
},
{ MT_ISHT
, "tm03", HTDS_BITS
, HTER_BITS
},
{ MT_ISTM
, "tm11", 0, TMER_BITS
},
{ MT_ISMT
, "tu78", MTDS_BITS
, 0 },
{ MT_ISUT
, "tu45", UTDS_BITS
, UTER_BITS
},
* Interpret the status buffer returned
register struct mtget
*bp
;
register struct tape_desc
*mt
;
for (mt
= tapes
; mt
->t_type
; mt
++)
if (mt
->t_type
== bp
->mt_type
)
printf("unknown tape drive type (%d)\n", bp
->mt_type
);
printf("%s tape drive\n", mt
->t_name
);
printreg("ds", bp
->mt_dsreg
, mt
->t_dsbits
);
printreg(" er", bp
->mt_erreg
, mt
->t_erbits
);
printf("\nresidual=%d\n", bp
->mt_resid
);
* Print a register a la the %b format of the kernel's printf
for (; (c
= *bits
) > 32; bits
++)
for (; *bits
> 32; bits
++)