[klibc] bunch of small fixes

H. Peter Anvin hpa at zytor.com
Fri Mar 28 16:30:50 PDT 2008

Nigel Cunningham wrote:
> Not being a shell guru, I'm not sure what the simplest way is to get
> 0xedc302e99856e50c into the start of a file. Can you help there?

It depends on what byte order you want to use (it should match the byte 
order of the other fields), but for littleendian, you can do:

printf '\x0c\xe5\x56\x98\xe9\x02\xc3\xed' > file


echo -ne '\x0c\xe5\x56\x98\xe9\x02\xc3\xed' > file

What I mean with "match the byte order of the other fields" - if you 
have no fields which are host-byte-order-dependent, just pick a specific 
byte sequence (like the above one) and stick to it.  If you *have* 
fields which are host-byte-order-dependent, then you probably want to 
have the magic be endian-sensitive too, unless you have a separate byte 
order field.


More information about the klibc mailing list