diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/makedevs.c | 19 | ||||
-rw-r--r-- | miscutils/mt.c | 15 |
2 files changed, 25 insertions, 9 deletions
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c index 5948bacc8..c8206e020 100644 --- a/miscutils/makedevs.c +++ b/miscutils/makedevs.c | |||
@@ -17,10 +17,18 @@ | |||
17 | #include <sys/stat.h> | 17 | #include <sys/stat.h> |
18 | 18 | ||
19 | static const char makedevs_usage[] = | 19 | static const char makedevs_usage[] = |
20 | "makedevs 0.01 -- Create an entire range of device files\n\n" | 20 | "makedevs NAME TYPE MAJOR MINOR FIRST LAST [s]\n\n" |
21 | "\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n" | 21 | "Creates a range of block or character special files\n\n" |
22 | 22 | "TYPEs include:\n" | |
23 | "\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n"; | 23 | "\tb:\tMake a block (buffered) device.\n" |
24 | "\tc or u:\tMake a character (un-buffered) device.\n" | ||
25 | "\tp:\tMake a named pipe. MAJOR and MINOR are ignored for named pipes.\n\n" | ||
26 | "FIRST specifies the number appended to NAME to create the first device.\n" | ||
27 | "LAST specifies the number of the last item that should be created.\n" | ||
28 | "If 's' is the last argument, the base device is created as well.\n\n" | ||
29 | "For example:\n" | ||
30 | "\tmakedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63\n" | ||
31 | "\tmakedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8\n"; | ||
24 | 32 | ||
25 | int makedevs_main(int argc, char **argv) | 33 | int makedevs_main(int argc, char **argv) |
26 | { | 34 | { |
@@ -38,6 +46,9 @@ int makedevs_main(int argc, char **argv) | |||
38 | char devname[255]; | 46 | char devname[255]; |
39 | char buf[255]; | 47 | char buf[255]; |
40 | 48 | ||
49 | if (argc < 7 || *argv[1]=='-') | ||
50 | usage(makedevs_usage); | ||
51 | |||
41 | switch (type[0]) { | 52 | switch (type[0]) { |
42 | case 'c': | 53 | case 'c': |
43 | mode = S_IFCHR; | 54 | mode = S_IFCHR; |
diff --git a/miscutils/mt.c b/miscutils/mt.c index 9791b64b2..cf20d1711 100644 --- a/miscutils/mt.c +++ b/miscutils/mt.c | |||
@@ -4,7 +4,8 @@ | |||
4 | #include <sys/mtio.h> | 4 | #include <sys/mtio.h> |
5 | #include <sys/fcntl.h> | 5 | #include <sys/fcntl.h> |
6 | 6 | ||
7 | static const char mt_usage[] = "mt [-f device] opcode value\n"; | 7 | static const char mt_usage[] = "mt [-f device] opcode value\n\n" |
8 | "Control magnetic tape drive operation\n"; | ||
8 | 9 | ||
9 | struct mt_opcodes { | 10 | struct mt_opcodes { |
10 | char *name; | 11 | char *name; |
@@ -56,6 +57,10 @@ extern int mt_main(int argc, char **argv) | |||
56 | const struct mt_opcodes *code = opcodes; | 57 | const struct mt_opcodes *code = opcodes; |
57 | struct mtop op; | 58 | struct mtop op; |
58 | int fd; | 59 | int fd; |
60 | |||
61 | if ((argc != 2 && argc != 3) || **(argv + 1) == '-') { | ||
62 | usage(mt_usage); | ||
63 | } | ||
59 | 64 | ||
60 | if (strcmp(argv[1], "-f") == 0) { | 65 | if (strcmp(argv[1], "-f") == 0) { |
61 | if (argc < 4) { | 66 | if (argc < 4) { |
@@ -74,7 +79,7 @@ extern int mt_main(int argc, char **argv) | |||
74 | 79 | ||
75 | if (code->name == 0) { | 80 | if (code->name == 0) { |
76 | fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); | 81 | fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]); |
77 | return (FALSE); | 82 | exit (FALSE); |
78 | } | 83 | } |
79 | 84 | ||
80 | op.mt_op = code->value; | 85 | op.mt_op = code->value; |
@@ -85,13 +90,13 @@ extern int mt_main(int argc, char **argv) | |||
85 | 90 | ||
86 | if ((fd = open(file, O_RDONLY, 0)) < 0) { | 91 | if ((fd = open(file, O_RDONLY, 0)) < 0) { |
87 | perror(file); | 92 | perror(file); |
88 | return (FALSE); | 93 | exit (FALSE); |
89 | } | 94 | } |
90 | 95 | ||
91 | if (ioctl(fd, MTIOCTOP, &op) != 0) { | 96 | if (ioctl(fd, MTIOCTOP, &op) != 0) { |
92 | perror(file); | 97 | perror(file); |
93 | return (FALSE); | 98 | exit (FALSE); |
94 | } | 99 | } |
95 | 100 | ||
96 | return (TRUE); | 101 | exit (TRUE); |
97 | } | 102 | } |