open: Check flags, and use _open2 if applicable.

* lib/linux/open.c (open): Check flags; use _open2.
This commit is contained in:
Danny Milosavljevic 2019-07-02 03:36:18 +02:00 committed by Jan Nieuwenhuizen
parent 3943155a64
commit 5a2a00f4e8
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -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);
}