Re: write(2) fails for large sizes in 64 bit applications
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=nuRLH7U1/d3uL7YaetMbDNr4gf8DZsoHa9TXxu1/iH0=; b=pZd6CEUr0/owus+kxfZtOympSuyv/PmqbxMiyHJsTBqpk/717Am42rU3zE4UwV/RvM IqIRhx5XF1MXP7NmNWwj7gPWss1Y7vyTIrdzSultEzLIzfdN5lCKfeLWWBQDxoCimPnB AM2oXib7UKliIZD5lqOJ58KOu9JywCco+WaJg= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=nM8Ww0xR1t0OP2ZFYgtpEklKvza8dAdRKLk96WjHtEjD4aonTM1EIRlTYHvgBQ1PF0 x1MV1O+kKsCdKOGK8meYNg1OfzMZVxNXH6fjmZn4xC4i9XENQhFk2wHqQ1uHuTHMq6Ua qwawZWEJ/PyULGa53IPaZN2I1LZXNrVPuy62M= Hi Jeremy, we know... what Robert pointed is a problem of behaviour regarding the return errno and the size_t, what Robert suggested to make the syscall not to fail is arguable and this is a question a side of the first comment. Robert noted a strange behaviour and certainly was disrupted by the errno and the size_t returned values I guess he was making a test; Robert did compare both architectures only to describe his point of view. There is something wrong, if you read the standard regarding the returned errno, this is not a big deal, but as Robert noticed: he was misleaded. Best, On Fri, May 29, 2009 at 12:26 PM, Jeremy Pereira <adc@jeremyp.net> wrote:
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 (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/adc%40jeremyp.net
This email sent to adc@jeremyp.net
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/0xcafefeed%40gmail.com
This email sent to 0xcafefeed@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
mm w