diff options
author | Simon Glass <sjg@chromium.org> | 2012-02-20 23:56:58 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-03-12 11:03:42 -0400 |
commit | d9165153caea9f342410ed3ac87cb68768ebec78 (patch) | |
tree | 9f43ac048461b4788fc15805802299bf3a88d998 /arch | |
parent | 7b06b66cd7f9f4d33cfd3e68046c094a43024cda (diff) | |
download | u-boot-imx-d9165153caea9f342410ed3ac87cb68768ebec78.zip u-boot-imx-d9165153caea9f342410ed3ac87cb68768ebec78.tar.gz u-boot-imx-d9165153caea9f342410ed3ac87cb68768ebec78.tar.bz2 |
sandbox: add flags for open() call
This provides a way for callers to create files for writing. The flags
are translated at runtime, for the ones we support.
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sandbox/cpu/os.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index f6d0e84..cb469e0 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -58,9 +58,29 @@ off_t os_lseek(int fd, off_t offset, int whence) return lseek(fd, offset, whence); } -int os_open(const char *pathname, int flags) +int os_open(const char *pathname, int os_flags) { - return open(pathname, flags); + int flags; + + switch (os_flags & OS_O_MASK) { + case OS_O_RDONLY: + default: + flags = O_RDONLY; + break; + + case OS_O_WRONLY: + flags = O_WRONLY; + break; + + case OS_O_RDWR: + flags = O_RDWR; + break; + } + + if (os_flags & OS_O_CREAT) + flags |= O_CREAT; + + return open(pathname, flags, 0777); } int os_close(int fd) |