Re: IDE/ATAPI in 2.5

From: Erik Andersen (andersen@codepoet.org)
Date: Sat Jul 13 2002 - 19:34:25 EST


On Sat Jul 13, 2002 at 12:53:46PM -0400, Olivier Galibert wrote:
> On Fri, Jul 12, 2002 at 11:40:58PM -0600, Erik Andersen wrote:
> > If you would throw away crdrecord's desire to do its own private
> > SCSI bus scanning
>
> CDROM_SEND_PACKET sounds nice, but do you have a way to:
> 1- Find all cdrom-ish devices in the system
> 2- Find if a given device is cdrom-ish
>
> By cdrom-ish, I mean cdrom, dvdrom, cd writer, dvd writer or a
> combination.
>
> Point 1 is necessary to be a minimum user-friendly, point 2 is
> necessary because you can't trust users :-)

Well, one way would be to scan for them directly, i.e.:
    for i in /dev/hd* ; do
        ioctl(fd, HDIO_GET_IDENTITY, &ident);
        if (!(ident.config & 0x4000) && ((ident.config & 0x1f00) >> 8)==5) {
            /* Got an ATAPI cdrom drive */
        }
    for i in /dev/scd* ; do
        open ($i, O_RDONLY|O_NONBLOCK)) < 0) {
            /* Got a SCSI cdrom drive */
        }
  
Of course making user space do this is pretty lame. But we
have a much better way. Each cdrom device registers with the
uniform cdrom driver, which can easily assign each registered
cdrom device a major and minor. That scanning for cdroms would
be as simple as
    for i in /dev/cdrom* ; do
        open ($i, O_RDONLY|O_NONBLOCK)) < 0) {
            /* Found a cdrom drive */
        }
    
 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 15 2002 - 22:00:26 EST