Date: Tue, 31 Mar 1998 01:53:05 +0200 From: Kent Boortz <kent@erlang.ericsson.se> To: freebsd-bugs@FreeBSD.ORG Cc: kent@erlang.ericsson.se Subject: lseek bug? Message-ID: <19980331015305F.kent@erlang.ericsson.se>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980331015305F.kent>