tools: add fakeroot
[openwrt/staging/ldir.git] / tools / fakeroot / patches / 100-portability.patch
1 --- a/libfakeroot.c
2 +++ b/libfakeroot.c
3 @@ -110,8 +110,16 @@
4 #define INT_NEXT_FSTATAT(a,b,c,d) NEXT_FSTATAT(_STAT_VER,a,b,c,d)
5 #define INT_SEND_STAT(a,b) SEND_STAT(a,b,_STAT_VER)
6 #define INT_SEND_GET_XATTR(a,b) SEND_GET_XATTR(a,b,_STAT_VER)
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 @@ -123,7 +131,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 @@ -1894,7 +1901,7 @@ ssize_t fremovexattr(int fd, const char
29 }
30 #endif /* HAVE_FREMOVEXATTR */
31
32 -int setpriority(int which, int who, int prio){
33 +int setpriority(int which, id_t who, int prio){
34 if (fakeroot_disabled)
35 return next_setpriority(which, who, prio);
36 next_setpriority(which, who, prio);
37 @@ -2426,3 +2433,19 @@ int sysinfo(int command, char *buf, long
38 }
39 }
40 #endif
41 +
42 +#ifdef HAVE_OPENAT
43 +int openat(int dir_fd, const char *pathname, int flags, ...)
44 +{
45 + mode_t mode;
46 +
47 + if (flags & O_CREAT) {
48 + va_list args;
49 + va_start(args, flags);
50 + mode = va_arg(args, int);
51 + va_end(args);
52 + }
53 +
54 + return next_openat(dir_fd, pathname, flags, mode);
55 +}
56 +#endif
57 --- a/wrapfunc.inp
58 +++ b/wrapfunc.inp
59 @@ -145,7 +145,7 @@ setfsgid;gid_t;(gid_t fsgid);(fsgid)
60 #endif /* HAVE_SETFSGID */
61 initgroups;int;(const char *user, INITGROUPS_SECOND_ARG group);(user, group)
62 setgroups;int;(SETGROUPS_SIZE_TYPE size, const gid_t *list);(size, list)
63 -setpriority;int;(int which, int who, int prio);(which, who, prio)
64 +setpriority;int;(int which, id_t who, int prio);(which, who, prio)
65 #ifdef HAVE_CAPSET
66 capset;int;(cap_user_header_t hdrp, const cap_user_data_t datap);(hdrp, datap)
67 #endif /* HAVE_CAPSET */
68 @@ -197,7 +197,7 @@ fchownat;int;(int dir_fd, const char *pa
69 mkdirat;int;(int dir_fd, const char *pathname, mode_t mode);(dir_fd, pathname, mode)
70 #endif /* HAVE_MKDIRAT */
71 #ifdef HAVE_OPENAT
72 -openat;int;(int dir_fd, const char *pathname, int flags);(dir_fd, pathname, flags)
73 +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, ...)
74 #endif /* HAVE_OPENAT */
75 #ifdef HAVE_RENAMEAT
76 renameat;int;(int olddir_fd, const char *oldpath, int newdir_fd, const char *newpath);(olddir_fd, oldpath, newdir_fd, newpath)
77 --- a/wrapawk_macosx
78 +++ b/wrapawk_macosx
79 @@ -46,26 +46,30 @@ BEGIN{
80 argtype=$3;
81 argname=$4;
82 MACRO=$5;
83 + argtype_def=$6
84 + if(!argtype_def) {
85 + argtype_def = argtype
86 + }
87 if(MACRO){
88 print "extern " ret " MY_DEF(" name ")" argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
89 print "INTERPOSE(MY_DEF(" name "_RAW)," name "_RAW);" > structfile;
90 print "#undef " name > deffile
91 print "#define " name " MY_DEF(" name "_RAW)" > deffile
92
93 - print "extern " ret, name, argtype ";" > tmpffile;
94 + print "extern " ret, name, argtype_def ";" > tmpffile;
95 print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " __attribute__((always_inline));" > tmpffile;
96 print "static __inline__ " ret " NEXT_" MACRO "_NOARG " argtype " {" > tmpffile;
97 print " return " name, argname ";" > tmpffile;
98 print "}" > tmpffile;
99 print "" > tmpffile;
100 } else {
101 - print "extern " ret " my_" name, argtype " __attribute__((visibility(\"hidden\")));" > headerfile;
102 + print "extern " ret " my_" name, argtype_def " __attribute__((visibility(\"hidden\")));" > headerfile;
103 print "#undef " name > structfile;
104 print "INTERPOSE(my_" name "," name ");" > structfile;
105 print "#define " name " my_" name > structfile
106 print "#define " name " my_" name > deffile
107
108 - print "extern " ret, name, argtype ";" > tmpffile;
109 + print "extern " ret, name, argtype_def ";" > tmpffile;
110 if(argname){
111 print "static __inline__ " ret " next_" name, argtype " __attribute__((always_inline));" > tmpffile;
112 print "static __inline__ " ret " next_" name, argtype " {" > tmpffile;