diff mbox

[U-Boot,1/6] sandbox: add lseek helper

Message ID 1327300228-26386-2-git-send-email-vapier@gentoo.org
State Accepted
Delegated to: Mike Frysinger
Headers show

Commit Message

Mike Frysinger Jan. 23, 2012, 6:30 a.m. UTC
Follow up patches want to be able to seek fd's.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/sandbox/cpu/os.c |    5 +++++
 include/os.h          |   10 ++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

Comments

Simon Glass Jan. 23, 2012, 6:51 a.m. UTC | #1
Hi Mike,

On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> Follow up patches want to be able to seek fd's.
>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
>  arch/sandbox/cpu/os.c |    5 +++++
>  include/os.h          |   10 ++++++++++
>  2 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
> index 093e7dc..6e257ff 100644
> --- a/arch/sandbox/cpu/os.c
> +++ b/arch/sandbox/cpu/os.c
> @@ -45,6 +45,11 @@ 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)
> +{
> +       return lseek(fd, offset, whence);
> +}

I think we need some sort of #define setup for the whence parameter in
the header file, like I did with open().

> +
>  int os_open(const char *pathname, int flags)
>  {
>        return open(pathname, flags);
> diff --git a/include/os.h b/include/os.h
> index c17a8a5..d182f40 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -49,6 +49,16 @@ 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

Document the values of this param, since people can't really assume
the mirror lseek() unless we tell them.

> + * \return new file offset
> + */
> +off_t os_lseek(int fd, off_t offset, int whence);
> +
> +/**
>  * Access to the OS open() system call
>  *
>  * \param pathname     Pathname of file to open
> --
> 1.7.8.3
>

Regards,
Simon
diff mbox

Patch

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 093e7dc..6e257ff 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -45,6 +45,11 @@  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)
+{
+	return lseek(fd, offset, whence);
+}
+
 int os_open(const char *pathname, int flags)
 {
 	return open(pathname, flags);
diff --git a/include/os.h b/include/os.h
index c17a8a5..d182f40 100644
--- a/include/os.h
+++ b/include/os.h
@@ -49,6 +49,16 @@  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
+ * \return new file offset
+ */
+off_t os_lseek(int fd, off_t offset, int whence);
+
+/**
  * Access to the OS open() system call
  *
  * \param pathname	Pathname of file to open