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>
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 @@
 	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)