[syslinux] port syslinux isohybrid perl script to C
H. Peter Anvin
hpa at zytor.com
Tue Apr 13 23:11:10 PDT 2010
On 04/13/2010 09:39 PM, P J P wrote:
> Hi,
>
> --- On Wed, 14/4/10, H. Peter Anvin <hpa at zytor.com> wrote:
>> fwrite(3) is the best option. Also keep in mind that you might be on a
>> system of different native byte order.
>
> But, fwrite(3) is for writing data to the file. Whereas, the following block writes data to mbr buffer, which is then written to the file with write(2).
>
For writing bytes to a buffer, just use simple assignment:
mbr[0] = 0x80;
mbr[1] = bhead;
... etc ...
Your use of write(2) is also incorrect; write(2) is interruptible and
should nearly always be used in a loop. The easiest workaround is to
use fwrite(3), which contains said loop.
A lot of this is pretty elementary C...
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
More information about the Syslinux
mailing list