From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Mon, 1 Oct 2018 11:55:07 -0600 Subject: [U-Boot] [PATCH 02/15] sandbox: Support file truncation with os_open() In-Reply-To: <20181001175520.239554-1-sjg@chromium.org> References: <20181001175520.239554-1-sjg@chromium.org> Message-ID: <20181001175520.239554-3-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de At present files are not truncated on writing. This is a useful feature. Add support for this. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 2 ++ include/os.h | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 071e2074ef4..2d20cfe1fa6 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 7116f875780..9e3a561b65e 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 -- 2.19.0.605.g01d371f741-goog