From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Lokier Subject: Re: negative seek offsets in VFS Date: Sat, 28 May 2005 13:37:31 +0100 Message-ID: <20050528123731.GA26151@mail.shareable.org> References: <20050526192332.GW86087@muc.de> <20050527104311.GC86087@muc.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Bryan Henderson , linux-fsdevel@vger.kernel.org, Paul Taysom , viro@www.linux.org.uk Return-path: Received: from mail.shareable.org ([81.29.64.88]:4062 "EHLO mail.shareable.org") by vger.kernel.org with ESMTP id S262718AbVE1Mhk (ORCPT ); Sat, 28 May 2005 08:37:40 -0400 To: Andi Kleen Content-Disposition: inline In-Reply-To: <20050527104311.GC86087@muc.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org 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 , which use a separate register to indicate an error return. That's the reason for the `force_successful_syscall_return' macro, defined in : /* * 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 : if ((unsigned long)(res) >= (unsigned long)(-127)) { \ errno = -(res); \ res = -1; \ } \ return (type) (res); \ >>From : #include >>From : #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 ), and most of them have a comment preceding the test which states yet another different wrong number. Example, from : /* user-visible error numbers are in the range -1 - -122: see */ #define __syscall_return(type, res) \ do { \ if ((unsigned long)(res) >= (unsigned long)(-125)) { \ -- Jamie