
For a namespace clean function, implement
_lseek, otherwise implement
lseek. The detailed implementation will
depend on the file handling functionality available.
A minimal implementation has no file system, so this function can return 0, indicating that the only stream (standard output) is positioned at the start of file.
#include <errno.h>
#undef errno
extern int errno;
int
_lseek (int file,
int offset,
int whence)
{
return 0;
} /* _lseek () */
The OpenRISC 1000 version is a little more detailed, returning zero only
if the stream is standard output, standard error or (for the
UART version of the BSP) standard input. Otherwise -1 is
returned and an appropriate error code set in
errno.
#include <errno.h>
#include <unistd.h>
#undef errno
extern int errno;
int
_lseek (int file,
int offset,
int whence)
{
if ((STDOUT_FILENO == file) || (STDERR_FILENO == file))
{
return 0;
}
else
{
errno = EBADF;
return (long) -1;
}
} /* _lseek () */
The UART version is almost identical, but also succeeds for standard input.
