From a36d06a84568d0e9eab610ba667971fd30500801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 21 Oct 2016 20:48:18 +0200 Subject: [PATCH] memtool: let mw create the target file if it doesn't exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König --- memtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memtool.c b/memtool.c index 5603d35..28d886e 100644 --- a/memtool.c +++ b/memtool.c @@ -208,7 +208,8 @@ static void *memmap(const char *file, off_t addr, size_t *size, int readonly) if (pagesize < 0) pagesize = 4096; - memfd = open(file, readonly ? O_RDONLY : O_RDWR); + memfd = open(file, readonly ? O_RDONLY : (O_RDWR | O_CREAT), + S_IRUSR | S_IWUSR); if (memfd < 0) { perror("open"); return NULL;