Commit | Line | Data |
---|---|---|
04b7d55b AM |
1 | /* |
2 | * Copyright (c) 1993 Steve Gerakines | |
3 | * | |
4 | * This is freely redistributable software. You may do anything you | |
5 | * wish with it, so long as the above notice stays intact. | |
6 | * | |
7 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS | |
8 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
9 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
10 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, | |
11 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
12 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
13 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
14 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
15 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
16 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
17 | * POSSIBILITY OF SUCH DAMAGE. | |
18 | * | |
19 | * ftinfo.c - display tape drive status | |
20 | * 10/30/93 v0.3 | |
21 | * Initial revision. | |
22 | * | |
23 | * usage: ftinfo [ -f tape ] | |
24 | */ | |
25 | #include <stdio.h> | |
26 | #include <sys/ftape.h> | |
27 | ||
28 | #define DEFQIC "/dev/rft0" | |
29 | #define equal(s1,s2) (strcmp(s1, s2) == 0) | |
30 | QIC_HWInfo hw; | |
31 | QIC_Geom g; | |
32 | ||
33 | main(int argc, char *argv[]) | |
34 | { | |
35 | int ft; | |
36 | int gotgeom; | |
37 | int s; | |
38 | char *tape, *getenv(); | |
39 | ||
40 | if (argc > 2 && (equal(argv[1], "-t") || equal(argv[1], "-f"))) { | |
41 | argc -= 2; | |
42 | tape = argv[2]; | |
43 | argv += 2; | |
44 | } else | |
45 | if ((tape = getenv("TAPE")) == NULL) | |
46 | tape = DEFQIC; | |
47 | if (argc > 1) { | |
48 | fprintf(stderr, "usage: ftinfo [ -f tape ]\n"); | |
49 | exit(1); | |
50 | } | |
51 | ||
52 | if ((ft = open(tape, 2)) < 0) { | |
53 | fprintf(stderr, "ftinfo: couldn't open tape device %s\n", tape); | |
54 | exit(2); | |
55 | } | |
56 | ||
57 | if (ioctl(ft, QIOSTATUS, &s) < 0) { | |
58 | fprintf(stderr, "ftinfo: couldn't get tape drive status\n"); | |
59 | exit(2); | |
60 | } | |
61 | ||
62 | if ((s & QS_CART) && (s & QS_FMTOK)) { | |
63 | if (ioctl(ft, QIOGEOM, &g) < 0) | |
64 | fprintf(stderr, "ftinfo: warning: get tape geometry failed\n"); | |
65 | } | |
66 | ||
67 | if (ioctl(ft, QIOHWINFO, &hw) < 0) | |
68 | fprintf(stderr, "ftinfo: warning: get hardware info failed\n"); | |
69 | ||
70 | close(ft); | |
71 | ||
72 | printf("drive status: %s\n", (s & QS_READY) ? "Ready" : "Not Ready"); | |
73 | if (s & QS_CART) { | |
74 | if (s & QS_FMTOK) { | |
75 | printf("tape type: %s %s\n", | |
76 | g.g_fmtdesc, (s & QS_RDONLY) ? "(Write-Protect)" : ""); | |
77 | printf("tape length: %s\n", g.g_lendesc); | |
78 | } else | |
79 | printf("tape type: Unformatted %s\n", | |
80 | (s & QS_RDONLY) ? "(Write-Protect)" : ""); | |
81 | } else | |
82 | printf("tape type: No tape in drive\n"); | |
83 | printf("drive make: 0x%04x\n", hw.hw_make); | |
84 | printf("drive model: 0x%02x\n", hw.hw_model); | |
85 | printf("drive rom-id: 0x%02x\n", hw.hw_romid); | |
86 | printf("beta roms: %s\n", hw.hw_rombeta ? "Yes" : "No"); | |
87 | ||
88 | exit(0); | |
89 | } |