Re: Detect CD Media Type?
boo0330:
>>> Now I can detect CD-R, CD-RW very well by -atip
>>> but are there information about the CD-R is closed, or it's blank, can
>>> write or not?
me:
>> I can distinguish them by this shell code snippet which does a 1 byte
>> test read :
>> if dd if=/dev/sr0 of=/dev/null bs=1 count=1
>> then echo "Has data" ; else ; echo "Seems to be empty" ; fi
Jörg:
> This does not work correctly in all cases.
> Use the "official" way and call readcd sectors=0-0
readcd is very appealing for that purpose because it uses
the same addresses as cdrecord.
I read in man readcd :
"... so sectors=0-0
will not read anything and may be used to check for
a CD in the drive."
I read further and tried this shell snippet :
if readcd dev=0,0,0 sectors=0-0 f=- >/dev/null 2>&1
then
echo success
else
echo failure
fi
As announced by the manual it does react on a blank CD-R with the
same exit value as on a CD-R which carries a closed session.
There is a difference visible in one of the stderr output lines,
though.
Blank CD-R :
Capacity: 1 Blocks = 2 kBytes = 0 MBytes = 0 prMB
Written CD-R :
Capacity: 126018 Blocks = 252036 kBytes = 246 MBytes = 258 prMB
Did i miss any better trick here ?
Additionally the question is still open about how to see wether a
CD-R(W) is finally closed or wether it is still appendable.
Have a nice day :)
Thomas
Reply to: