74dff7bbf36077176a7df813b5fdba11b967a184
[openwrt/svn-archive/archive.git] / toolchain / uClibc / patches / 160-add_openat_and_friends.patch
1 Index: uClibc-0.9.29/libc/sysdeps/linux/common/openat.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ uClibc-0.9.29/libc/sysdeps/linux/common/openat.c 2008-10-27 12:59:25.000000000 +0100
5 @@ -0,0 +1,41 @@
6 +/* vi: set sw=4 ts=4: */
7 +/*
8 + * openat() for uClibc
9 + *
10 + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
11 + *
12 + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
13 + */
14 +
15 +#include <sys/syscall.h>
16 +#include <stdlib.h>
17 +#include <stdarg.h>
18 +#include <fcntl.h>
19 +#include <string.h>
20 +#include <sys/param.h>
21 +
22 +extern __typeof(openat) __libc_openat;
23 +
24 +#define __NR___syscall_openat __NR_openat
25 +static inline _syscall4(int, __syscall_openat, int, fd, const char *, file,
26 + int, flags, __kernel_mode_t, mode);
27 +
28 +libc_hidden_proto(__libc_openat)
29 +int __libc_openat(int fd, const char *file, int oflag, ...)
30 +{
31 + mode_t mode = 0;
32 +
33 + if (oflag & O_CREAT) {
34 + va_list arg;
35 + va_start (arg, oflag);
36 + mode = va_arg (arg, mode_t);
37 + va_end (arg);
38 + }
39 +
40 + return __syscall_openat(fd, file, oflag, mode);
41 +}
42 +libc_hidden_def(__libc_openat)
43 +
44 +libc_hidden_proto(openat)
45 +weak_alias(__libc_openat,openat)
46 +libc_hidden_weak(openat)
47 Index: uClibc-0.9.29/include/fcntl.h
48 ===================================================================
49 --- uClibc-0.9.29.orig/include/fcntl.h 2008-10-27 12:52:04.000000000 +0100
50 +++ uClibc-0.9.29/include/fcntl.h 2008-10-27 13:08:11.000000000 +0100
51 @@ -56,7 +56,7 @@
52 # define SEEK_END 2 /* Seek from end of file. */
53 #endif /* XPG */
54
55 -#if 0 /*def __USE_GNU*/
56 +#ifdef __USE_GNU
57 # define AT_FDCWD -100 /* Special value used to indicate
58 openat should use the current
59 working directory. */
60 @@ -103,7 +103,7 @@
61 extern int open64 (__const char *__file, int __oflag, ...) __nonnull ((1));
62 #endif
63
64 -#if 0 /*def __USE_GNU*/
65 +#ifdef __USE_GNU
66 /* Similar to OPEN but a relative path name is interpreted relative to
67 the directory for which FD is a descriptor.
68