Re: write(2) fails for large sizes in 64 bit applications
Re: write(2) fails for large sizes in 64 bit applications
- Subject: Re: write(2) fails for large sizes in 64 bit applications
- From: Jeremy Pereira <email@hidden>
- Date: Fri, 29 May 2009 20:26:08 +0100
On 28 May 2009, at 10:22, Robert Homann wrote:
Hi all!
Therefore, I think the implementation of write() is buggy; or at
least, its unexpected behavior in 64 bit mode should be documented on
the man page. What do you think?
I think the behaviour is probably correct in that the OS X kernel is a
*32 bit* mach-o object, at least it is on my 10.5.7 Core 2 Duo Macbook
Pro.
monica:/ jeremyp$ otool -h /mach_kernel
/mach_kernel:
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds
flags
0xfeedface 7 3 0x00 2 12 2808
0x00000001
^^^^^^^^^^ note the magic number.
In /usr/include/mach-o/loader.h:
===========
<< snip >>
/* Constant for the magic field of the mach_header (32-bit
architectures) */
#define MH_MAGIC 0xfeedface /* the mach magic number */
#define MH_CIGAM 0xcefaedfe /* NXSwapInt(MH_MAGIC) */
/*
* The 64-bit mach header appears at the very beginning of object files
for
* 64-bit architectures.
*/
<< snip >>
/* Constant for the magic field of the mach_header_64 (64-bit
architectures) */
#define MH_MAGIC_64 0xfeedfacf /* the 64-bit mach magic number */
#define MH_CIGAM_64 0xcffaedfe /* NXSwapInt(MH_MAGIC_64) */
===========
write(2) is a system call. The implementation is inside the kernel,
not in any user space library linked with your application.
Internally, it is going to be subject to 32 bit limits and personally
I think that is entirely reasonable.
Whilst I admit the kernel could be changed to cope with larger
buffers, I think it is a bit harsh to criticise it because the largest
block it can write to a file in one go is a mere 2Gb, especially
considering some other 32 bit kernels can't run 64 bit code at all.
Best regards,
Robert Homann
--
Windows is not the answer.
Windows is the question.
The answer is "No".
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden