Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Aug 1999 02:03:25 -0700 (PDT)
From:      "Jason K. Fritcher" <jkf@wolfnet.org>
To:        freebsd-questions@freebsd.org
Subject:   ioctl problem w/ scsi cdrom
Message-ID:  <Pine.BSF.4.10.9908110201160.14325-100000@outreach.wolfnet.org>

next in thread | raw e-mail | index | archive | help

As a follow-up for my own message, here are the version stats for my system.

FreeBSD solaris.wolfnet.org 3.2-19990804-STABLE FreeBSD 3.2-19990804-STABLE
#0: Wed Aug  4 09:37:01 GMT 1999
root@usw3.freebsd.org:/usr/src/sys/compile/GENERIC  i386

--
 Jason K. Fritcher
  jkf@wolfnet.org

---------- Forwarded message ----------
Date: Wed, 11 Aug 1999 01:52:08 -0700 (PDT)
From: Jason K. Fritcher <jkf@wolfnet.org>
To: freebsd-questions@freebsd.org
Subject: ioctl problem w/ scsi cdrom


Hello. I am writing an audio cd player because I can't find one that I like.
I am having a problem interacting with the cdrom through ioctls. I have
looked at the source code of other programs that work, and what I am doing
looks the same as what they are doing, but mine doesn't work. All of the
ioctl calls I am making, returns an error of 'Inappropriate ioctl for
device'. The device I am using is /dev/rcd0c, which I think is the right
device since other programs I have looked at use that device.

Any help or references to information is much appriciated.


Here are the appropriate devices from dmesg:

ahc0: <Adaptec aic7890/91 Ultra2 SCSI adapter> rev 0x00 int a irq 15 on pci0.6.0
ahc0: aic7890/91 Wide Channel A, SCSI Id=7, 16/255 SCBs
cd0 at ahc0 bus 0 target 6 lun 0
cd0: <PLEXTOR CD-ROM PX-40TS 1.00> Removable CD-ROM SCSI-2 device 
cd0: 20.000MB/s transfers (20.000MHz, offset 15)


Here is the snippet of code I am having problems with.

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/cdio.h>

#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int cda_open(char *devname, struct ioc_capability *cap)
{
    int fd;

    /* Open device in read-only mode. */
    if ((fd = open(devname, O_RDONLY)) < 0) {
        fprintf(stderr, "open(): Can't open %s: %s\n", devname, strerror(errno));
        return -1;
    }

    /* Reset cdrom drive. */
    if (ioctl(fd, CDIOCRESET) < 0) {
        fprintf(stderr, "ioctl(): %s\n", strerror(errno));
        return -1;
    }

    /* Get cdrom drive capabilities. */
    if (ioctl(fd, CDIOCCAPABILITY, cap) < 0) {
        fprintf(stderr, "ioctl(): %s\n", strerror(errno));
        return -1;
    }

    return fd;
}

int main(int argc, char *argv[])
{
    struct ioc_capability cap;

    cda_open(argv[1], &cap);

    return 0;
}



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9908110201160.14325-100000>