7ba12996beb77cefa90862b66cbb48d2a27933e6
[openwrt/staging/ansuel.git] / tools / fakeroot / patches / 100-portability.patch
1 --- a/libfakeroot.c
2 +++ b/libfakeroot.c
3 @@ -112,8 +112,16 @@
4 #define INT_SEND_STAT(a,b) SEND_STAT(a,b,_STAT_VER)
5 #define INT_SEND_GET_XATTR(a,b) SEND_GET_XATTR(a,b,_STAT_VER)
6 #define INT_SEND_GET_STAT(a,b) SEND_GET_STAT(a,b)
7 +
8 +/* 10.10 uses id_t in getpriority/setpriority calls, so pretend
9 + id_t is used everywhere, just happens to be int on some OSes */
10 +#ifndef _ID_T
11 +#define _ID_T
12 +typedef int id_t;
13 +#endif
14 #endif
15
16 +#include <sys/types.h>
17 #include <stdlib.h>
18 #include <sys/ipc.h>
19 #include <sys/msg.h>
20 @@ -125,7 +133,6 @@
21 #include <unistd.h>
22 #include <dirent.h>
23 #include <errno.h>
24 -#include <sys/types.h>
25 #ifdef HAVE_SYS_ACL_H
26 #include <sys/acl.h>
27 #endif /* HAVE_SYS_ACL_H */
28 @@ -188,6 +195,15 @@ extern int unsetenv (const char *name);
29 #undef __lxstat64
30 #undef _FILE_OFFSET_BITS
31
32 +
33 +#ifndef AT_EMPTY_PATH
34 +#define AT_EMPTY_PATH 0
35 +#endif
36 +
37 +#ifndef AT_NO_AUTOMOUNT
38 +#define AT_NO_AUTOMOUNT 0
39 +#endif
40 +
41 /*
42 // next_wrap_st:
43 // this structure is used in next_wrap, which is defined in
44 @@ -1911,7 +1927,7 @@ ssize_t fremovexattr(int fd, const char
45 }
46 #endif /* HAVE_FREMOVEXATTR */
47
48 -int setpriority(int which, int who, int prio){
49 +int setpriority(int which, id_t who, int prio){
50 if (fakeroot_disabled)
51 return next_setpriority(which, who, prio);
52 next_setpriority(which, who, prio);
53 @@ -2520,3 +2536,19 @@ int sysinfo(int command, char *buf, long
54 }
55 }
56 #endif
57 +
58 +#ifdef HAVE_OPENAT
59 +int openat(int dir_fd, const char *pathname, int flags, ...)
60 +{
61 + mode_t mode;
62 +
63 + if (flags & O_CREAT) {
64 + va_list args;
65 + va_start(args, flags);
66 + mode = va_arg(args, int);
67 + va_end(args);
68 + }
69 +
70 + return next_openat(dir_fd, pathname, flags, mode);
71 +}
72 +#endif
73 --- a/wrapfunc.inp
74 +++ b/wrapfunc.inp
75 @@ -146,7 +146,7 @@ setfsgid;gid_t;(gid_t fsgid);(fsgid)
76 initgroups;int;(const char *user, INITGROUPS_SECOND_ARG group);(user, group)
77 getgroups;int;(int size, gid_t list[]);(size, list)
78 setgroups;int;(SETGROUPS_SIZE_TYPE size, const gid_t *list);(size, list)
79 -setpriority;int;(int which, int who, int prio);(which, who, prio)
80 +setpriority;int;(int which, id_t who, int prio);(which, who, prio)
81 #ifdef HAVE_CAPSET
82 capset;int;(cap_user_header_t hdrp, const cap_user_data_t datap);(hdrp, datap)
83 #endif /* HAVE_CAPSET */
84 @@ -198,7 +198,7 @@ fchownat;int;(int dir_fd, const char *pa
85 mkdirat;int;(int dir_fd, const char *pathname, mode_t mode);(dir_fd, pathname, mode)
86 #endif /* HAVE_MKDIRAT */
87 #ifdef HAVE_OPENAT
88 -openat;int;(int dir_fd, const char *pathname, int flags);(dir_fd, pathname, flags)
89 +openat;int;(int dir_fd, const char *pathname, int flags, mode_t mode);(dir_fd, pathname, flags, mode);;(int dir_fd, const char *pathname, int flags, ...)
90 #endif /* HAVE_OPENAT */
91 #ifdef HAVE_RENAMEAT
92 renameat;int;(int olddir_fd, const char *oldpath, int newdir_fd, const char *newpath);(olddir_fd, oldpath, newdir_fd, newpath)
93 --- a/wrapawk_macosx
94 +++ b/wrapawk_macosx
95 @@ -46,26 +46,30 @@ BEGIN{
96 argtype=$3;
97 argname=$4;
98 MACRO=$5;
99 + argtype_def=$6
100 + if(!argtype_def) {
101 + argtype_def = argtype
102 + }
103 if(MACRO){
104 print "extern " ret " MY_DEF(" name ")" argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
105 print "INTERPOSE(MY_DEF(" name "_RAW)," name "_RAW);" > structfile;
106 print "#undef " name > deffile
107 print "#define " name " MY_DEF(" name "_RAW)" > deffile
108
109 - print "extern " ret, name, argtype ";" > tmpffile;
110 + print "extern " ret, name, argtype_def ";" > tmpffile;
111 print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " __attribute__((always_inline));" > tmpffile;
112 print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " {" > tmpffile;
113 print " return " name, argname ";" > tmpffile;
114 print "}" > tmpffile;
115 print "" > tmpffile;
116 } else {
117 - print "extern " ret " my_" name, argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
118 + print "extern " ret " my_" name, argtype_def " __attribute__((visibility(\"hidden\")));" > headerfile;
119 print "#undef " name > structfile;
120 print "INTERPOSE(my_" name "," name ");" > structfile;
121 print "#define " name " my_" name > structfile
122 print "#define " name " my_" name > deffile
123
124 - print "extern " ret, name, argtype ";" > tmpffile;
125 + print "extern " ret, name, argtype_def ";" > tmpffile;
126 if(argname){
127 print "static __inline__ " ret " next_" name, argtype " __attribute__((always_inline));" > tmpffile;
128 print "static __inline__ " ret " next_" name, argtype " {" > tmpffile;
129 --- a/configure.ac
130 +++ b/configure.ac
131 @@ -146,6 +146,7 @@ for first in size_t int; do
132 #include <sys/types.h>
133 #endif
134 #include <unistd.h>
135 +#include <stdio.h>
136 #ifdef HAVE_GRP_H
137 #include <grp.h>
138 #endif