lkml.org 
[lkml]   [2000]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: CD_Rom problems (fwd)
On Wed, 12 Jul 2000, Dave wrote:

> Sorry about the seriousness comment... I wasn't trying to be snotty... You
> guys really are the best in the world and deserve more credit than you all
> get.
>
> I believe what I was writing is...
>
> int main () {
> int file;
> int stats;
> file = open("/dev/hdd", O_RDONLY | O_NONBLOCK);
> ioctl(file, CDROM_GET_CAPABILITY, & stats);
> if (stats && CDC_SELECT_DISC)
^^ Will nearly always be true.
> printf("Success!\n");
> else
> printf("<DOH!> Something went wrong\n");
> return 0;
> }
>

The following works:

#include <stdio.h>
#include <fcntl.h>
#include <linux/cdrom.h>

int main () {
int file;
int stats;
if((file = open("/dev/hdd", O_RDONLY | O_NONBLOCK)) < 0)
{
fprintf(stderr,"No such device\n");
return 0;
}
ioctl(file, CDROM_GET_CAPABILITY, & stats);
if (stats & CDC_SELECT_DISC)
printf("Success!\n");
else
printf("<DOH!> Something went wrong\n");
return 0;
}


Cheers,
Dick Johnson

Penguin : Linux version 2.2.15 on an i686 machine (797.90 BogoMips).

"Memory is like gasoline. You use it up when you are running. Of
course you get it all back when you reboot..."; Actual explanation
obtained from the Micro$oft help desk.



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.076 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site