OSDN Git Service

b4bef3c6308ce889d125a0773072435500f8e264
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / open.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * open() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <sys/syscall.h>
11 #include <stdlib.h>
12 #include <stdarg.h>
13 #include <fcntl.h>
14 #include <string.h>
15 #include <sys/param.h>
16
17 extern __typeof(open) __libc_open;
18 extern __typeof(creat) __libc_creat;
19
20 #define __NR___syscall_open __NR_open
21 static inline _syscall3(int, __syscall_open, const char *, file,
22                 int, flags, __kernel_mode_t, mode);
23
24 libc_hidden_proto(__libc_open)
25 int __libc_open(const char *file, int oflag, ...)
26 {
27         mode_t mode = 0;
28
29         if (oflag & O_CREAT) {
30                 va_list arg;
31                 va_start (arg, oflag);
32                 mode = va_arg (arg, mode_t);
33                 va_end (arg);
34         }
35
36         return __syscall_open(file, oflag, mode);
37 }
38 libc_hidden_def(__libc_open)
39
40 libc_hidden_proto(open)
41 weak_alias(__libc_open,open)
42 libc_hidden_weak(open)
43
44 int __libc_creat(const char *file, mode_t mode)
45 {
46         return __libc_open(file, O_WRONLY | O_CREAT | O_TRUNC, mode);
47 }
48 weak_alias(__libc_creat,creat)