From owner-freebsd-bugs Mon Mar 30 15:51:06 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA29894 for freebsd-bugs-outgoing; Mon, 30 Mar 1998 15:51:06 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from penguin.wise.edt.ericsson.se (penguin-ext.wise.edt.ericsson.se [194.237.142.5]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA29777 for ; Mon, 30 Mar 1998 15:50:37 -0800 (PST) (envelope-from kent@erlang.ericsson.se) Received: from erlang (erlang.ericsson.se [147.214.36.16]) by penguin.wise.edt.ericsson.se (8.7.5/8.7.3/glacier-1.12) with SMTP id BAA25091 for ; Tue, 31 Mar 1998 01:50:31 +0200 (MET DST) Received: from localhost by erlang (SMI-8.6/SMI-SVR4) id BAA27255; Tue, 31 Mar 1998 01:50:31 +0200 To: freebsd-bugs@FreeBSD.ORG Cc: kent@erlang.ericsson.se Subject: lseek bug? Reply-To: kent@erlang.ericsson.se X-Mailer: Mew version 1.92.4 on Emacs 19.34 X-URL: http://www.ericsson.se/erlang Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19980331015305F.kent@erlang.ericsson.se> Date: Tue, 31 Mar 1998 01:53:05 +0200 From: Kent Boortz X-Dispatcher: imput version 971024 Lines: 54 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org In FreeBSD 2.2.5 lseek moves the file position without any error checks. If the resulting position is negative we have the problem that the result value -1 can mean two things, that there was an error or that the file position was set to -1 and no error. We have to clear errno before the call and examine errno after the call to find out if there was an error or not. If the resulting position is to be negative, Linux and Solaris will preserve the file position before the call to lseek and return an error. Is this a bug in FreeBSD or a different interpretations of the POSIX standard? /kgb int lseek(p, uap, retval) struct proc *p; register struct lseek_args *uap; int *retval; { struct ucred *cred = p->p_ucred; register struct filedesc *fdp = p->p_fd; register struct file *fp; struct vattr vattr; int error; if ((u_int)uap->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[uap->fd]) == NULL) return (EBADF); if (fp->f_type != DTYPE_VNODE) return (ESPIPE); switch (uap->whence) { case L_INCR: fp->f_offset += uap->offset; break; case L_XTND: error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p); if (error) return (error); fp->f_offset = uap->offset + vattr.va_size; break; case L_SET: fp->f_offset = uap->offset; break; default: return (EINVAL); } *(off_t *)retval = fp->f_offset; return (0); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message