From 6334e558ab33ee1e54ed33740881a2798c5915c2 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 21 Jan 2004 23:27:48 +0000 Subject: Split up syscalls.c, since it had grown to be quite large and ugly. -Erik --- libc/sysdeps/linux/common/open.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 libc/sysdeps/linux/common/open.c (limited to 'libc/sysdeps/linux/common/open.c') diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c new file mode 100644 index 000000000..a027e9e21 --- /dev/null +++ b/libc/sysdeps/linux/common/open.c @@ -0,0 +1,41 @@ +/* vi: set sw=4 ts=4: */ +/* + * open() for uClibc + * + * Copyright (C) 2000-2004 by Erik Andersen + * + * GNU Library General Public License (LGPL) version 2 or later. + */ + +#include "syscalls.h" +#include +#include +#include +#include +#include + +#define __NR___syscall_open __NR_open +static inline _syscall3(int, __syscall_open, const char *, file, + int, flags, __kernel_mode_t, mode); + +int __libc_open(const char *file, int flags, ...) +{ + /* gcc may warn about mode being uninitialized. + * Just ignore that, since gcc is wrong. */ + mode_t mode; + + if (flags & O_CREAT) { + va_list ap; + + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } + return __syscall_open(file, flags, mode); +} +weak_alias(__libc_open, open); + +int creat(const char *file, mode_t mode) +{ + return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode); +} -- cgit v1.2.3