PDA

View Full Version : Obtain detailed information about a media in the CD-ROM drive?


felix
07-21-2006, 05:47 AM
Hi,

I opened a question sometime ago asking how to obtain detailed information about a media in the CD-ROM drive, but no reply (probabilitty because I went see it in Java and you all in general hardcoded C gurus :).

The thread is here http://www.developerweb.net/forum/showthread.php?t=4502

and the questions are:

I need a source code example (commented should be good :) that show how to extract metric information from a CD in a CDROM drive.

Information I want to extract:

- CD media size (the most precise possible, 1byte or 1 nible of precision make difference for me).

- CD space used (need to be precise too).

- Number of tracks and layout of disc.

- Size and information of header CD track.

ps: Preferable if work in in Windows and Linux, if not possible just Linux already is good. :)



Someone know how to do it?

Thank you all

Regards,

mlampkin
07-21-2006, 09:34 AM
Its been a billion years or so since I did any low level disk stuff... so figured I would go look up some existing source code...

Try taking a peek at the k3b distribution... sections of interest are:

libk3bdevice/k3bscsicommand_linux.cpp

This appears to be where the appropriate scsi command(s) are sent out to retrieve all the info for the disc... if you look for calls to the transport method thru the rest of the code it should provide more info on how the retrieved info is parsed out...

You could also hunt thru other cdrom / dvd utility source code... I just happened to have k3b source on my system so that was the first place I looked...

As for Java - I don't believe you can retrieve the information without wrapping native code with JNI calls... at least I don't know of any ( and I have been using the language since the end of '95 )... but I could be wrong... ;-)


Michael

felix
07-21-2006, 05:21 PM
Hi Michael,

Thank you for reply and help. ;)

This appears to be where the appropriate scsi command(s) are sent out to retrieve all the info for the disc... if you look for calls to the transport method thru the rest of the code it should provide more info on how the retrieved info is parsed out...Michael

Hummm... scsi commands to CD-ROM drive? But it will work with CD-ROM using IDE devices?

Obs: If you find any source code that have functionality like it, it's very welcome to post here. heheh

I will check libk3bdevice/k3bscsicommand_linux.cpp, thank you. :)

Regards,

mlampkin
07-21-2006, 07:50 PM
For Linux and what not the IDE drive is typically ( automatically with a modern distribution ) wrapped with a SCSI emulation layer... that was done to allow things like information retrieval ( among other things ) to be done... so it shouldn't be a problem even with an IDE cdrom drive...

One catch - and this may no longer hold true - but if you have a distro that compiles the ATAPI IDE driver directly into the kernel then the SCSI emulation never gets used... since the built in module will be always chosen first... but again - that shouldn't be a problem with a newer ( last few years ) distribution...


Michael

felix
07-21-2006, 08:26 PM
Hi Michael,

Got it, so I think it will not be a poblem for me, I will start read the code and maybe I update the thread. :)

Thank you again,

Regards