From: Simon Glass Date: Mon, 1 Oct 2018 17:55:07 +0000 (-0600) Subject: sandbox: Support file truncation with os_open() X-Git-Tag: v2018.11-rc2~7^2~55 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=50b288aca324649fb5b357ce75972a5261cf94fc;p=oweals%2Fu-boot.git 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 --- diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index d4d6d78dc7..1d87a53843 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -85,6 +85,8 @@ int os_open(const char *pathname, int os_flags) if (os_flags & OS_O_CREAT) flags |= O_CREAT; + if (os_flags & OS_O_TRUNC) + flags |= O_TRUNC; return open(pathname, flags, 0777); } diff --git a/include/os.h b/include/os.h index 7116f87578..9e3a561b65 100644 --- a/include/os.h +++ b/include/os.h @@ -75,6 +75,7 @@ int os_open(const char *pathname, int flags); #define OS_O_RDWR 2 #define OS_O_MASK 3 /* Mask for read/write flags */ #define OS_O_CREAT 0100 +#define OS_O_TRUNC 01000 /** * Access to the OS close() system call