- off = _sysio_lseek(fd, offset, whence);
- if (off < 0)
- SYSIO_INTERFACE_RETURN((off64_t )-1, (int )off);
- rtn = (off64_t )off;
- assert(rtn == off);
- SYSIO_INTERFACE_RETURN(rtn, 0);
+ fil = _sysio_fd_find(fd);
+ if (!fil)
+ SYSIO_INTERFACE_RETURN((off64_t )-1, -EBADF);
+ off = _sysio_lseek(fil, offset, whence, _SEEK_MAX(fil));
+ SYSIO_INTERFACE_RETURN(off < 0 ? (off64_t )-1 : off,
+ off < 0 ? (int )off : 0);
+