mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
sandbox: add lseek helper
Follow up patches want to be able to seek fd's. Acked-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
4f345d5673
commit
e2dcefcb40
2 changed files with 28 additions and 0 deletions
|
@ -45,6 +45,19 @@ ssize_t os_write(int fd, const void *buf, size_t count)
|
|||
return write(fd, buf, count);
|
||||
}
|
||||
|
||||
off_t os_lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
if (whence == OS_SEEK_SET)
|
||||
whence = SEEK_SET;
|
||||
else if (whence == OS_SEEK_CUR)
|
||||
whence = SEEK_CUR;
|
||||
else if (whence == OS_SEEK_END)
|
||||
whence = SEEK_END;
|
||||
else
|
||||
os_exit(1);
|
||||
return lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
int os_open(const char *pathname, int flags)
|
||||
{
|
||||
return open(pathname, flags);
|
||||
|
|
15
include/os.h
15
include/os.h
|
@ -48,6 +48,21 @@ ssize_t os_read(int fd, void *buf, size_t count);
|
|||
*/
|
||||
ssize_t os_write(int fd, const void *buf, size_t count);
|
||||
|
||||
/**
|
||||
* Access to the OS lseek() system call
|
||||
*
|
||||
* \param fd File descriptor as returned by os_open()
|
||||
* \param offset File offset (based on whence)
|
||||
* \param whence Position offset is relative to (see below)
|
||||
* \return new file offset
|
||||
*/
|
||||
off_t os_lseek(int fd, off_t offset, int whence);
|
||||
|
||||
/* Defines for "whence" in os_lseek() */
|
||||
#define OS_SEEK_SET 0
|
||||
#define OS_SEEK_CUR 1
|
||||
#define OS_SEEK_END 2
|
||||
|
||||
/**
|
||||
* Access to the OS open() system call
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue