]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sandbox: add lseek helper
authorMike Frysinger <vapier@gentoo.org>
Tue, 25 Oct 2011 11:02:58 +0000 (13:02 +0200)
committerMike Frysinger <vapier@gentoo.org>
Mon, 12 Mar 2012 15:03:42 +0000 (11:03 -0400)
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>
arch/sandbox/cpu/os.c
include/os.h

index 093e7dc7ad3fa31b9be4d1c0b62ecd7e759296fe..f6d0e8457d1651931a5403ba2e8fa3a04ee4eca6 100644 (file)
@@ -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);
index c17a8a52ab3266c348568fb583005bcca6636bac..f74766d16c61a422a5f21620f3d49a820478c637 100644 (file)
@@ -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
  *