From d9165153caea9f342410ed3ac87cb68768ebec78 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 20 Feb 2012 23:56:58 -0500 Subject: 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 Signed-off-by: Mike Frysinger --- arch/sandbox/cpu/os.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'arch/sandbox/cpu/os.c') diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index f6d0e8457d..cb469e0510 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) -- cgit v1.2.1