[BusyBox] Problem with 'mt' ?
Matt Kraai
kraai at alumni.carnegiemellon.edu
Mon May 21 08:27:01 UTC 2001
On Mon, May 21, 2001 at 01:37:54PM +0000, Tom Oehser wrote:
> There is something wrong with 'mt' which causes it to give incorrect
> 'permission denied' errors, which do not happen with the gnu or bsd
> versions of the command...
Could you please test the following patch and let me know if it
fixes your problem? If so, I'll commit it.
Matt
Index: mt.c
===================================================================
RCS file: /var/cvs/busybox/mt.c,v
retrieving revision 1.20
diff -u -r1.20 mt.c
--- mt.c 2001/03/09 14:36:42 1.20
+++ mt.c 2001/05/21 14:26:02
@@ -55,7 +55,7 @@
const char *file = "/dev/tape";
const struct mt_opcodes *code = opcodes;
struct mtop op;
- int fd;
+ int fd, mode;
if (argc < 2) {
show_usage();
@@ -87,7 +87,20 @@
else
op.mt_count = 1; /* One, not zero, right? */
- if ((fd = open(file, O_RDONLY, 0)) < 0)
+ switch (code->value) {
+ case MTWEOF:
+ case MTERASE:
+ case MTWSM:
+ case MTSETDRVBUFFER:
+ mode = O_WRONLY;
+ break;
+
+ default:
+ mode = O_RDONLY;
+ break;
+ }
+
+ if ((fd = open(file, mode, 0)) < 0)
perror_msg_and_die("%s", file);
if (ioctl(fd, MTIOCTOP, &op) != 0)
More information about the busybox
mailing list