public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>,
	linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: change sys_truncate/sys_ftruncate length parameter type
Date: Wed, 23 Sep 2009 09:31:15 -0700	[thread overview]
Message-ID: <4ABA4D53.2040607@zytor.com> (raw)
In-Reply-To: <alpine.LFD.2.01.0909230808130.4950@localhost.localdomain>

Linus Torvalds wrote:
> 
> Look at sys_ftruncate() again. It doesn't convert it to signed long at 
> all. It converts it to 'loff_t' which is something different entirely.
> 
> Now, it may be that we _should_ convert it to 'long' like your patch does, 
> but this is definitely not a "no changes" patch as far as I can tell. It 
> limits ftruncate to 31 bits on 32-bit architectures, in ways it didn't use 
> to be limited.
> 
> [ Note the "small" logic and the interaction with O_LARGEFILE. On a 32-bit 
>   architecture, if you open with O_LARGEFILE, ftruncate() gets the full 
>   32-bit range, and that's the part your patch broke. ]
> 

I would argue that the current behavior is, if not incorrect (we define 
our own ABI after all) at least unwanted (we want our ABI to be as close 
as practical to the POSIX API.)

In particular, at the API level, both truncate() and ftruncate does take 
a signed (off_t) parameter, and the POSIX spec states:

        The ftruncate() function shall fail if:

        EINVAL The length argument was less than 0.

So yes, it's a change, but it seems to be one which probably should be done.

> In addition if hpa comes up with an automated way of generating
> compat wrappers it would generate wrong ones for these two cases.

I really mean to try to shake free some time and do that project.  I 
don't think it will happen before Kernel Summit, though :(

	-hpa

  parent reply	other threads:[~2009-09-23 16:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-23 15:03 [PATCH] fs: change sys_truncate/sys_ftruncate length parameter type Heiko Carstens
2009-09-23 15:13 ` Linus Torvalds
2009-09-23 15:49   ` Heiko Carstens
2009-09-23 15:49     ` Heiko Carstens
2009-09-23 16:31   ` H. Peter Anvin [this message]
2009-09-23 17:18     ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ABA4D53.2040607@zytor.com \
    --to=hpa@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox