Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Sep 1995 22:09:41 +0400 (MSD)
From:      "Serge V.Vakulenko" <vak@crox.net.kiae.su>
To:        current@freebsd.org
Subject:   [patch] wcd.c version 1.6
Message-ID:  <Pine.BSF.3.91.950922220641.274A-100000@crox.net.kiae.su>

next in thread | raw e-mail | index | archive | help

Some ATAPI CD-ROM drives don't support READ_CAPACITY
and READ_TOC commands.  Fortunately, these commands are not
necessary for data i/o.  This patch makes such drives happy.

Serge

--- wcd15.c	Fri Sep 22 00:06:44 1995
+++ wcd.c	Fri Sep 22 21:40:28 1995
@@ -12,7 +12,7 @@
  * or modify this software as long as this message is kept with the software,
  * all derivative works or modified versions.
  *
- * Version 1.5, Thu Sep 21 23:08:11 MSD 1995
+ * Version 1.6, Fri Sep 22 21:40:12 MSD 1995
  */
 
 #include "wd.h"
@@ -403,18 +403,19 @@
 
 	/* Read table of contents. */
 	if (wcd_read_toc (t) != 0)
-		return (EIO);
+		bzero (&t->toc, sizeof (t->toc));
 
 	/* Read disc capacity. */
 	if (wcd_request_wait (t, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0,
 	    0, sizeof(t->info), 0, (char*)&t->info, sizeof(t->info)) != 0)
-		return (EIO);
+		bzero (&t->info, sizeof (t->info));
 	t->info.volsize = ntohl (t->info.volsize);
 	t->info.blksize = ntohl (t->info.blksize);
 
 	/* Print the disc description string on every disc change.
 	 * It would help to track the history of disc changes. */
-	if (t->flags & (F_MEDIA_CHANGED | F_DEBUG)) {
+	if (t->info.volsize && t->toc.hdr.ending_track &&
+	    (t->flags & (F_MEDIA_CHANGED | F_DEBUG))) {
 		printf ("wcd%d: ", t->lun);
 		if (t->toc.tab[0].control & 4)
 			printf ("%ldMB ", t->info.volsize / 512);
@@ -692,6 +693,8 @@
 			0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0);
 
 	case CDIOREADTOCHEADER:
+		if (! t->toc.hdr.ending_track)
+			return (ENODEV);
 		bcopy (&t->toc.hdr, addr, sizeof t->toc.hdr);
 		break;
 
@@ -702,6 +705,8 @@
 		struct toc buf;
 		u_long len;
 
+		if (! t->toc.hdr.ending_track)
+			return (ENODEV);
 		if (te->starting_track < toc->hdr.starting_track ||
 		    te->starting_track > toc->hdr.ending_track)
 			return (EINVAL);
@@ -792,6 +797,9 @@
 		struct ioc_play_track *args = (struct ioc_play_track*) addr;
 		u_long start, len;
 		int t1, t2;
+
+		if (! t->toc.hdr.ending_track)
+			return (ENODEV);
 
 		/* Ignore index fields,
 		 * play from start_track to end_track inclusive. */

---
Serge Vakulenko                 <vak@cronyx.msk.su>
Cronyx Ltd., Moscow             Unix consulting and custom programming
phone: +7 (095) 939-23-23       FreeBSD support
fax:   +7 (095) 939-03-00       Relcom network development




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.950922220641.274A-100000>