Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Specialized CD Querying Program

From: Patrick Gibson <openbsd_list(at)patrickg.com>
Date: Wed Feb 26 2003 - 02:54:43 EST


Since I cannot seem to find anything that does exactly what I want*, I've decided it shouldn't be too hard to write a simple program that does it.

  • Here's what I want to do:

I want to have a process running that queries the CD drive (always going to be an IDE drive on i386 architecture) every few seconds, and when it detects that the door has just closed (if that's possible) or that there is suddenly media present, it executes the command of my choice.

I noticed that when you run the mount command on the cdrom and there's no media present, an error message is displayed like so:

cd0(atapiscsi0:0:0): Check Condition on opcode 0x43

    SENSE KEY: Not Ready
     ASC/ASCQ: Medium Not Present

So it occurred to me, that all I really need to do is figure what code to send the device, and listen for the same opcode as mount (0x43, I presume?). The trouble is, I need a little help getting pointed in the right direction on exactly how I can do this. It seems like only a few simple calls, but what exactly I need to call, I'm not sure. I've been looking through atapiscsi.c, mount.c, and a few others, but I'm finding myself a bit lost as to precisely for what I should be looking.

If anyone is familiar with working directly with a CD-ROM device, I'd really appreciate a push in the right direction. I think even knowing which initial function I need to call to send a signal ought to be enough to get me started.

Thanks in advance,

Do you need help?X

Patrick Received on Wed Feb 26 02:57:05 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:48:30 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library