From 5a2a00f4e848601a0a7a539aa9d858051ac9afc4 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Tue, 2 Jul 2019 03:36:18 +0200 Subject: [PATCH] open: Check flags, and use _open2 if applicable. * lib/linux/open.c (open): Check flags; use _open2. --- lib/posix/open.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/posix/open.c b/lib/posix/open.c index 256f2f13..ad76297d 100644 --- a/lib/posix/open.c +++ b/lib/posix/open.c @@ -32,10 +32,15 @@ _open2 (char const *file_name, int flags) int open (char const *file_name, int flags, ...) { - va_list ap; - va_start (ap, flags); - int mask = va_arg (ap, int); - int r = _open3 (file_name, flags, mask); - va_end (ap); - return r; + if (flags & O_CREAT) + { + va_list ap; + va_start (ap, flags); + int mask = va_arg (ap, int); + int r = _open3 (file_name, flags, mask); + va_end (ap); + return r; + } + else + return _open2(file_name, flags); }