Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Interpreting CDROM_GET_CAPABILITIES ioctl

Reply
Thread Tools

Interpreting CDROM_GET_CAPABILITIES ioctl

 
 
Chris Johnson
Guest
Posts: n/a
 
      06-15-2005
I have need to determine the capabilities of an optical drive. Right
now I'm using SDL to find the drives, and ioctl to get the
capabilities. Unfortunately, based on the output that I'm getting,
either my method of interpretation is bad or these drives are
misrepresenting themselves (which they shouldn't be, as other programs
can use the abilites they would here appear to be lacking). If anyone
has experience with the CDROM_GET_CAPABILITIES ioctl, could you please
tell me where I am going amiss?

Thanks,
Chris

#include <stdio.h>
#include <SDL.h>
#include <linux/cdrom.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>


int main(){
/* Initialize CDROM subsystem */
int init = SDL_Init(SDL_INIT_CDROM);

/* Get number of drives */
int num = SDL_CDNumDrives();
printf("Initialized: %d\nNumber of Drives: %d\n",init,num);


int i;
for(i=0;i < num; ++i){
/* System-dependent drive name (i.e. /dev/cdrom or E*/
const char *name = SDL_CDName(i);
printf("Name: %s\nID: %d\n",name,i);

/* Open device */
int drive = open(name,0);
if(drive < 0){
printf("Cannot open drive: %s.\n",name);
return 1;
}

/* Pointer to hold output */
int *argp;

/* Get drive capabilities, store in argp */
int retvalue = ioctl(drive,CDROM_GET_CAPABILITY,argp);

/* First attempt at argp interpretation */
if(*argp & CDC_CD_R)
printf("Can write CD-Rs\n");
if(*argp & CDC_CD_RW)
printf("Can write CD-RWs\n");
if(*argp & CDC_DVD)
printf("Can read DVDs\n");
if(*argp & CDC_DVD_R)
printf("Can write DVD-Rs\n");
if(*argp & CDC_DVD_RAM)
printf("Can write DVD-RAMs\n");

/* Most likely gibberish output, but I still want to see it. */
printf("Return: %d\nArgp: %Ld\n",retvalue,argp);
close(drive);
}
return 0;
}

 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      06-15-2005
Chris Johnson wrote:
>
> I have need to determine the capabilities of an optical drive. Right
> now I'm using SDL to find the drives, and ioctl to get the
> capabilities. Unfortunately, based on the output that I'm getting,
> either my method of interpretation is bad or these drives are
> misrepresenting themselves (which they shouldn't be, as other programs
> can use the abilites they would here appear to be lacking). If anyone
> has experience with the CDROM_GET_CAPABILITIES ioctl, could you please
> tell me where I am going amiss?


You are going amiss by expecting an answer here. Those things are
peculiar to the system and compiler you are using, so ask in a
newsgroup that deals with them. c.l.c deals with the PORTABLE C
language, which knows nothing about drives, ioctl, etc.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson


 
Reply With Quote
 
 
 
 
Lawrence Kirby
Guest
Posts: n/a
 
      06-21-2005
On Wed, 15 Jun 2005 08:32:33 -0700, Chris Johnson wrote:

> I have need to determine the capabilities of an optical drive. Right
> now I'm using SDL to find the drives, and ioctl to get the
> capabilities. Unfortunately, based on the output that I'm getting,
> either my method of interpretation is bad or these drives are
> misrepresenting themselves (which they shouldn't be, as other programs
> can use the abilites they would here appear to be lacking). If anyone
> has experience with the CDROM_GET_CAPABILITIES ioctl, could you please
> tell me where I am going amiss?


The C language doesn't define SDL or ioctl, these are extensions provided
by your platform and are not portable.

Your code appears to be including a linux related header. A good place to
discuss Linux related features is comp.os.linux.development.apps.

Lawrence

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ioctl klappnase@web.de Python 1 02-09-2006 01:47 PM
ioctl() help needed for video4linux Kyler Laird Python 0 12-24-2004 11:08 PM
ioctl(2) ? Peter Luciak Python 1 04-24-2004 07:39 PM
Python + ioctl + Windows HOWTO?? Javier Python 1 10-30-2003 10:06 AM
how to make network ioctl call from java Roger Java 1 10-22-2003 10:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57