Introduce WANT_NETGRAPH7 make variable.
[dragonfly.git] / usr.bin / mt / mt.c
blob8772f515e62cfadb533ee494e579e20ef4dfe2e8
1 /*
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
33 * @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved.
34 * @(#)mt.c 8.2 (Berkeley) 5/4/95
35 * $FreeBSD: src/usr.bin/mt/mt.c,v 1.26.2.3 2002/11/08 11:35:57 joerg Exp $
36 * $DragonFly: src/usr.bin/mt/mt.c,v 1.7 2005/09/10 21:03:27 swildner Exp $
40 * mt --
41 * magnetic tape manipulation program
43 #include <sys/types.h>
44 #include <sys/ioctl.h>
45 #include <sys/mtio.h>
47 #include <ctype.h>
48 #include <err.h>
49 #include <fcntl.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <string.h>
53 #include <unistd.h>
55 /* the appropriate sections of <sys/mtio.h> are also #ifdef'd for FreeBSD */
56 #if defined(__DragonFly__)
57 /* c_flags */
58 #define NEED_2ARGS 0x01
59 #define ZERO_ALLOWED 0x02
60 #define IS_DENSITY 0x04
61 #define DISABLE_THIS 0x08
62 #define IS_COMP 0x10
63 #endif /* defined(__DragonFly__) */
65 #ifndef TRUE
66 #define TRUE 1
67 #endif
68 #ifndef FALSE
69 #define FALSE 0
70 #endif
72 struct commands {
73 char *c_name;
74 int c_code;
75 int c_ronly;
76 #if defined(__DragonFly__)
77 int c_flags;
78 #endif /* defined(__DragonFly__) */
79 } com[] = {
80 { "bsf", MTBSF, 1 },
81 { "bsr", MTBSR, 1 },
82 #if defined(__DragonFly__)
83 /* XXX FreeBSD considered "eof" dangerous, since it's being
84 confused with "eom" (and is an alias for "weof" anyway) */
85 { "eof", MTWEOF, 0, DISABLE_THIS },
86 #else
87 { "eof", MTWEOF, 0 },
88 #endif
89 { "fsf", MTFSF, 1 },
90 { "fsr", MTFSR, 1 },
91 { "offline", MTOFFL, 1 },
92 { "rewind", MTREW, 1 },
93 { "rewoffl", MTOFFL, 1 },
94 { "status", MTNOP, 1 },
95 #if defined(__DragonFly__)
96 { "weof", MTWEOF, 0, ZERO_ALLOWED },
97 #else
98 { "weof", MTWEOF, 0 },
99 #endif
100 #if defined(__DragonFly__)
101 { "erase", MTERASE, 0, ZERO_ALLOWED},
102 { "blocksize", MTSETBSIZ, 0, NEED_2ARGS|ZERO_ALLOWED },
103 { "density", MTSETDNSTY, 0, NEED_2ARGS|ZERO_ALLOWED|IS_DENSITY },
104 { "eom", MTEOD, 1 },
105 { "eod", MTEOD, 1 },
106 { "smk", MTWSS, 0 },
107 { "wss", MTWSS, 0 },
108 { "fss", MTFSS, 1 },
109 { "bss", MTBSS, 1 },
110 { "comp", MTCOMP, 0, NEED_2ARGS|ZERO_ALLOWED|IS_COMP },
111 { "retension", MTRETENS, 1 },
112 { "rdhpos", MTIOCRDHPOS, 0 },
113 { "rdspos", MTIOCRDSPOS, 0 },
114 { "sethpos", MTIOCHLOCATE, 0, NEED_2ARGS|ZERO_ALLOWED },
115 { "setspos", MTIOCSLOCATE, 0, NEED_2ARGS|ZERO_ALLOWED },
116 { "errstat", MTIOCERRSTAT, 0 },
117 { "setmodel", MTIOCSETEOTMODEL, 0, NEED_2ARGS|ZERO_ALLOWED },
118 { "seteotmodel", MTIOCSETEOTMODEL, 0, NEED_2ARGS|ZERO_ALLOWED },
119 { "getmodel", MTIOCGETEOTMODEL },
120 { "geteotmodel", MTIOCGETEOTMODEL },
121 #endif /* defined(__DragonFly__) */
122 { NULL }
125 void printreg(char *, u_int, char *);
126 void status(struct mtget *);
127 void usage(void);
128 #if defined (__DragonFly__)
129 void st_status (struct mtget *);
130 int stringtodens (const char *s);
131 const char *denstostring (int d);
132 int denstobp(int d, int bpi);
133 u_int32_t stringtocomp(const char *s);
134 const char * comptostring(u_int32_t comp);
135 void warn_eof(void);
136 #endif /* defined (__DragonFly__) */
139 main(int argc, char **argv)
141 struct commands *comp;
142 struct mtget mt_status;
143 struct mtop mt_com;
144 int ch, len, mtfd;
145 char *p, *tape;
147 if ((tape = getenv("TAPE")) == NULL)
148 tape = DEFTAPE;
150 while ((ch = getopt(argc, argv, "f:t:")) != -1)
151 switch(ch) {
152 case 'f':
153 case 't':
154 tape = optarg;
155 break;
156 case '?':
157 default:
158 usage();
160 argc -= optind;
161 argv += optind;
163 if (argc < 1 || argc > 2)
164 usage();
166 len = strlen(p = *argv++);
167 for (comp = com;; comp++) {
168 if (comp->c_name == NULL)
169 errx(1, "%s: unknown command", p);
170 if (strncmp(p, comp->c_name, len) == 0)
171 break;
173 #if defined(__DragonFly__)
174 if((comp->c_flags & NEED_2ARGS) && argc != 2)
175 usage();
176 if(comp->c_flags & DISABLE_THIS) {
177 warn_eof();
179 #endif /* defined(__DragonFly__) */
180 if ((mtfd = open(tape, comp->c_ronly ? O_RDONLY : O_RDWR)) < 0)
181 err(1, "%s", tape);
182 if (comp->c_code != MTNOP) {
183 mt_com.mt_op = comp->c_code;
184 if (*argv) {
185 #if defined (__DragonFly__)
186 if (!isdigit(**argv) &&
187 (comp->c_flags & IS_DENSITY)) {
188 const char *dcanon;
189 mt_com.mt_count = stringtodens(*argv);
190 if (mt_com.mt_count == 0)
191 errx(1, "%s: unknown density", *argv);
192 dcanon = denstostring(mt_com.mt_count);
193 if (strcmp(dcanon, *argv) != 0)
194 printf(
195 "Using \"%s\" as an alias for %s\n",
196 *argv, dcanon);
197 p = "";
198 } else if (!isdigit(**argv) &&
199 (comp->c_flags & IS_COMP)) {
201 mt_com.mt_count = stringtocomp(*argv);
202 if ((u_int32_t)mt_com.mt_count == 0xf0f0f0f0)
203 errx(1, "%s: unknown compression",
204 *argv);
205 p = "";
206 } else
207 /* allow for hex numbers; useful for density */
208 mt_com.mt_count = strtol(*argv, &p, 0);
209 #else
210 mt_com.mt_count = strtol(*argv, &p, 10);
211 #endif /* defined(__DragonFly__) */
212 if ((mt_com.mt_count <=
213 #if defined (__DragonFly__)
214 ((comp->c_flags & ZERO_ALLOWED)? -1: 0)
215 && ((comp->c_flags & IS_COMP) == 0)
216 #else
218 #endif /* defined (__DragonFly__) */
219 ) || *p)
220 errx(1, "%s: illegal count", *argv);
222 else
223 mt_com.mt_count = 1;
224 #if defined(__DragonFly__)
225 switch (comp->c_code) {
226 case MTIOCERRSTAT:
228 int i;
229 union mterrstat umn;
230 struct scsi_tape_errors *s = &umn.scsi_errstat;
232 if (ioctl(mtfd, comp->c_code, (caddr_t)&umn) < 0)
233 err(2, "%s", tape);
234 (void)printf("Last I/O Residual: %u\n", s->io_resid);
235 (void)printf(" Last I/O Command:");
236 for (i = 0; i < sizeof (s->io_cdb); i++)
237 (void)printf(" %02X", s->io_cdb[i]);
238 (void)printf("\n");
239 (void)printf(" Last I/O Sense:\n\n\t");
240 for (i = 0; i < sizeof (s->io_sense); i++) {
241 (void)printf(" %02X", s->io_sense[i]);
242 if (((i + 1) & 0xf) == 0) {
243 (void)printf("\n\t");
246 (void)printf("\n");
247 (void)printf("Last Control Residual: %u\n",
248 s->ctl_resid);
249 (void)printf(" Last Control Command:");
250 for (i = 0; i < sizeof (s->ctl_cdb); i++)
251 (void)printf(" %02X", s->ctl_cdb[i]);
252 (void)printf("\n");
253 (void)printf(" Last Control Sense:\n\n\t");
254 for (i = 0; i < sizeof (s->ctl_sense); i++) {
255 (void)printf(" %02X", s->ctl_sense[i]);
256 if (((i + 1) & 0xf) == 0) {
257 (void)printf("\n\t");
260 (void)printf("\n\n");
261 exit(0);
262 /* NOTREACHED */
264 case MTIOCRDHPOS:
265 case MTIOCRDSPOS:
267 u_int32_t block;
268 if (ioctl(mtfd, comp->c_code, (caddr_t)&block) < 0)
269 err(2, "%s", tape);
270 (void)printf("%s: %s block location %u\n", tape,
271 (comp->c_code == MTIOCRDHPOS)? "hardware" :
272 "logical", block);
273 exit(0);
274 /* NOTREACHED */
276 case MTIOCSLOCATE:
277 case MTIOCHLOCATE:
279 u_int32_t block = (u_int32_t)mt_com.mt_count;
280 if (ioctl(mtfd, comp->c_code, (caddr_t)&block) < 0)
281 err(2, "%s", tape);
282 exit(0);
283 /* NOTREACHED */
285 case MTIOCGETEOTMODEL:
287 u_int32_t om;
288 if (ioctl(mtfd, MTIOCGETEOTMODEL, (caddr_t)&om) < 0)
289 err(2, "%s", tape);
290 (void)printf("%s: the model is %u filemar%s at EOT\n",
291 tape, om, (om > 1)? "ks" : "k");
292 exit(0);
293 /* NOTREACHED */
295 case MTIOCSETEOTMODEL:
297 u_int32_t om, nm = (u_int32_t)mt_com.mt_count;
298 if (ioctl(mtfd, MTIOCGETEOTMODEL, (caddr_t)&om) < 0)
299 err(2, "%s", tape);
300 if (ioctl(mtfd, comp->c_code, (caddr_t)&nm) < 0)
301 err(2, "%s", tape);
302 (void)printf("%s: old model was %u filemar%s at EOT\n",
303 tape, om, (om > 1)? "ks" : "k");
304 (void)printf("%s: new model is %u filemar%s at EOT\n",
305 tape, nm, (nm > 1)? "ks" : "k");
306 exit(0);
307 /* NOTREACHED */
309 default:
310 break;
312 #endif
313 if (ioctl(mtfd, MTIOCTOP, &mt_com) < 0)
314 err(1, "%s: %s", tape, comp->c_name);
315 } else {
316 if (ioctl(mtfd, MTIOCGET, &mt_status) < 0)
317 err(1, NULL);
318 status(&mt_status);
320 exit(0);
321 /* NOTREACHED */
324 #ifdef sun
325 #include <sundev/tmreg.h>
326 #include <sundev/arreg.h>
327 #endif
329 #if defined(__DragonFly__) && defined(__i386__)
330 #include <machine/wtio.h>
331 #endif
333 struct tape_desc {
334 short t_type; /* type of magtape device */
335 char *t_name; /* printing name */
336 char *t_dsbits; /* "drive status" register */
337 char *t_erbits; /* "error" register */
338 } tapes[] = {
339 #ifdef sun
340 { MT_ISCPC, "TapeMaster", TMS_BITS, 0 },
341 { MT_ISAR, "Archive", ARCH_CTRL_BITS, ARCH_BITS },
342 #endif
343 #if defined (__DragonFly__)
345 * XXX This is weird. The st driver reports the tape drive
346 * as 0x7 (MT_ISAR - Sun/Archive compatible); the wt driver
347 * either reports MT_ISVIPER1 for an Archive tape, or 0x11
348 * (MT_ISMFOUR) for other tapes.
349 * XXX for the wt driver, rely on it behaving like a "standard"
350 * magtape driver.
352 { MT_ISAR, "SCSI tape drive", 0, 0 },
353 #if defined (__i386__)
354 { MT_ISVIPER1, "Archive Viper", WTDS_BITS, WTER_BITS },
355 { MT_ISMFOUR, "Wangtek", WTDS_BITS, WTER_BITS },
356 #endif
357 #endif /* defined (__DragonFly__) */
358 { 0 }
362 * Interpret the status buffer returned
364 void
365 status(struct mtget *bp)
367 struct tape_desc *mt;
369 for (mt = tapes;; mt++) {
370 if (mt->t_type == 0) {
371 (void)printf("%d: unknown tape drive type\n",
372 bp->mt_type);
373 return;
375 if (mt->t_type == bp->mt_type)
376 break;
378 #if defined (__DragonFly__)
379 if(mt->t_type == MT_ISAR)
380 st_status(bp);
381 else {
382 #endif /* defined (__DragonFly__) */
383 (void)printf("%s tape drive, residual=%d\n", mt->t_name, bp->mt_resid);
384 printreg("ds", (unsigned short)bp->mt_dsreg, mt->t_dsbits);
385 printreg("\ner", (unsigned short)bp->mt_erreg, mt->t_erbits);
386 (void)putchar('\n');
387 #if defined (__DragonFly__)
389 #endif /* defined (__DragonFly__) */
393 * Print a register a la the %b format of the kernel's printf.
395 void
396 printreg(char *s, u_int v, char *bits)
398 int i, any = 0;
399 char c;
401 if (bits && *bits == 8)
402 printf("%s=%o", s, v);
403 else
404 printf("%s=%x", s, v);
405 if (!bits)
406 return;
407 bits++;
408 if (v && bits) {
409 putchar('<');
410 while ((i = *bits++)) {
411 if (v & (1 << (i-1))) {
412 if (any)
413 putchar(',');
414 any = 1;
415 for (; (c = *bits) > 32; bits++)
416 putchar(c);
417 } else
418 for (; *bits > 32; bits++)
421 putchar('>');
425 void
426 usage(void)
428 (void)fprintf(stderr, "usage: mt [-f device] command [ count ]\n");
429 exit(1);
432 #if defined (__DragonFly__)
434 struct densities {
435 int dens;
436 int bpmm;
437 int bpi;
438 const char *name;
439 } dens[] = {
441 * Taken from T10 Project 997D
442 * SCSI-3 Stream Device Commands (SSC)
443 * Revision 11, 4-Nov-97
445 /*Num. bpmm bpi Reference */
446 { 0x1, 32, 800, "X3.22-1983" },
447 { 0x2, 63, 1600, "X3.39-1986" },
448 { 0x3, 246, 6250, "X3.54-1986" },
449 { 0x5, 315, 8000, "X3.136-1986" },
450 { 0x6, 126, 3200, "X3.157-1987" },
451 { 0x7, 252, 6400, "X3.116-1986" },
452 { 0x8, 315, 8000, "X3.158-1987" },
453 { 0x9, 491, 37871, "X3.180" },
454 { 0xA, 262, 6667, "X3B5/86-199" },
455 { 0xB, 63, 1600, "X3.56-1986" },
456 { 0xC, 500, 12690, "HI-TC1" },
457 { 0xD, 999, 25380, "HI-TC2" },
458 { 0xF, 394, 10000, "QIC-120" },
459 { 0x10, 394, 10000, "QIC-150" },
460 { 0x11, 630, 16000, "QIC-320" },
461 { 0x12, 2034, 51667, "QIC-1350" },
462 { 0x13, 2400, 61000, "X3B5/88-185A" },
463 { 0x14, 1703, 43245, "X3.202-1991" },
464 { 0x15, 1789, 45434, "ECMA TC17" },
465 { 0x16, 394, 10000, "X3.193-1990" },
466 { 0x17, 1673, 42500, "X3B5/91-174" },
467 { 0x18, 1673, 42500, "X3B5/92-50" },
468 { 0x19, 2460, 62500, "DLTapeIII" },
469 { 0x1A, 3214, 81633, "DLTapeIV(20GB)" },
470 { 0x1B, 3383, 85937, "DLTapeIV(35GB)" },
471 { 0x1C, 1654, 42000, "QIC-385M" },
472 { 0x1D, 1512, 38400, "QIC-410M" },
473 { 0x1E, 1385, 36000, "QIC-1000C" },
474 { 0x1F, 2666, 67733, "QIC-2100C" },
475 { 0x20, 2666, 67733, "QIC-6GB(M)" },
476 { 0x21, 2666, 67733, "QIC-20GB(C)" },
477 { 0x22, 1600, 40640, "QIC-2GB(C)" },
478 { 0x23, 2666, 67733, "QIC-875M" },
479 { 0x24, 2400, 61000, "DDS-2" },
480 { 0x25, 3816, 97000, "DDS-3" },
481 { 0x26, 3816, 97000, "DDS-4" },
482 { 0x27, 3056, 77611, "Mammoth" },
483 { 0x28, 1491, 37871, "X3.224" },
484 { 0x41, 3868, 98250, "DLTapeIV(40GB)" },
485 { 0x48, 5236, 133000, "SDLTapeI(110)" },
486 { 0x49, 7598, 193000, "SDLTapeI(160)" },
487 { 0, 0, 0, NULL }
490 struct compression_types {
491 u_int32_t comp_number;
492 const char *name;
493 } comp_types[] = {
494 { 0x00, "none" },
495 { 0x00, "off" },
496 { 0x10, "IDRC" },
497 { 0x20, "DCLZ" },
498 { 0xffffffff, "enable" },
499 { 0xffffffff, "on" },
500 { 0xf0f0f0f0, NULL}
503 const char *
504 denstostring(int d)
506 static char buf[20];
507 struct densities *sd;
509 /* densities 0 and 0x7f are handled as special cases */
510 if (d == 0)
511 return "default";
512 if (d == 0x7f)
513 return "same";
514 for (sd = dens; sd->dens; sd++)
515 if (sd->dens == d)
516 break;
517 if (sd->dens == 0)
518 sprintf(buf, "0x%02x", d);
519 else
520 sprintf(buf, "0x%02x:%s", d, sd->name);
521 return buf;
525 * Given a specific density number, return either the bits per inch or bits
526 * per millimeter for the given density.
529 denstobp(int d, int bpi)
531 struct densities *sd;
533 for (sd = dens; sd->dens; sd++)
534 if (sd->dens == d)
535 break;
536 if (sd->dens == 0)
537 return(0);
538 else {
539 if (bpi)
540 return(sd->bpi);
541 else
542 return(sd->bpmm);
547 stringtodens(const char *s)
549 struct densities *sd;
550 size_t l = strlen(s);
552 for (sd = dens; sd->dens; sd++)
553 if (strncasecmp(sd->name, s, l) == 0)
554 break;
555 return sd->dens;
559 const char *
560 getblksiz(int bs)
562 static char buf[25];
563 if (bs == 0)
564 return "variable";
565 else {
566 sprintf(buf, "%d bytes", bs);
567 return buf;
571 const char *
572 comptostring(u_int32_t comp)
574 static char buf[20];
575 struct compression_types *ct;
577 if (comp == MT_COMP_DISABLED)
578 return "disabled";
579 else if (comp == MT_COMP_UNSUPP)
580 return "unsupported";
582 for (ct = comp_types; ct->name; ct++)
583 if (ct->comp_number == comp)
584 break;
586 if (ct->comp_number == 0xf0f0f0f0) {
587 sprintf(buf, "0x%x", comp);
588 return(buf);
589 } else
590 return(ct->name);
593 u_int32_t
594 stringtocomp(const char *s)
596 struct compression_types *ct;
597 size_t l = strlen(s);
599 for (ct = comp_types; ct->name; ct++)
600 if (strncasecmp(ct->name, s, l) == 0)
601 break;
603 return(ct->comp_number);
606 void
607 st_status(struct mtget *bp)
609 printf("Mode Density Blocksize bpi "
610 "Compression\n"
611 "Current: %-17s %-12s %-7d %s\n"
612 "---------available modes---------\n"
613 "0: %-17s %-12s %-7d %s\n"
614 "1: %-17s %-12s %-7d %s\n"
615 "2: %-17s %-12s %-7d %s\n"
616 "3: %-17s %-12s %-7d %s\n",
617 denstostring(bp->mt_density), getblksiz(bp->mt_blksiz),
618 denstobp(bp->mt_density, TRUE), comptostring(bp->mt_comp),
619 denstostring(bp->mt_density0), getblksiz(bp->mt_blksiz0),
620 denstobp(bp->mt_density0, TRUE), comptostring(bp->mt_comp0),
621 denstostring(bp->mt_density1), getblksiz(bp->mt_blksiz1),
622 denstobp(bp->mt_density1, TRUE), comptostring(bp->mt_comp1),
623 denstostring(bp->mt_density2), getblksiz(bp->mt_blksiz2),
624 denstobp(bp->mt_density2, TRUE), comptostring(bp->mt_comp2),
625 denstostring(bp->mt_density3), getblksiz(bp->mt_blksiz3),
626 denstobp(bp->mt_density3, TRUE), comptostring(bp->mt_comp3));
628 if (bp->mt_dsreg != MTIO_DSREG_NIL) {
629 auto char foo[32];
630 const char *sfmt = "Current Driver State: %s.\n";
631 printf("---------------------------------\n");
632 switch (bp->mt_dsreg) {
633 case MTIO_DSREG_REST:
634 printf(sfmt, "at rest");
635 break;
636 case MTIO_DSREG_RBSY:
637 printf(sfmt, "Communicating with drive");
638 break;
639 case MTIO_DSREG_WR:
640 printf(sfmt, "Writing");
641 break;
642 case MTIO_DSREG_FMK:
643 printf(sfmt, "Writing Filemarks");
644 break;
645 case MTIO_DSREG_ZER:
646 printf(sfmt, "Erasing");
647 break;
648 case MTIO_DSREG_RD:
649 printf(sfmt, "Reading");
650 break;
651 case MTIO_DSREG_FWD:
652 printf(sfmt, "Spacing Forward");
653 break;
654 case MTIO_DSREG_REV:
655 printf(sfmt, "Spacing Reverse");
656 break;
657 case MTIO_DSREG_POS:
658 printf(sfmt,
659 "Hardware Positioning (direction unknown)");
660 break;
661 case MTIO_DSREG_REW:
662 printf(sfmt, "Rewinding");
663 break;
664 case MTIO_DSREG_TEN:
665 printf(sfmt, "Retensioning");
666 break;
667 case MTIO_DSREG_UNL:
668 printf(sfmt, "Unloading");
669 break;
670 case MTIO_DSREG_LD:
671 printf(sfmt, "Loading");
672 break;
673 default:
674 (void) sprintf(foo, "Unknown state 0x%x", bp->mt_dsreg);
675 printf(sfmt, foo);
676 break;
679 if (bp->mt_resid == 0 && bp->mt_fileno == (daddr_t) -1 &&
680 bp->mt_blkno == (daddr_t) -1)
681 return;
682 printf("---------------------------------\n");
683 printf("File Number: %ld\tRecord Number: %ld\tResidual Count %d\n",
684 bp->mt_fileno, bp->mt_blkno, bp->mt_resid);
687 void
688 warn_eof(void)
690 fprintf(stderr,
691 "The \"eof\" command has been disabled.\n"
692 "Use \"weof\" if you really want to write end-of-file marks,\n"
693 "or \"eom\" if you rather want to skip to the end of "
694 "recorded medium.\n");
695 exit(1);
698 #endif /* defined (__DragonFly__) */