LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Data cd title in bash (https://www.linuxquestions.org/questions/programming-9/data-cd-title-in-bash-652000/)

freeindy 06-27-2008 04:11 AM

Data cd title in bash
 
Hi,

A simple question:
How can I retreive the data cd title in bash?

Thanks,
Indy

colucix 06-27-2008 05:17 AM

Code:

volname
This is a little utility coming with the eject package. If you don't specify the device name (as in my example) it defaults to /dev/cdrom. If you don't have the volname utility you can read the label using the dd command:
Code:

dd if=/dev/cdrom bs=1 skip=32808 count=32 2>/dev/null
the redirection of the standard error to /dev/null is meant to strip out the statistics from the output of the dd command.

Hko 06-27-2008 05:50 AM

* please ignore / delete *
(did not read thread very well, sry)

sk8guitar 07-01-2008 10:35 AM

colucix, are you saying that the cd title information is 32 bytes long located at an offset of 32808 blocks (in 512 chucks) from the start? where did you find this info? i've been googling for a few minutes and can't seem to find anything

sk8guitar 07-01-2008 10:35 AM

i'm just personally curious

colucix 07-01-2008 11:13 AM

Quote:

Originally Posted by sk8guitar (Post 3200378)
colucix, are you saying that the cd title information is 32 bytes long located at an offset of 32808 blocks (in 512 chucks) from the start?

Not really. The offset is 32808 bytes (see bs=1 in the dd command above). The structure of a ISO9660 CDROM is divided in blocks of 2048 bytes. The first sixteen blocks are the System Area and does not conform to any standard. Then follows a Primary Volume Descriptor, whose structure tell us that at bytes from 41 to 72 the volume identifier (that is the CD title) is written. So 2048*16 + 40 = 32808 is the offset to read the volume identifier.

Such informations are contained in the official standard "Volume and file structure of CDROM for Information Interchange". The structure of the Primary Volume Descriptor is specified in paragraph 8.4 at page 17 (see table).

More simply the dd command above is taken from the Linux CDROM Howto. Forgive me, I did not mention!


All times are GMT -5. The time now is 07:00 PM.