Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/miscutils/mt.c
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/miscutils/mt.c
r821 r1770 1 1 /* vi: set sw=4 ts=4: */ 2 #include "busybox.h" 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <string.h> 2 /* 3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 4 */ 5 6 #include "libbb.h" 6 7 #include <sys/mtio.h> 7 #include <fcntl.h>8 8 9 9 struct mt_opcodes { 10 c har *name;10 const char *name; 11 11 short value; 12 12 }; … … 51 51 }; 52 52 53 int mt_main(int argc, char **argv); 53 54 int mt_main(int argc, char **argv) 54 55 { … … 79 80 80 81 if (code->name == 0) { 81 bb_error_msg("unrecognized opcode %s .", argv[1]);82 bb_error_msg("unrecognized opcode %s", argv[1]); 82 83 return EXIT_FAILURE; 83 84 } … … 85 86 op.mt_op = code->value; 86 87 if (argc >= 3) 87 op.mt_count = atoi(argv[2]);88 op.mt_count = xatoi_u(argv[2]); 88 89 else 89 90 op.mt_count = 1; /* One, not zero, right? */ … … 102 103 } 103 104 104 fd = bb_xopen3(file, mode, 0);105 fd = xopen(file, mode); 105 106 106 107 switch (code->value) { 107 108 case MTTELL: 108 if (ioctl(fd, MTIOCPOS, &position) < 0) 109 bb_perror_msg_and_die("%s", file); 110 printf ("At block %d.\n", (int) position.mt_blkno); 109 ioctl_or_perror_and_die(fd, MTIOCPOS, &position, "%s", file); 110 printf("At block %d.\n", (int) position.mt_blkno); 111 111 break; 112 112 113 113 default: 114 if (ioctl(fd, MTIOCTOP, &op) != 0) 115 bb_perror_msg_and_die("%s", file); 114 ioctl_or_perror_and_die(fd, MTIOCTOP, &op, "%s", file); 116 115 break; 117 116 }
Note:
See TracChangeset
for help on using the changeset viewer.