Bug 25240

Summary: incomplete CDIOCREADSUBCHANNEL support in atapi-cd
Product: Base System Reporter: Tony Finch <dot>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Tony Finch 2001-02-21 01:50:01 UTC
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`.

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?
How-To-Repeat: 
`cdcontrol status media` with an audio CD in an ATAPI drive prints
garbage for the catalogue number.
Comment 1 Tony Finch 2001-02-21 12:31:39 UTC
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 };
Comment 2 Søren Schmidt freebsd_committer freebsd_triage 2001-05-29 14:27:21 UTC
State Changed
From-To: open->closed

Dublicate of pr 26644, which contain a more complete set of 
patches. I need to find out how exactly I want this done though.