Browse Source

sandbox: Support file truncation with os_open()

At present files are not truncated on writing. This is a useful feature.
Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Simon Glass 6 years ago
parent
commit
50b288aca3
2 changed files with 3 additions and 0 deletions
  1. 2 0
      arch/sandbox/cpu/os.c
  2. 1 0
      include/os.h

+ 2 - 0
arch/sandbox/cpu/os.c

@@ -85,6 +85,8 @@ int os_open(const char *pathname, int os_flags)
 
 
 	if (os_flags & OS_O_CREAT)
 	if (os_flags & OS_O_CREAT)
 		flags |= O_CREAT;
 		flags |= O_CREAT;
+	if (os_flags & OS_O_TRUNC)
+		flags |= O_TRUNC;
 
 
 	return open(pathname, flags, 0777);
 	return open(pathname, flags, 0777);
 }
 }

+ 1 - 0
include/os.h

@@ -75,6 +75,7 @@ int os_open(const char *pathname, int flags);
 #define OS_O_RDWR	2
 #define OS_O_RDWR	2
 #define OS_O_MASK	3	/* Mask for read/write flags */
 #define OS_O_MASK	3	/* Mask for read/write flags */
 #define OS_O_CREAT	0100
 #define OS_O_CREAT	0100
+#define OS_O_TRUNC	01000
 
 
 /**
 /**
  * Access to the OS close() system call
  * Access to the OS close() system call