[svlug] Predicting size of CD image

Karsten M. Self kmself at ix.netcom.com
Thu Jan 30 16:32:29 PST 2003

on Thu, Jan 30, 2003 at 03:55:38PM -0800, Sean McAfee (mcafee at transmeta.com) 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.

mount the device if it's mountable, and check the size.  This will give
you approximately the right value (probably underestimating by a bit).

As the image is a remote bitstream, as you're accessing it, the data
you're looking for *won't* be available until you read the bitstream at
least once.  This occurs, e.g., when you write a file on a filesystem.

Unless contained in header data of the bitstream itself, the data you're
looking for won't be known until you've completed the read.


Karsten M. Self <kmself at ix.netcom.com>        http://kmself.home.netcom.com/
 What Part of "Gestalt" don't you understand?
    The truth behind the H-1B indentured servant scam:

More information about the svlug mailing list