| PLEX86 | ||
|
checking to see if a CD is in the drive Sender: LinuxCD Burning problem I wonder if anyone can help me here. I am running Red Hat Linux 9. I had a CDRW drive in my PC but upgraded it to a DVD... SCSI device listing in Linux 2.6 On 8 Dec 2005 16:12:13 -0800, googler staggered into the Black Sun and said: Hm. That one's not in 2.6.12 here. "Volume creation"? Er... what exactly did you do here? Did you reparbreastion something...
You can do this with Perl or C. C is probably your best bet. Perl example only shows opening-closing. #!-usr-bin-perl # read man ioctllist for hex codes # readusr-include-linux-cdrom.h for cd codes use Fcntl; sysopen my $f, "-dev-sr0", ORDONLYONONBLOCK or die "open $?"; ioctl $f, 0x5329, 0 or die "ioctl $!"; # 0 unlocks 1 locks door ioctl $f, 0x5309, 0 or die "ioctl $!"; # open tray ioctl $f, 0x5319, 0 or die "ioctl $!"; #close tray END ################################################################# * Begin C code. Put this in a file called cdstatus.c and do "gcc -o * cdstatus cdstatus.c" . No error checking, no looping, no * documentation, if it breaks, you get to keep both pieces. * int main(int argc, char **argv) { char buff256; * ioctl() needs a 3rd arg but it doesn't really use it here. *int fd,status; if(argc!=2){ exit(1); } fd=open(argv1, ORDONLY ONONBLOCK);* need NONBLOCK! * snprintf(buff,64,"%s cannot be opened ",argv1); perror(buff); exit(1); } status=ioctl(fd,CDROMDRIVESTATUS,buff); close(fd); switch(status){ case CDSNOINFO: printf("Whoa. Huh?-n"); break; case CDSNODISC: printf("No disc is in the drive.-n"); break; case CDSTRAYOPEN: printf("Tray is open, or tray is closed and no CD is present.-n"); break; case CDSDRIVENOTREADY: printf("Drive is not ready.-n"); break; case CDSDISCOK: printf("A disc is in the drive.-n"); break; default: printf("Um, we shouldn't be here!-n"); break; } return 0; } what does uptime's load average mean Aragorn I do not think it is a percentage. IIRC, it is the number of entries in the run queue... * end of C code *
-- I'm not really a human, but I play one on earth.
|
||||
SCSI device listing in Linux 2.6 Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||