mt.c revision 44618
1/* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 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. 20 * 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. 32 */ 33 34#ifndef lint 35static const char copyright[] = 36"@(#) Copyright (c) 1980, 1993\n\ 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)mt.c 8.2 (Berkeley) 5/4/95"; 43#endif 44static const char rcsid[] = 45 "$Id: mt.c,v 1.22 1999/03/02 06:27:59 mjacob Exp $"; 46#endif /* not lint */ 47 48/* 49 * mt -- 50 * magnetic tape manipulation program 51 */ 52#include <sys/types.h> 53#include <sys/ioctl.h> 54#include <sys/mtio.h> 55 56#include <ctype.h> 57#include <err.h> 58#include <fcntl.h> 59#include <stdio.h> 60#include <stdlib.h> 61#include <string.h> 62#include <unistd.h> 63 64/* the appropriate sections of <sys/mtio.h> are also #ifdef'd for FreeBSD */ 65#if defined(__FreeBSD__) 66/* c_flags */ 67#define NEED_2ARGS 0x01 68#define ZERO_ALLOWED 0x02 69#define IS_DENSITY 0x04 70#define DISABLE_THIS 0x08 71#define IS_COMP 0x10 72#endif /* defined(__FreeBSD__) */ 73 74#ifndef TRUE 75#define TRUE 1 76#endif 77#ifndef FALSE 78#define FALSE 0 79#endif 80 81struct commands { 82 char *c_name; 83 int c_code; 84 int c_ronly; 85#if defined(__FreeBSD__) 86 int c_flags; 87#endif /* defined(__FreeBSD__) */ 88} com[] = { 89 { "bsf", MTBSF, 1 }, 90 { "bsr", MTBSR, 1 }, 91#if defined(__FreeBSD__) 92 /* XXX FreeBSD considered "eof" dangerous, since it's being 93 confused with "eom" (and is an alias for "weof" anyway) */ 94 { "eof", MTWEOF, 0, DISABLE_THIS }, 95#else 96 { "eof", MTWEOF, 0 }, 97#endif 98 { "fsf", MTFSF, 1 }, 99 { "fsr", MTFSR, 1 }, 100 { "offline", MTOFFL, 1 }, 101 { "rewind", MTREW, 1 }, 102 { "rewoffl", MTOFFL, 1 }, 103 { "status", MTNOP, 1 }, 104#if defined(__FreeBSD__) 105 { "weof", MTWEOF, 0, ZERO_ALLOWED }, 106#else 107 { "weof", MTWEOF, 0 }, 108#endif 109#if defined(__FreeBSD__) 110 { "erase", MTERASE, 0, ZERO_ALLOWED}, 111 { "blocksize", MTSETBSIZ, 0, NEED_2ARGS|ZERO_ALLOWED }, 112 { "density", MTSETDNSTY, 0, NEED_2ARGS|ZERO_ALLOWED|IS_DENSITY }, 113 { "eom", MTEOD, 1 }, 114 { "eod", MTEOD, 1 }, 115 { "smk", MTWSS, 0 }, 116 { "wss", MTWSS, 0 }, 117 { "fss", MTFSS, 1 }, 118 { "bss", MTBSS, 1 }, 119 { "comp", MTCOMP, 0, NEED_2ARGS|ZERO_ALLOWED|IS_COMP }, 120 { "retension", MTRETENS, 1 }, 121 { "rdhpos", MTIOCRDHPOS, 0 }, 122 { "rdspos", MTIOCRDSPOS, 0 }, 123 { "sethpos", MTIOCHLOCATE, 0, NEED_2ARGS|ZERO_ALLOWED }, 124 { "setspos", MTIOCSLOCATE, 0, NEED_2ARGS|ZERO_ALLOWED }, 125 { "errstat", MTIOCERRSTAT, 0 }, 126#endif /* defined(__FreeBSD__) */ 127 { NULL } 128}; 129 130void printreg __P((char *, u_int, char *)); 131void status __P((struct mtget *)); 132void usage __P((void)); 133#if defined (__FreeBSD__) 134void st_status (struct mtget *); 135int stringtodens (const char *s); 136const char *denstostring (int d); 137int denstobp(int d, int bpi); 138u_int32_t stringtocomp(const char *s); 139const char * comptostring(u_int32_t comp); 140void warn_eof __P((void)); 141#endif /* defined (__FreeBSD__) */ 142 143int 144main(argc, argv) 145 int argc; 146 char *argv[]; 147{ 148 register struct commands *comp; 149 struct mtget mt_status; 150 struct mtop mt_com; 151 int ch, len, mtfd; 152 char *p, *tape; 153 154 if ((tape = getenv("TAPE")) == NULL) 155 tape = DEFTAPE; 156 157 while ((ch = getopt(argc, argv, "f:t:")) != -1) 158 switch(ch) { 159 case 'f': 160 case 't': 161 tape = optarg; 162 break; 163 case '?': 164 default: 165 usage(); 166 } 167 argc -= optind; 168 argv += optind; 169 170 if (argc < 1 || argc > 2) 171 usage(); 172 173 len = strlen(p = *argv++); 174 for (comp = com;; comp++) { 175 if (comp->c_name == NULL) 176 errx(1, "%s: unknown command", p); 177 if (strncmp(p, comp->c_name, len) == 0) 178 break; 179 } 180#if defined(__FreeBSD__) 181 if((comp->c_flags & NEED_2ARGS) && argc != 2) 182 usage(); 183 if(comp->c_flags & DISABLE_THIS) { 184 warn_eof(); 185 } 186#endif /* defined(__FreeBSD__) */ 187 if ((mtfd = open(tape, comp->c_ronly ? O_RDONLY : O_RDWR)) < 0) 188 err(1, "%s", tape); 189 if (comp->c_code != MTNOP) { 190 mt_com.mt_op = comp->c_code; 191 if (*argv) { 192#if defined (__FreeBSD__) 193 if (!isdigit(**argv) && 194 (comp->c_flags & IS_DENSITY)) { 195 const char *dcanon; 196 mt_com.mt_count = stringtodens(*argv); 197 if (mt_com.mt_count == 0) 198 errx(1, "%s: unknown density", *argv); 199 dcanon = denstostring(mt_com.mt_count); 200 if (strcmp(dcanon, *argv) != 0) 201 printf( 202 "Using \"%s\" as an alias for %s\n", 203 *argv, dcanon); 204 p = ""; 205 } else if (!isdigit(**argv) && 206 (comp->c_flags & IS_COMP)) { 207 208 mt_com.mt_count = stringtocomp(*argv); 209 if ((u_int32_t)mt_com.mt_count == 0xf0f0f0f0) 210 errx(1, "%s: unknown compression", 211 *argv); 212 p = ""; 213 } else 214 /* allow for hex numbers; useful for density */ 215 mt_com.mt_count = strtol(*argv, &p, 0); 216#else 217 mt_com.mt_count = strtol(*argv, &p, 10); 218#endif /* defined(__FreeBSD__) */ 219 if ((mt_com.mt_count <= 220#if defined (__FreeBSD__) 221 ((comp->c_flags & ZERO_ALLOWED)? -1: 0) 222 && ((comp->c_flags & IS_COMP) == 0) 223#else 224 0 225#endif /* defined (__FreeBSD__) */ 226 ) || *p) 227 errx(1, "%s: illegal count", *argv); 228 } 229 else 230 mt_com.mt_count = 1; 231#if defined(__FreeBSD__) 232 switch (comp->c_code) { 233 case MTIOCERRSTAT: 234 { 235 int i; 236 union mterrstat umn; 237 struct scsi_tape_errors *s = &umn.scsi_errstat; 238 239 if (ioctl(mtfd, comp->c_code, (caddr_t)&umn) < 0) 240 err(2, "%s", tape); 241 (void)printf("Last I/O Residual: %u\n", s->io_resid); 242 (void)printf(" Last I/O Command:"); 243 for (i = 0; i < sizeof (s->io_cdb); i++) 244 (void)printf(" %02X", s->io_cdb[i]); 245 (void)printf("\n"); 246 (void)printf(" Last I/O Sense:\n\n\t"); 247 for (i = 0; i < sizeof (s->io_sense); i++) { 248 (void)printf(" %02X", s->io_sense[i]); 249 if (((i + 1) & 0xf) == 0) { 250 (void)printf("\n\t"); 251 } 252 } 253 (void)printf("\n"); 254 (void)printf("Last Control Residual: %u\n", 255 s->ctl_resid); 256 (void)printf(" Last Control Command:"); 257 for (i = 0; i < sizeof (s->ctl_cdb); i++) 258 (void)printf(" %02X", s->ctl_cdb[i]); 259 (void)printf("\n"); 260 (void)printf(" Last Control Sense:\n\n\t"); 261 for (i = 0; i < sizeof (s->ctl_sense); i++) { 262 (void)printf(" %02X", s->ctl_sense[i]); 263 if (((i + 1) & 0xf) == 0) { 264 (void)printf("\n\t"); 265 } 266 } 267 (void)printf("\n\n"); 268 exit(0); 269 /* NOTREACHED */ 270 } 271 case MTIOCRDHPOS: 272 case MTIOCRDSPOS: 273 { 274 u_int32_t block; 275 if (ioctl(mtfd, comp->c_code, (caddr_t)&block) < 0) 276 err(2, "%s", tape); 277 (void)printf("%s: %s block location %u\n", tape, 278 (comp->c_code == MTIOCRDHPOS)? "hardware" : 279 "logical", block); 280 exit(0); 281 /* NOTREACHED */ 282 } 283 case MTIOCSLOCATE: 284 case MTIOCHLOCATE: 285 { 286 u_int32_t block = (u_int32_t)mt_com.mt_count; 287 if (ioctl(mtfd, comp->c_code, (caddr_t)&block) < 0) 288 err(2, "%s", tape); 289 exit(0); 290 /* NOTREACHED */ 291 } 292 default: 293 break; 294 } 295#endif 296 if (ioctl(mtfd, MTIOCTOP, &mt_com) < 0) 297 err(1, "%s: %s", tape, comp->c_name); 298 } else { 299 if (ioctl(mtfd, MTIOCGET, &mt_status) < 0) 300 err(1, NULL); 301 status(&mt_status); 302 } 303 exit(0); 304 /* NOTREACHED */ 305} 306 307#ifdef vax 308#include <vax/mba/mtreg.h> 309#include <vax/mba/htreg.h> 310 311#include <vax/uba/utreg.h> 312#include <vax/uba/tmreg.h> 313#undef b_repcnt /* argh */ 314#include <vax/uba/tsreg.h> 315#endif 316 317#ifdef sun 318#include <sundev/tmreg.h> 319#include <sundev/arreg.h> 320#endif 321 322#ifdef tahoe 323#include <tahoe/vba/cyreg.h> 324#endif 325 326#if defined(__FreeBSD__) && defined(__i386__) 327#include <machine/wtio.h> 328#endif 329 330struct tape_desc { 331 short t_type; /* type of magtape device */ 332 char *t_name; /* printing name */ 333 char *t_dsbits; /* "drive status" register */ 334 char *t_erbits; /* "error" register */ 335} tapes[] = { 336#ifdef vax 337 { MT_ISTS, "ts11", 0, TSXS0_BITS }, 338 { MT_ISHT, "tm03", HTDS_BITS, HTER_BITS }, 339 { MT_ISTM, "tm11", 0, TMER_BITS }, 340 { MT_ISMT, "tu78", MTDS_BITS, 0 }, 341 { MT_ISUT, "tu45", UTDS_BITS, UTER_BITS }, 342#endif 343#ifdef sun 344 { MT_ISCPC, "TapeMaster", TMS_BITS, 0 }, 345 { MT_ISAR, "Archive", ARCH_CTRL_BITS, ARCH_BITS }, 346#endif 347#ifdef tahoe 348 { MT_ISCY, "cipher", CYS_BITS, CYCW_BITS }, 349#endif 350#if defined (__FreeBSD__) 351 /* 352 * XXX This is weird. The st driver reports the tape drive 353 * as 0x7 (MT_ISAR - Sun/Archive compatible); the wt driver 354 * either reports MT_ISVIPER1 for an Archive tape, or 0x11 355 * (MT_ISMFOUR) for other tapes. 356 * XXX for the wt driver, rely on it behaving like a "standard" 357 * magtape driver. 358 */ 359 { MT_ISAR, "SCSI tape drive", 0, 0 }, 360#if defined (__i386__) 361 { MT_ISVIPER1, "Archive Viper", WTDS_BITS, WTER_BITS }, 362 { MT_ISMFOUR, "Wangtek", WTDS_BITS, WTER_BITS }, 363#endif 364#endif /* defined (__FreeBSD__) */ 365 { 0 } 366}; 367 368/* 369 * Interpret the status buffer returned 370 */ 371void 372status(bp) 373 register struct mtget *bp; 374{ 375 register struct tape_desc *mt; 376 377 for (mt = tapes;; mt++) { 378 if (mt->t_type == 0) { 379 (void)printf("%d: unknown tape drive type\n", 380 bp->mt_type); 381 return; 382 } 383 if (mt->t_type == bp->mt_type) 384 break; 385 } 386#if defined (__FreeBSD__) 387 if(mt->t_type == MT_ISAR) 388 st_status(bp); 389 else { 390#endif /* defined (__FreeBSD__) */ 391 (void)printf("%s tape drive, residual=%d\n", mt->t_name, bp->mt_resid); 392 printreg("ds", (unsigned short)bp->mt_dsreg, mt->t_dsbits); 393 printreg("\ner", (unsigned short)bp->mt_erreg, mt->t_erbits); 394 (void)putchar('\n'); 395#if defined (__FreeBSD__) 396 } 397#endif /* defined (__FreeBSD__) */ 398} 399 400/* 401 * Print a register a la the %b format of the kernel's printf. 402 */ 403void 404printreg(s, v, bits) 405 char *s; 406 register u_int v; 407 register char *bits; 408{ 409 register int i, any = 0; 410 register char c; 411 412 if (bits && *bits == 8) 413 printf("%s=%o", s, v); 414 else 415 printf("%s=%x", s, v); 416 if (!bits) 417 return; 418 bits++; 419 if (v && bits) { 420 putchar('<'); 421 while ((i = *bits++)) { 422 if (v & (1 << (i-1))) { 423 if (any) 424 putchar(','); 425 any = 1; 426 for (; (c = *bits) > 32; bits++) 427 putchar(c); 428 } else 429 for (; *bits > 32; bits++) 430 ; 431 } 432 putchar('>'); 433 } 434} 435 436void 437usage() 438{ 439 (void)fprintf(stderr, "usage: mt [-f device] command [ count ]\n"); 440 exit(1); 441} 442 443#if defined (__FreeBSD__) 444 445struct densities { 446 int dens; 447 int bpmm; 448 int bpi; 449 const char *name; 450} dens[] = { 451 /* 452 * Taken from T10 Project 997D 453 * SCSI-3 Stream Device Commands (SSC) 454 * Revision 11, 4-Nov-97 455 */ 456 /*Num. bpmm bpi Reference */ 457 { 0x1, 32, 800, "X3.22-1983" }, 458 { 0x2, 63, 1600, "X3.39-1986" }, 459 { 0x3, 246, 6250, "X3.54-1986" }, 460 { 0x5, 315, 8000, "X3.136-1986" }, 461 { 0x6, 126, 3200, "X3.157-1987" }, 462 { 0x7, 252, 6400, "X3.116-1986" }, 463 { 0x8, 315, 8000, "X3.158-1987" }, 464 { 0x9, 491, 37871, "X3.180" }, 465 { 0xA, 262, 6667, "X3B5/86-199" }, 466 { 0xB, 63, 1600, "X3.56-1986" }, 467 { 0xC, 500, 12690, "HI-TC1" }, 468 { 0xD, 999, 25380, "HI-TC2" }, 469 { 0xF, 394, 10000, "QIC-120" }, 470 { 0x10, 394, 10000, "QIC-150" }, 471 { 0x11, 630, 16000, "QIC-320" }, 472 { 0x12, 2034, 51667, "QIC-1350" }, 473 { 0x13, 2400, 61000, "X3B5/88-185A" }, 474 { 0x14, 1703, 43245, "X3.202-1991" }, 475 { 0x15, 1789, 45434, "ECMA TC17" }, 476 { 0x16, 394, 10000, "X3.193-1990" }, 477 { 0x17, 1673, 42500, "X3B5/91-174" }, 478 { 0x18, 1673, 42500, "X3B5/92-50" }, 479 { 0x1C, 1654, 42000, "QIC-385M" }, 480 { 0x1D, 1512, 38400, "QIC-410M" }, 481 { 0x1E, 1385, 36000, "QIC-1000C" }, 482 { 0x1F, 2666, 67733, "QIC-2100C" }, 483 { 0x20, 2666, 67733, "QIC-6GB(M)" }, 484 { 0x21, 2666, 67733, "QIC-20GB(C)" }, 485 { 0x22, 1600, 40640, "QIC-2GB(C)" }, 486 { 0x23, 2666, 67733, "QIC-875M" }, 487 { 0x24, 2400, 61000, "DDS-2" }, 488 { 0x25, 3816, 97000, "DDS-3" }, 489 { 0x26, 3816, 97000, "DDS-4" }, 490 { 0x27, 3056, 77611, "Mammoth" }, 491 { 0x28, 1491, 37871, "X3.224" }, 492 { 0, 0, 0, NULL } 493}; 494 495struct compression_types { 496 u_int32_t comp_number; 497 const char *name; 498} comp_types[] = { 499 { 0x00, "none" }, 500 { 0x00, "off" }, 501 { 0x10, "IDRC" }, 502 { 0x20, "DCLZ" }, 503 { 0xffffffff, "enable" }, 504 { 0xffffffff, "on" }, 505 { 0xf0f0f0f0, NULL} 506}; 507 508const char * 509denstostring(int d) 510{ 511 static char buf[20]; 512 struct densities *sd; 513 514 /* densities 0 and 0x7f are handled as special cases */ 515 if (d == 0) 516 return "default"; 517 if (d == 0x7f) 518 return "same"; 519 for (sd = dens; sd->dens; sd++) 520 if (sd->dens == d) 521 break; 522 if (sd->dens == 0) 523 sprintf(buf, "0x%02x", d); 524 else 525 sprintf(buf, "0x%02x:%s", d, sd->name); 526 return buf; 527} 528 529/* 530 * Given a specific density number, return either the bits per inch or bits 531 * per millimeter for the given density. 532 */ 533int 534denstobp(int d, int bpi) 535{ 536 struct densities *sd; 537 538 for (sd = dens; sd->dens; sd++) 539 if (sd->dens == d) 540 break; 541 if (sd->dens == 0) 542 return(0); 543 else { 544 if (bpi) 545 return(sd->bpi); 546 else 547 return(sd->bpmm); 548 } 549} 550 551int 552stringtodens(const char *s) 553{ 554 struct densities *sd; 555 size_t l = strlen(s); 556 557 for (sd = dens; sd->dens; sd++) 558 if (strncasecmp(sd->name, s, l) == 0) 559 break; 560 return sd->dens; 561} 562 563 564const char * 565getblksiz(int bs) 566{ 567 static char buf[25]; 568 if (bs == 0) 569 return "variable"; 570 else { 571 sprintf(buf, "%d bytes", bs); 572 return buf; 573 } 574} 575 576const char * 577comptostring(u_int32_t comp) 578{ 579 static char buf[20]; 580 struct compression_types *ct; 581 582 if (comp == MT_COMP_DISABLED) 583 return "disabled"; 584 else if (comp == MT_COMP_UNSUPP) 585 return "unsupported"; 586 587 for (ct = comp_types; ct->name; ct++) 588 if (ct->comp_number == comp) 589 break; 590 591 if (ct->comp_number == 0xf0f0f0f0) { 592 sprintf(buf, "0x%x", comp); 593 return(buf); 594 } else 595 return(ct->name); 596} 597 598u_int32_t 599stringtocomp(const char *s) 600{ 601 struct compression_types *ct; 602 size_t l = strlen(s); 603 604 for (ct = comp_types; ct->name; ct++) 605 if (strncasecmp(ct->name, s, l) == 0) 606 break; 607 608 return(ct->comp_number); 609} 610 611void 612st_status(struct mtget *bp) 613{ 614 printf("Mode Density Blocksize bpi " 615 "Compression\n" 616 "Current: %-12s %-12s %-7d %s\n" 617 "---------available modes---------\n" 618 "0: %-12s %-12s %-7d %s\n" 619 "1: %-12s %-12s %-7d %s\n" 620 "2: %-12s %-12s %-7d %s\n" 621 "3: %-12s %-12s %-7d %s\n", 622 denstostring(bp->mt_density), getblksiz(bp->mt_blksiz), 623 denstobp(bp->mt_density, TRUE), comptostring(bp->mt_comp), 624 denstostring(bp->mt_density0), getblksiz(bp->mt_blksiz0), 625 denstobp(bp->mt_density0, TRUE), comptostring(bp->mt_comp0), 626 denstostring(bp->mt_density1), getblksiz(bp->mt_blksiz1), 627 denstobp(bp->mt_density1, TRUE), comptostring(bp->mt_comp1), 628 denstostring(bp->mt_density2), getblksiz(bp->mt_blksiz2), 629 denstobp(bp->mt_density2, TRUE), comptostring(bp->mt_comp2), 630 denstostring(bp->mt_density3), getblksiz(bp->mt_blksiz3), 631 denstobp(bp->mt_density3, TRUE), comptostring(bp->mt_comp3)); 632 633 if (bp->mt_dsreg != MTIO_DSREG_NIL) { 634 auto char foo[32]; 635 const char *sfmt = "Current Driver State: %s.\n"; 636 printf("---------------------------------\n"); 637 switch (bp->mt_dsreg) { 638 case MTIO_DSREG_REST: 639 printf(sfmt, "at rest"); 640 break; 641 case MTIO_DSREG_RBSY: 642 printf(sfmt, "Communicating with drive"); 643 break; 644 case MTIO_DSREG_WR: 645 printf(sfmt, "Writing"); 646 break; 647 case MTIO_DSREG_FMK: 648 printf(sfmt, "Writing Filemarks"); 649 break; 650 case MTIO_DSREG_ZER: 651 printf(sfmt, "Erasing"); 652 break; 653 case MTIO_DSREG_RD: 654 printf(sfmt, "Reading"); 655 break; 656 case MTIO_DSREG_FWD: 657 printf(sfmt, "Spacing Forward"); 658 break; 659 case MTIO_DSREG_REV: 660 printf(sfmt, "Spacing Reverse"); 661 break; 662 case MTIO_DSREG_POS: 663 printf(sfmt, 664 "Hardware Positioning (direction unknown)"); 665 break; 666 case MTIO_DSREG_REW: 667 printf(sfmt, "Rewinding"); 668 break; 669 case MTIO_DSREG_TEN: 670 printf(sfmt, "Retensioning"); 671 break; 672 case MTIO_DSREG_UNL: 673 printf(sfmt, "Unloading"); 674 break; 675 case MTIO_DSREG_LD: 676 printf(sfmt, "Loading"); 677 break; 678 default: 679 (void) sprintf(foo, "Unknown state 0x%x", bp->mt_dsreg); 680 printf(sfmt, foo); 681 break; 682 } 683 } 684 if (bp->mt_fileno == (daddr_t) -1 || bp->mt_blkno == (daddr_t) -1) 685 return; 686 printf("---------------------------------\n"); 687 printf("File Number: %ld\tRecord Number: %ld\n", bp->mt_fileno, 688 bp->mt_blkno); 689} 690 691void 692warn_eof(void) 693{ 694 fprintf(stderr, 695 "The \"eof\" command has been disabled.\n" 696 "Use \"weof\" if you really want to write end-of-file marks,\n" 697 "or \"eom\" if you rather want to skip to the end of " 698 "recorded medium.\n"); 699 exit(1); 700} 701 702#endif /* defined (__FreeBSD__) */ 703