Date: Thu, 15 Oct 1998 00:23:40 +0900 (JST) From: tamrin@kuee.kyoto-u.ac.jp To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: kern/8316: [ATAPI CD-ROM] open() doesn't return -1 when no CDs in drive. Message-ID: <199810141523.AAA12060@shinzan.kuee.kyoto-u.ac.jp>
next in thread | raw e-mail | index | archive | help
>Number: 8316
>Category: kern
>Synopsis: [ATAPI CD-ROM] open() doesn't return -1 when no CDs in drive.
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Oct 14 08:30:01 PDT 1998
>Last-Modified:
>Originator: Masatoshi TAMURA
>Organization:
Kyoto Univ.
>Release: FreeBSD 2.2.7-RELEASE i386
>Environment:
OS Version: 2.2.7-RELEASE
ATAPI CD-ROM: TEAC CD-524EA (Secondary Master)
M/B: GigaByte GA-586ATX3
: wdc1 at 0x170-0x177 irq 15 on isa
: wdc1: unit 0 (atapi): <CD-524EA/3.0A>, removable, accel, ovlap, dma, iordis
: wcd0: 4134Kb/sec, 128Kb cache, audio play, 16 volume levels, ejectable tray
: wcd0: no disc inside, unlocked
>Description:
I think, for SCSI CD driver compatible, open() system call for
"/dev/[r]wcd0c" should return -1 if no CD is in the drive.
But open("/dev/rwcd0c",..) return a positive number such case.
Open() seems to success, but no ioctl() request is accepted by
returned file descriptor.
>How-To-Repeat:
Run the next program with no CD in drive.
You will see "open success(fd=3)", and kernel message
"wcd0: cannot read audio disc" in cosole.
-----
#include <stdio.h>
#include <fcntl.h>
main()
{
int fd;
if ((fd = open("/dev/rwcd0c", O_RDONLY)) < 0)
printf("open fail\n");
else
printf("open success(fd=%d)\n", fd);
return 0;
}
-----
>Fix:
patch for /sys/i386/isa/wcd.c
function wcd_read_toc() will return only 0 or EIO(this is defined to 5).
So "wcd_read_toc (t) < 0" is always FALSE.
--- /sys/i386/isa/wcd.c.original Tue Jul 7 14:23:28 1998
+++ /sys/i386/isa/wcd.c Fri Oct 9 14:11:30 1998
@@ -420,7 +420,7 @@
/* On the first open, read the table of contents. */
if (! (t->flags & F_BOPEN) && ! t->refcnt) {
/* Read table of contents. */
- if (wcd_read_toc (t) < 0)
+ if (wcd_read_toc (t) != 0)
return (EIO);
/* Lock the media. */
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810141523.AAA12060>
