Open / check different devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I want to check different devices on status and if media is insert.
Now i have tried followed 

    errno = 0;
    fd = open( device , O_RDWR|O_NONBLOCK );
    if( fd < 0 ) {
        if( errno == ENOENT ) return "3,0,0,0" ;
        i = 1 ;
        errno = 0;
        fd = open( device , O_RDONLY|O_NDELAY );
        if( fd < 0 ) {
            return "2,0,0,0" ;
        }
    }
    sprintf( parmstring , "%d,0,0,0" , i );

    return parmstring ;

But if I check a cd-rom device without any insert media, i get the parameter
1,0,0,0.
Exist any other easy way to check different devices (disk, floppy, tape, cd,
zip) or should i check the status of the devices with special ioctl -
commands ? 

Thnx 
Alex



_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@redhat.com
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux