summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Coulter <mjc@cvs.openbsd.org>2006-05-31 03:12:29 +0000
committerMichael Coulter <mjc@cvs.openbsd.org>2006-05-31 03:12:29 +0000
commit90ba8e48de95ab37476b630585a7166c10c691d9 (patch)
tree30c4e026e1d6b0c85c8ebfd37682e2994cd4d96b
parent05f31df8987fd2c50c38ef52709c52fa4439bf54 (diff)
when blanking, if fd is already open read-only, re-open read/write
-rw-r--r--usr.bin/cdio/mmc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.bin/cdio/mmc.c b/usr.bin/cdio/mmc.c
index a582a2493ac..e30b8c260dc 100644
--- a/usr.bin/cdio/mmc.c
+++ b/usr.bin/cdio/mmc.c
@@ -3,6 +3,7 @@
#include <sys/stat.h>
#include <sys/scsiio.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
@@ -10,7 +11,9 @@
#include "extern.h"
#define WAVHDRLEN 44
+extern int errno;
extern int fd;
+extern char *cdname;
extern char *track_types;
int
@@ -29,6 +32,13 @@ blank(void)
scr.senselen = SENSEBUFLEN;
r = ioctl(fd, SCIOCCOMMAND, &scr);
+ if (r == -1 && errno == EPERM) {
+ close(fd);
+ fd = -1;
+ if (! open_cd(cdname, 1))
+ return (-1);
+ }
+ r = ioctl(fd, SCIOCCOMMAND, &scr);
return (r == 0 ? scr.retsts : -1);
}