[svlug] Predicting size of CD image

Ixanian Craig Nichols fathom at armory.com
Thu Jan 30 17:07:00 PST 2003


On Thu January 30 2003 3:55 pm, Sean McAfee wrote:
> Greetings everyone--
>
> I'm working on some software which generates CD images by running the
> following command:
>
> dd if=/dev/scd0 of=image.iso
>
> I'd like to be able to find out in advance how large the image is going to
> be so that I can present a status thermometer for the reading process.
> I've tried stat(2) and fstat(2), but both return a size of zero when
> applied to /dev/scd0.  That's pretty much all I presently know to try.
>
> Can anyone suggest a way to get the info I'm after?  Thanks in advance.

A simple alternative to the ways mentioned so far: the "sum" command.

"sum /dev/sr0" reports the same block count as "dd if=/dev/sr0 of=foo.iso" (if 
it doesn't, try "sum -s /dev/sr0"). 

If you'd rather see the sizes in 1k blocks (much easier to parse for most 
human brains), use "sum -r" and "dd bs=1k".

- Ix




More information about the svlug mailing list