write feature. Add additional check for media type before blanking.
The patch fixes problem for Giovanni.
ok fgsch
-/* $OpenBSD: cdio.c,v 1.65 2008/08/08 07:26:40 fgsch Exp $ */
+/* $OpenBSD: cdio.c,v 1.66 2008/08/13 12:21:19 av Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
warnx("Can't determine media type");
return (0);
}
- if ((mediacap & MEDIACAP_CDRW_WRITE) == 0) {
+ if ((mediacap & MEDIACAP_CDRW_WRITE) == 0 &&
+ get_media_type() != MEDIATYPE_CDRW) {
warnx("The media doesn't support blanking");
return (0);
}
-/* $OpenBSD: extern.h,v 1.12 2008/06/30 23:35:39 av Exp $ */
+/* $OpenBSD: extern.h,v 1.13 2008/08/13 12:21:19 av Exp $ */
/*
* Copyright (c) 2002 Marc Espie.
*
*/
#define CD_MAX_SPEED 380
+/*
+ * Media types
+ */
+#define MEDIATYPE_UNKNOWN 0
+#define MEDIATYPE_CDR 1
+#define MEDIATYPE_CDRW 2
+
extern unsigned long entry2time(struct cd_toc_entry *);
extern unsigned long entry2frames(struct cd_toc_entry *);
extern int open_cd(char *, int);
extern char ** cddb(const char *, int, struct cd_toc_entry *, char *);
extern unsigned long cddb_discid(int, struct cd_toc_entry *);
extern void free_names(char **);
+extern int get_media_type(void);
extern int get_media_capabilities(int *cap);
extern int blank(void);
extern int unit_ready(void);
-/* $OpenBSD: mmc.c,v 1.24 2008/08/08 07:26:40 fgsch Exp $ */
+/* $OpenBSD: mmc.c,v 1.25 2008/08/13 12:21:19 av Exp $ */
/*
* Copyright (c) 2006 Michael Coulter <mjc@openbsd.org>
*
#define MMC_FEATURE_CD_TAO 0x2d
#define MMC_FEATURE_CDRW_WRITE 0x37
+int
+get_media_type(void)
+{
+ scsireq_t scr;
+ char buf[32];
+ u_char disctype;
+ int rv, error;
+
+ rv = MEDIATYPE_UNKNOWN;
+ memset(buf, 0, sizeof(buf));
+ memset(&scr, 0, sizeof(scr));
+
+ scr.cmd[0] = READ_TOC;
+ scr.cmd[1] = 0x2; /* MSF */
+ scr.cmd[2] = 0x4; /* ATIP */
+ scr.cmd[8] = 0x20;
+
+ scr.flags = SCCMD_ESCAPE | SCCMD_READ;
+ scr.databuf = buf;
+ scr.datalen = sizeof(buf);
+ scr.cmdlen = 10;
+ scr.timeout = 120000;
+ scr.senselen = SENSEBUFLEN;
+
+ error = ioctl(fd, SCIOCCOMMAND, &scr);
+ if (error != -1 && scr.retsts == 0 && scr.datalen_used > 7) {
+ disctype = (buf[6] >> 6) & 0x1;
+ if (disctype == 0)
+ rv = MEDIATYPE_CDR;
+ else if (disctype == 1)
+ rv = MEDIATYPE_CDRW;
+ }
+
+ return (rv);
+}
+
int
get_media_capabilities(int *cap)
{