From fanf@dotat.at  Tue Feb 20 17:47:25 2001
Return-Path: <fanf@dotat.at>
Received: from hand.dotat.at (sfo-gw.covalent.net [207.44.198.62])
	by hub.freebsd.org (Postfix) with ESMTP id E640437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 20 Feb 2001 17:47:24 -0800 (PST)
	(envelope-from fanf@dotat.at)
Received: from fanf by hand.dotat.at with local (Exim 3.20 #3)
	id 14VONA-0000FZ-00
	for FreeBSD-gnats-submit@freebsd.org; Wed, 21 Feb 2001 01:47:16 +0000
Message-Id: <E14VONA-0000FZ-00@hand.dotat.at>
Date: Wed, 21 Feb 2001 01:47:16 +0000
From: Tony Finch <dot@dotat.at>
Reply-To: Tony Finch <dot@dotat.at>
To: FreeBSD-gnats-submit@freebsd.org
Subject: incomplete CDIOCREADSUBCHANNEL support in atapi-cd
X-Send-Pr-Version: 3.2

>Number:         25240
>Category:       kern
>Synopsis:       incomplete CDIOCREADSUBCHANNEL support in atapi-cd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 20 17:50:01 PST 2001
>Closed-Date:    Tue May 29 06:27:21 PDT 2001
>Last-Modified:  Tue May 29 06:28:11 PDT 2001
>Originator:     Tony Finch
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
Covalent Technologies, Inc.
>Environment:

FreeBSD hand.dotat.at 4.2-STABLE FreeBSD 4.2-STABLE #4: Wed Feb 21 00:26:12 GMT 2001     fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/releng4/sys/DELL-Latitude-CSx  i386

>Description:

The implementation of CDIOCREADSUBCHANNEL in sys/dev/ata/atapi-cd.c only
supports the CD_CURRENT_POSITION data_format, but it doesn't actually
check the data_format to ensure that it is CD_CURRENT_POSITION. This
manifests as garbage printed by `cdcontrol status media`.

>How-To-Repeat:

`cdcontrol status media` with an audio CD in an ATAPI drive prints
garbage for the catalogue number.

>Fix:

This patch just checks that the data_format is supported. I'm not
sure if ENODEV is right: would EOPNOTSUPP (as suggested by bfumerola)
be more appropriate or does the fact that it isn't mentioned in the
ioctl(2) man page mean that isn't allowed?

Index: atapi-cd.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/atapi-cd.c,v
retrieving revision 1.48.2.9
diff -u -r1.48.2.9 atapi-cd.c
--- atapi-cd.c	2001/01/29 18:07:18	1.48.2.9
+++ atapi-cd.c	2001/02/21 01:42:14
@@ -730,6 +730,11 @@
 			       sizeof(cdp->subchan)>>8, sizeof(cdp->subchan),
 			       0, 0, 0, 0, 0, 0, 0 };
 
+	    if (args->data_format != CD_CURRENT_POSITION) {
+		error = ENODEV;
+		break;
+	    }
+
 	    if (len > sizeof(data) ||
 		len < sizeof(struct cd_sub_channel_header)) {
 		error = EINVAL;
>Release-Note:
>Audit-Trail:

From: Tony Finch <dot@dotat.at>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/25240: incomplete CDIOCREADSUBCHANNEL support in atapi-cd
Date: Wed, 21 Feb 2001 12:31:39 +0000

 Following a conversation with sos about this I have tried the
 following patch which has the same end result (at least on my
 hardware) but takes a slightly different route.
 
 This patch needs some finishing to deal with the way the data is
 prepared for copyout(); I note that the CAM SCSI CD driver just copies
 the response data from the device straight into the user's args->data
 block.
 
 Tony.
 -- 
 f.a.n.finch    fanf@covalent.net    dot@dotat.at
 CROMARTY: NORTHWESTERLY 5 TO 7, OCCASIONALLY GALE 8 IN NORTHEAST. SHOWERS.
 GOOD.
 
 Index: atapi-cd.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/dev/ata/atapi-cd.c,v
 retrieving revision 1.48.2.9
 diff -u -r1.48.2.9 atapi-cd.c
 --- atapi-cd.c	2001/01/29 18:07:18	1.48.2.9
 +++ atapi-cd.c	2001/02/21 11:08:56
 @@ -726,7 +726,8 @@
  	    struct cd_sub_channel_info data;
  	    int len = args->data_len;
  	    int32_t abslba, rellba;
 -	    int8_t ccb[16] = { ATAPI_READ_SUBCHANNEL, 0, 0x40, 1, 0, 0, 0,
 +	    int8_t ccb[16] = { ATAPI_READ_SUBCHANNEL, 0, 0x40, 
 +			       args->data_format, 0, 0, 0,
  			       sizeof(cdp->subchan)>>8, sizeof(cdp->subchan),
  			       0, 0, 0, 0, 0, 0, 0 };
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Tue May 29 06:27:21 PDT 2001 
State-Changed-Why:  
Dublicate of pr 26644, which contain a more complete set of 
patches. I need to find out how exactly I want this done though. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=25240 
>Unformatted:
