From: Jamie Lokier <jamie@shareable.org>
To: Andi Kleen <ak@muc.de>
Cc: Bryan Henderson <hbryan@us.ibm.com>,
linux-fsdevel@vger.kernel.org,
Paul Taysom <Paul.Taysom@novell.com>,
viro@www.linux.org.uk
Subject: Re: negative seek offsets in VFS
Date: Sat, 28 May 2005 13:37:31 +0100 [thread overview]
Message-ID: <20050528123731.GA26151@mail.shareable.org> (raw)
In-Reply-To: <20050527104311.GC86087@muc.de>
Andi Kleen wrote:
> The linux system call interface on most (all?) architectures
Actually that's not true on many architectures, including most of the
64-bit ones. See (e.g.) the Alpha, MIPS32, MIPS64, IA64, PPC32 and
PPC64 versions of <asm/unistd.h>, which use a separate register to
indicate an error return.
That's the reason for the `force_successful_syscall_return' macro,
defined in <linux/ptrace.h>:
/*
* System call handlers that, upon successful completion, need
* to return a negative value should call
* force_successful_syscall_return() right before returning.
* On architectures where the syscall convention provides for
* a separate error flag (e.g., alpha, ia64, ppc{,64},
* sparc{,64}, possibly others), this macro can be used to
* ensure that the error flag will not get set. On
* architectures which do not support a separate error flag,
* the macro is a no-op and the spurious error condition needs
* to be filtered out by some other means (e.g., in
* user-level, by passing an extra argument to the syscall
* handler, or something along those lines).
*/
> reserves -1 to -4095 for error returns. When such a error is detected
> it is converted to errno and -1. This applies to all system
> calls.
>
> Take a look at unistd.h of your favourite architecture if you
> dont believe me.
Most unistd.h's are wrong by now, as they don't test against -4095.
Example, from <asm-x86_64/unistd.h>:
if ((unsigned long)(res) >= (unsigned long)(-127)) { \
errno = -(res); \
res = -1; \
} \
return (type) (res); \
>From <asm-x86_64/errno.h>:
#include <asm-generic/errno.h>
>From <asm-generic/errno.h>:
#define ECANCELED 125 /* Operation Canceled */
#define ENOKEY 126 /* Required key not available */
#define EKEYEXPIRED 127 /* Key has expired */
#define EKEYREVOKED 128 /* Key has been revoked */
#define EKEYREJECTED 129 /* Key was rejected by service */
Spot the inconsistency :)
x86_64 tests against -127; SH64 against -125; etc. most of the ones I
looked at are wrong, they're different from each other (despite using
<asm-generic/errno.h>), and most of them have a comment preceding the
test which states yet another different wrong number.
Example, from <asm-s390/unistd.h>:
/* user-visible error numbers are in the range -1 - -122:
see <asm-s390/errno.h> */
#define __syscall_return(type, res) \
do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-- Jamie
next prev parent reply other threads:[~2005-05-28 12:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <s29588e0.089@sinclair.provo.novell.com>
2005-05-26 17:49 ` negative seek offsets in VFS Bryan Henderson
2005-05-26 19:23 ` Andi Kleen
2005-05-26 21:17 ` Bryan Henderson
2005-05-27 10:43 ` Andi Kleen
2005-05-27 18:39 ` Bryan Henderson
2005-05-28 12:41 ` Jamie Lokier
2005-05-31 18:08 ` Bryan Henderson
2005-05-30 9:36 ` Andi Kleen
2005-05-31 18:33 ` Bryan Henderson
2005-05-28 12:37 ` Jamie Lokier [this message]
2005-05-30 9:32 ` Andi Kleen
2005-05-26 14:29 Paul Taysom
-- strict thread matches above, loose matches on Subject: below --
2005-05-25 16:39 Andi Kleen
2005-05-25 16:56 ` Trond Myklebust
2005-05-25 18:48 ` Andi Kleen
2005-05-26 0:56 ` Bryan Henderson
2005-05-26 19:20 ` Andi Kleen
2005-05-26 15:15 ` Al Viro
2005-05-26 15:29 ` Linus Torvalds
2005-05-26 19:25 ` Andi Kleen
2005-05-26 19:39 ` 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=20050528123731.GA26151@mail.shareable.org \
--to=jamie@shareable.org \
--cc=Paul.Taysom@novell.com \
--cc=ak@muc.de \
--cc=hbryan@us.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@www.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.