diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-02-08 19:58:47 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-02-08 19:58:47 +0000 |
commit | e49d5ecbbe51718fa925b6890a735e5937cc2aa2 (patch) | |
tree | c90bda10731ad9333ce3b404f993354c9fc104b8 /miscutils/mt.c | |
parent | c0bf817bbc5c7867fbe8fb76d5c39f8ee802692f (diff) | |
download | busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.gz busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.tar.bz2 busybox-w32-e49d5ecbbe51718fa925b6890a735e5937cc2aa2.zip |
Some formatting updates (ran the code through indent)
-Erik
Diffstat (limited to 'miscutils/mt.c')
-rw-r--r-- | miscutils/mt.c | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/miscutils/mt.c b/miscutils/mt.c index 7168ef7ac..9791b64b2 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c | |||
@@ -1,97 +1,97 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | #include "internal.h" | 2 | #include "internal.h" |
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <sys/mtio.h> | 4 | #include <sys/mtio.h> |
4 | #include <sys/fcntl.h> | 5 | #include <sys/fcntl.h> |
5 | 6 | ||
6 | static const char mt_usage[] = "mt [-f device] opcode value\n"; | 7 | static const char mt_usage[] = "mt [-f device] opcode value\n"; |
7 | 8 | ||
8 | struct mt_opcodes { | 9 | struct mt_opcodes { |
9 | char * name; | 10 | char *name; |
10 | short value; | 11 | short value; |
11 | }; | 12 | }; |
12 | 13 | ||
13 | /* missing: eod/seod, stoptions, stwrthreshold, densities */ | 14 | /* missing: eod/seod, stoptions, stwrthreshold, densities */ |
14 | static const struct mt_opcodes opcodes[] = { | 15 | static const struct mt_opcodes opcodes[] = { |
15 | { "bsf", MTBSF }, | 16 | {"bsf", MTBSF}, |
16 | { "bsfm", MTBSFM }, | 17 | {"bsfm", MTBSFM}, |
17 | { "bsr", MTBSR }, | 18 | {"bsr", MTBSR}, |
18 | { "bss", MTBSS }, | 19 | {"bss", MTBSS}, |
19 | { "datacompression", MTCOMPRESSION }, | 20 | {"datacompression", MTCOMPRESSION}, |
20 | { "eom", MTEOM }, | 21 | {"eom", MTEOM}, |
21 | { "erase", MTERASE }, | 22 | {"erase", MTERASE}, |
22 | { "fsf", MTFSF }, | 23 | {"fsf", MTFSF}, |
23 | { "fsfm", MTFSFM }, | 24 | {"fsfm", MTFSFM}, |
24 | { "fsr", MTFSR }, | 25 | {"fsr", MTFSR}, |
25 | { "fss", MTFSS }, | 26 | {"fss", MTFSS}, |
26 | { "load", MTLOAD }, | 27 | {"load", MTLOAD}, |
27 | { "lock", MTLOCK }, | 28 | {"lock", MTLOCK}, |
28 | { "mkpart", MTMKPART }, | 29 | {"mkpart", MTMKPART}, |
29 | { "nop", MTNOP }, | 30 | {"nop", MTNOP}, |
30 | { "offline",MTOFFL }, | 31 | {"offline", MTOFFL}, |
31 | { "rewoffline",MTOFFL }, | 32 | {"rewoffline", MTOFFL}, |
32 | { "ras1", MTRAS1 }, | 33 | {"ras1", MTRAS1}, |
33 | { "ras2", MTRAS2 }, | 34 | {"ras2", MTRAS2}, |
34 | { "ras3", MTRAS3 }, | 35 | {"ras3", MTRAS3}, |
35 | { "reset", MTRESET }, | 36 | {"reset", MTRESET}, |
36 | { "retension", MTRETEN }, | 37 | {"retension", MTRETEN}, |
37 | { "rew", MTREW }, | 38 | {"rew", MTREW}, |
38 | { "seek", MTSEEK }, | 39 | {"seek", MTSEEK}, |
39 | { "setblk", MTSETBLK }, | 40 | {"setblk", MTSETBLK}, |
40 | { "setdensity", MTSETDENSITY }, | 41 | {"setdensity", MTSETDENSITY}, |
41 | { "drvbuffer", MTSETDRVBUFFER }, | 42 | {"drvbuffer", MTSETDRVBUFFER}, |
42 | { "setpart", MTSETPART }, | 43 | {"setpart", MTSETPART}, |
43 | { "tell", MTTELL }, | 44 | {"tell", MTTELL}, |
44 | { "wset", MTWSM }, | 45 | {"wset", MTWSM}, |
45 | { "unload", MTUNLOAD }, | 46 | {"unload", MTUNLOAD}, |
46 | { "unlock", MTUNLOCK }, | 47 | {"unlock", MTUNLOCK}, |
47 | { "eof", MTWEOF }, | 48 | {"eof", MTWEOF}, |
48 | { "weof", MTWEOF }, | 49 | {"weof", MTWEOF}, |
49 | { 0, 0 } | 50 | {0, 0} |
50 | }; | 51 | }; |
51 | 52 | ||
52 | extern int | 53 | extern int mt_main(int argc, char **argv) |
53 | mt_main(int argc, char** argv) | ||
54 | { | 54 | { |
55 | const char * file = "/dev/tape"; | 55 | const char *file = "/dev/tape"; |
56 | const struct mt_opcodes * code = opcodes; | 56 | const struct mt_opcodes *code = opcodes; |
57 | struct mtop op; | 57 | struct mtop op; |
58 | int fd; | 58 | int fd; |
59 | 59 | ||
60 | if ( strcmp(argv[1], "-f") == 0 ) { | 60 | if (strcmp(argv[1], "-f") == 0) { |
61 | if ( argc < 4 ) { | 61 | if (argc < 4) { |
62 | usage (mt_usage); | 62 | usage(mt_usage); |
63 | } | 63 | } |
64 | file = argv[2]; | 64 | file = argv[2]; |
65 | argv += 2; | 65 | argv += 2; |
66 | argc -= 2; | 66 | argc -= 2; |
67 | } | 67 | } |
68 | 68 | ||
69 | while ( code->name != 0 ) { | 69 | while (code->name != 0) { |
70 | if ( strcmp(code->name, argv[1]) == 0 ) | 70 | if (strcmp(code->name, argv[1]) == 0) |
71 | break; | 71 | break; |
72 | code++; | 72 | code++; |
73 | } | 73 | } |
74 | 74 | ||
75 | if ( code->name == 0 ) { | 75 | if (code->name == 0) { |
76 | fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); | 76 | fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); |
77 | return( FALSE); | 77 | return (FALSE); |
78 | } | 78 | } |
79 | 79 | ||
80 | op.mt_op = code->value; | 80 | op.mt_op = code->value; |
81 | if ( argc >= 3 ) | 81 | if (argc >= 3) |
82 | op.mt_count = atoi(argv[2]); | 82 | op.mt_count = atoi(argv[2]); |
83 | else | 83 | else |
84 | op.mt_count = 1; /* One, not zero, right? */ | 84 | op.mt_count = 1; /* One, not zero, right? */ |
85 | 85 | ||
86 | if ( (fd = open(file, O_RDONLY, 0)) < 0 ) { | 86 | if ((fd = open(file, O_RDONLY, 0)) < 0) { |
87 | perror(file); | 87 | perror(file); |
88 | return( FALSE); | 88 | return (FALSE); |
89 | } | 89 | } |
90 | 90 | ||
91 | if ( ioctl(fd, MTIOCTOP, &op) != 0 ) { | 91 | if (ioctl(fd, MTIOCTOP, &op) != 0) { |
92 | perror(file); | 92 | perror(file); |
93 | return( FALSE); | 93 | return (FALSE); |
94 | } | 94 | } |
95 | 95 | ||
96 | return( TRUE); | 96 | return (TRUE); |
97 | } | 97 | } |