I want to write an existing ISO file to a CD using C. I am using an array of 256 bytes to read characters from the ISO file and trying to write it to the block file /dev/sr0. But I am getting the error message “No disk space present”, even though I have checked that the CD is a blank one. Can anybody suggest why this is not working?
I would be grateful if somebody could offer some advice on this matter.
Thanks for reading this!
-----BEGIN PGP SIGNED MESSAGE-----
Since you don’t specify, is there a reason you must do this directly from
C? I do not believe, in any language, that you can treat optical devices
as regular writable devices. You could fairly easily write your 256-bite
blocks of data to a file and then burn that directly using something like
cdrecorder, though, without needing to reinvent the CD-burning wheel. You
could probably find the code to do the writing from the cdrecorder code as
well as long as you complied with its license.
On 03/04/2010 08:36 AM, arani wrote:
> I want to write an existing ISO file to a CD using C. I am using an
> array of 256 bytes to read characters from the ISO file and trying to
> write it to the block file /dev/sr0. But I am getting the error message
> “No disk space present”, even though I have checked that the CD is a
> blank one. Can anybody suggest why this is not working?
> I would be grateful if somebody could offer some advice on this
> Thanks for reading this!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
-----END PGP SIGNATURE-----
‘growisofs’ can write to a CD/DVD, so I would suggest looking at it’s source code how they do it. I suspect there are some tricks involved how to keep buffers almost full and assure a constant flow of data.
Why not just call the wodim (cdrecord) utility to do it for you?
status = system(“wodim -dev=/dev/sr0 file.iso”);
Well, to be honest, the only reason why I am doing it is because I want to know how programs interact with optical devices. I have heard that every device (including optical devices) are treated as a file (though with some restrictions), and now I am looking forward to test it.
Yes, but treated as a file when reading. You can do cat /dev/sr0 > output.iso. When writing, different rules apply due to the nature of the media.
dd if=path-to-iso of=/dev/cdrom
i am not sure, but point me if anything is wrong…
It is as far as I know not possible to directly treat the cd/dvd in the same
way as block device as you would do it with a harddisk.
What comes nearest is the use of UDF as file system on the optical media
(yes it can also be used for cd not only for dvd where it is used more
I recommend: Make yourself familier with the specs of UDF and to get an
impression from the programmers point of view:
Look into the source code of udftools and libudf on your system.