From owner-freebsd-current Fri Sep 22 11:18:40 1995 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id LAA12703 for current-outgoing; Fri, 22 Sep 1995 11:18:40 -0700 Received: from crox.net.kiae.su (crox.net.kiae.su [144.206.130.72]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id LAA12694 for ; Fri, 22 Sep 1995 11:18:27 -0700 Received: by crox.net.kiae.su id WAA00280; (8.6.9/vak/1.8a) Fri, 22 Sep 1995 22:09:41 +0400 Date: Fri, 22 Sep 1995 22:09:41 +0400 (MSD) From: "Serge V.Vakulenko" To: current@freebsd.org Subject: [patch] wcd.c version 1.6 Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-current@freebsd.org Precedence: bulk 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 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