1 |
commit: 35459036a204bbf147b11631317aff9eb1804573 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Nov 6 03:38:02 2021 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 6 03:38:02 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=35459036 |
7 |
|
8 |
libsandbox: reduce & inline the __64_{pre,post}.h headers |
9 |
|
10 |
Now that we use 64-bit stat & lstat explicitly everywhere, we don't |
11 |
need these dynamic redirects for 64-bit wrappers. The off_t define |
12 |
is only used by one file anymore too, but we can inline that. |
13 |
|
14 |
That leaves the SB64 define which we use inconsistently in places. |
15 |
In some 64-bit modules that include the 32-bit, we use SB64 to switch |
16 |
between the 64-bit & 32-bit APIs. In other places, the 64-bit file |
17 |
is responsible for redefining the few relevant APIs. Let's switch |
18 |
all the files away from SB64 and to defining the single thing that |
19 |
the 64-bit module needs directly. It's either the same or fewer LOC |
20 |
this way, and doesn't seem any more or less difficult to maintain. |
21 |
The __64_{pre,post}.h & SB64 define weren't easily discoverable. |
22 |
|
23 |
Bug: https://bugs.gentoo.org/583282 |
24 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
25 |
|
26 |
libsandbox/pre_check_openat64.c | 2 -- |
27 |
libsandbox/wrapper-funcs/__64_post.h | 4 ---- |
28 |
libsandbox/wrapper-funcs/__64_pre.h | 4 ---- |
29 |
libsandbox/wrapper-funcs/__open64_2.c | 4 ++-- |
30 |
libsandbox/wrapper-funcs/__openat64_2.c | 4 ++-- |
31 |
libsandbox/wrapper-funcs/__openat_2.c | 6 +----- |
32 |
libsandbox/wrapper-funcs/fopen.c | 7 +------ |
33 |
libsandbox/wrapper-funcs/fopen64.c | 4 ++-- |
34 |
libsandbox/wrapper-funcs/fopen64_pre_check.c | 2 -- |
35 |
libsandbox/wrapper-funcs/open64.c | 4 ++-- |
36 |
libsandbox/wrapper-funcs/openat.c | 6 +----- |
37 |
libsandbox/wrapper-funcs/openat64.c | 4 ++-- |
38 |
libsandbox/wrapper-funcs/truncate.c | 4 +++- |
39 |
libsandbox/wrapper-funcs/truncate64.c | 3 +-- |
40 |
14 files changed, 17 insertions(+), 41 deletions(-) |
41 |
|
42 |
diff --git a/libsandbox/pre_check_openat64.c b/libsandbox/pre_check_openat64.c |
43 |
index 9420c98..d4dbe97 100644 |
44 |
--- a/libsandbox/pre_check_openat64.c |
45 |
+++ b/libsandbox/pre_check_openat64.c |
46 |
@@ -10,8 +10,6 @@ |
47 |
#include "libsandbox.h" |
48 |
#include "wrappers.h" |
49 |
|
50 |
-#include "wrapper-funcs/__64_pre.h" |
51 |
#define sb_openat_pre_check sb_openat64_pre_check |
52 |
#include "pre_check_openat.c" |
53 |
#undef sb_openat_pre_check |
54 |
-#include "wrapper-funcs/__64_post.h" |
55 |
|
56 |
diff --git a/libsandbox/wrapper-funcs/__64_post.h b/libsandbox/wrapper-funcs/__64_post.h |
57 |
deleted file mode 100644 |
58 |
index 82d2a16..0000000 |
59 |
--- a/libsandbox/wrapper-funcs/__64_post.h |
60 |
+++ /dev/null |
61 |
@@ -1,4 +0,0 @@ |
62 |
-#undef SB64 |
63 |
-#undef stat |
64 |
-#undef lstat |
65 |
-#undef off_t |
66 |
|
67 |
diff --git a/libsandbox/wrapper-funcs/__64_pre.h b/libsandbox/wrapper-funcs/__64_pre.h |
68 |
deleted file mode 100644 |
69 |
index 0b34b25..0000000 |
70 |
--- a/libsandbox/wrapper-funcs/__64_pre.h |
71 |
+++ /dev/null |
72 |
@@ -1,4 +0,0 @@ |
73 |
-#define SB64 |
74 |
-#define stat stat64 |
75 |
-#define lstat lstat64 |
76 |
-#define off_t off64_t |
77 |
|
78 |
diff --git a/libsandbox/wrapper-funcs/__open64_2.c b/libsandbox/wrapper-funcs/__open64_2.c |
79 |
index bdbd5d8..52daff1 100644 |
80 |
--- a/libsandbox/wrapper-funcs/__open64_2.c |
81 |
+++ b/libsandbox/wrapper-funcs/__open64_2.c |
82 |
@@ -5,6 +5,6 @@ |
83 |
* Licensed under the GPL-2 |
84 |
*/ |
85 |
|
86 |
-#include "__64_pre.h" |
87 |
+#define sb_openat_pre_check sb_openat64_pre_check |
88 |
#include "__open_2.c" |
89 |
-#include "__64_post.h" |
90 |
+#undef sb_openat_pre_check |
91 |
|
92 |
diff --git a/libsandbox/wrapper-funcs/__openat64_2.c b/libsandbox/wrapper-funcs/__openat64_2.c |
93 |
index 445164a..ccc4fdd 100644 |
94 |
--- a/libsandbox/wrapper-funcs/__openat64_2.c |
95 |
+++ b/libsandbox/wrapper-funcs/__openat64_2.c |
96 |
@@ -5,6 +5,6 @@ |
97 |
* Licensed under the GPL-2 |
98 |
*/ |
99 |
|
100 |
-#include "__64_pre.h" |
101 |
+#define sb_openat_pre_check sb_openat64_pre_check |
102 |
#include "__openat_2.c" |
103 |
-#include "__64_post.h" |
104 |
+#undef sb_openat_pre_check |
105 |
|
106 |
diff --git a/libsandbox/wrapper-funcs/__openat_2.c b/libsandbox/wrapper-funcs/__openat_2.c |
107 |
index 4549a23..f2e85ea 100644 |
108 |
--- a/libsandbox/wrapper-funcs/__openat_2.c |
109 |
+++ b/libsandbox/wrapper-funcs/__openat_2.c |
110 |
@@ -13,11 +13,7 @@ |
111 |
# define dirfd AT_FDCWD |
112 |
#endif |
113 |
|
114 |
-#ifdef SB64 |
115 |
-# define WRAPPER_PRE_CHECKS() sb_openat64_pre_check(STRING_NAME, pathname, dirfd, flags) |
116 |
-#else |
117 |
-# define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) |
118 |
-#endif |
119 |
+#define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) |
120 |
|
121 |
#include "__wrapper_simple.c" |
122 |
|
123 |
|
124 |
diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c |
125 |
index ce2fdf3..5d36ffa 100644 |
126 |
--- a/libsandbox/wrapper-funcs/fopen.c |
127 |
+++ b/libsandbox/wrapper-funcs/fopen.c |
128 |
@@ -10,11 +10,6 @@ |
129 |
#define WRAPPER_SAFE() SB_SAFE_OPEN_CHAR(pathname, mode) |
130 |
#define WRAPPER_RET_TYPE FILE * |
131 |
#define WRAPPER_RET_DEFAULT NULL |
132 |
- |
133 |
-#ifdef SB64 |
134 |
-# define WRAPPER_PRE_CHECKS() sb_fopen64_pre_check(STRING_NAME, pathname, mode) |
135 |
-#else |
136 |
-# define WRAPPER_PRE_CHECKS() sb_fopen_pre_check(STRING_NAME, pathname, mode) |
137 |
-#endif |
138 |
+#define WRAPPER_PRE_CHECKS() sb_fopen_pre_check(STRING_NAME, pathname, mode) |
139 |
|
140 |
#include "__wrapper_simple.c" |
141 |
|
142 |
diff --git a/libsandbox/wrapper-funcs/fopen64.c b/libsandbox/wrapper-funcs/fopen64.c |
143 |
index 8e0cdb0..c9b42ef 100644 |
144 |
--- a/libsandbox/wrapper-funcs/fopen64.c |
145 |
+++ b/libsandbox/wrapper-funcs/fopen64.c |
146 |
@@ -5,6 +5,6 @@ |
147 |
* Licensed under the GPL-2 |
148 |
*/ |
149 |
|
150 |
-#include "__64_pre.h" |
151 |
+#define sb_fopen_pre_check sb_fopen64_pre_check |
152 |
#include "fopen.c" |
153 |
-#include "__64_post.h" |
154 |
+#undef sb_fopen_pre_check |
155 |
|
156 |
diff --git a/libsandbox/wrapper-funcs/fopen64_pre_check.c b/libsandbox/wrapper-funcs/fopen64_pre_check.c |
157 |
index 3f7a737..4dbd171 100644 |
158 |
--- a/libsandbox/wrapper-funcs/fopen64_pre_check.c |
159 |
+++ b/libsandbox/wrapper-funcs/fopen64_pre_check.c |
160 |
@@ -5,8 +5,6 @@ |
161 |
* Licensed under the GPL-2 |
162 |
*/ |
163 |
|
164 |
-#include "__64_pre.h" |
165 |
#define sb_fopen_pre_check sb_fopen64_pre_check |
166 |
#include "fopen_pre_check.c" |
167 |
#undef sb_fopen_pre_check |
168 |
-#include "__64_post.h" |
169 |
|
170 |
diff --git a/libsandbox/wrapper-funcs/open64.c b/libsandbox/wrapper-funcs/open64.c |
171 |
index 622b8ea..8b03ea8 100644 |
172 |
--- a/libsandbox/wrapper-funcs/open64.c |
173 |
+++ b/libsandbox/wrapper-funcs/open64.c |
174 |
@@ -5,6 +5,6 @@ |
175 |
* Licensed under the GPL-2 |
176 |
*/ |
177 |
|
178 |
-#include "__64_pre.h" |
179 |
+#define sb_openat_pre_check sb_openat64_pre_check |
180 |
#include "open.c" |
181 |
-#include "__64_post.h" |
182 |
+#undef sb_openat_pre_check |
183 |
|
184 |
diff --git a/libsandbox/wrapper-funcs/openat.c b/libsandbox/wrapper-funcs/openat.c |
185 |
index 846c63f..d09e63d 100644 |
186 |
--- a/libsandbox/wrapper-funcs/openat.c |
187 |
+++ b/libsandbox/wrapper-funcs/openat.c |
188 |
@@ -16,11 +16,7 @@ |
189 |
# define dirfd AT_FDCWD |
190 |
#endif |
191 |
|
192 |
-#ifdef SB64 |
193 |
-# define WRAPPER_PRE_CHECKS() sb_openat64_pre_check(STRING_NAME, pathname, dirfd, flags) |
194 |
-#else |
195 |
-# define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) |
196 |
-#endif |
197 |
+#define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) |
198 |
|
199 |
#define WRAPPER_SAFE_POST_EXPAND \ |
200 |
int mode = 0; \ |
201 |
|
202 |
diff --git a/libsandbox/wrapper-funcs/openat64.c b/libsandbox/wrapper-funcs/openat64.c |
203 |
index b410af2..66c2089 100644 |
204 |
--- a/libsandbox/wrapper-funcs/openat64.c |
205 |
+++ b/libsandbox/wrapper-funcs/openat64.c |
206 |
@@ -5,6 +5,6 @@ |
207 |
* Licensed under the GPL-2 |
208 |
*/ |
209 |
|
210 |
-#include "__64_pre.h" |
211 |
+#define sb_openat_pre_check sb_openat64_pre_check |
212 |
#include "openat.c" |
213 |
-#include "__64_post.h" |
214 |
+#undef sb_openat_pre_check |
215 |
|
216 |
diff --git a/libsandbox/wrapper-funcs/truncate.c b/libsandbox/wrapper-funcs/truncate.c |
217 |
index b0b5674..2bfbec7 100644 |
218 |
--- a/libsandbox/wrapper-funcs/truncate.c |
219 |
+++ b/libsandbox/wrapper-funcs/truncate.c |
220 |
@@ -5,7 +5,9 @@ |
221 |
* Licensed under the GPL-2 |
222 |
*/ |
223 |
|
224 |
-#define WRAPPER_ARGS_PROTO const char *path, off_t length |
225 |
+#ifndef WRAPPER_ARGS_PROTO |
226 |
+# define WRAPPER_ARGS_PROTO const char *path, off_t length |
227 |
+#endif |
228 |
#define WRAPPER_ARGS path, length |
229 |
#define WRAPPER_SAFE() SB_SAFE(path) |
230 |
#include "__wrapper_simple.c" |
231 |
|
232 |
diff --git a/libsandbox/wrapper-funcs/truncate64.c b/libsandbox/wrapper-funcs/truncate64.c |
233 |
index a06b895..6e2266d 100644 |
234 |
--- a/libsandbox/wrapper-funcs/truncate64.c |
235 |
+++ b/libsandbox/wrapper-funcs/truncate64.c |
236 |
@@ -5,6 +5,5 @@ |
237 |
* Licensed under the GPL-2 |
238 |
*/ |
239 |
|
240 |
-#include "__64_pre.h" |
241 |
+#define WRAPPER_ARGS_PROTO const char *path, off64_t length |
242 |
#include "truncate.c" |
243 |
-#include "__64_post.h" |