diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-11-05 23:38:02 -0400 |
---|---|---|
committer | Mike Gilbert <floppym@gentoo.org> | 2022-12-30 16:31:43 -0500 |
commit | 784477e6c1e09328b363fc5fea4dd304fe053c04 (patch) | |
tree | a918de282f4984544215a93b2f6c7d9cf2be9e70 | |
parent | change FS calls to use 64-bit interfaces explicitly (diff) | |
download | sandbox-784477e6c1e09328b363fc5fea4dd304fe053c04.tar.gz sandbox-784477e6c1e09328b363fc5fea4dd304fe053c04.tar.bz2 sandbox-784477e6c1e09328b363fc5fea4dd304fe053c04.zip |
libsandbox: reduce & inline the __64_{pre,post}.h headers
Now that we use 64-bit stat & lstat explicitly everywhere, we don't
need these dynamic redirects for 64-bit wrappers. The off_t define
is only used by one file anymore too, but we can inline that.
That leaves the SB64 define which we use inconsistently in places.
In some 64-bit modules that include the 32-bit, we use SB64 to switch
between the 64-bit & 32-bit APIs. In other places, the 64-bit file
is responsible for redefining the few relevant APIs. Let's switch
all the files away from SB64 and to defining the single thing that
the 64-bit module needs directly. It's either the same or fewer LOC
this way, and doesn't seem any more or less difficult to maintain.
The __64_{pre,post}.h & SB64 define weren't easily discoverable.
Bug: https://bugs.gentoo.org/583282
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
(cherry picked from commit 35459036a204bbf147b11631317aff9eb1804573)
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r-- | libsandbox/pre_check_openat64.c | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__64_post.h | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__64_pre.h | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__open64_2.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__openat64_2.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/__openat_2.c | 6 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/fopen.c | 7 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/fopen64.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/fopen64_pre_check.c | 2 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/open64.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/openat.c | 6 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/openat64.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/truncate.c | 4 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/truncate64.c | 3 |
14 files changed, 17 insertions, 41 deletions
diff --git a/libsandbox/pre_check_openat64.c b/libsandbox/pre_check_openat64.c index 9420c98..d4dbe97 100644 --- a/libsandbox/pre_check_openat64.c +++ b/libsandbox/pre_check_openat64.c @@ -10,8 +10,6 @@ #include "libsandbox.h" #include "wrappers.h" -#include "wrapper-funcs/__64_pre.h" #define sb_openat_pre_check sb_openat64_pre_check #include "pre_check_openat.c" #undef sb_openat_pre_check -#include "wrapper-funcs/__64_post.h" diff --git a/libsandbox/wrapper-funcs/__64_post.h b/libsandbox/wrapper-funcs/__64_post.h deleted file mode 100644 index 82d2a16..0000000 --- a/libsandbox/wrapper-funcs/__64_post.h +++ /dev/null @@ -1,4 +0,0 @@ -#undef SB64 -#undef stat -#undef lstat -#undef off_t diff --git a/libsandbox/wrapper-funcs/__64_pre.h b/libsandbox/wrapper-funcs/__64_pre.h deleted file mode 100644 index 0b34b25..0000000 --- a/libsandbox/wrapper-funcs/__64_pre.h +++ /dev/null @@ -1,4 +0,0 @@ -#define SB64 -#define stat stat64 -#define lstat lstat64 -#define off_t off64_t diff --git a/libsandbox/wrapper-funcs/__open64_2.c b/libsandbox/wrapper-funcs/__open64_2.c index bdbd5d8..52daff1 100644 --- a/libsandbox/wrapper-funcs/__open64_2.c +++ b/libsandbox/wrapper-funcs/__open64_2.c @@ -5,6 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define sb_openat_pre_check sb_openat64_pre_check #include "__open_2.c" -#include "__64_post.h" +#undef sb_openat_pre_check diff --git a/libsandbox/wrapper-funcs/__openat64_2.c b/libsandbox/wrapper-funcs/__openat64_2.c index 445164a..ccc4fdd 100644 --- a/libsandbox/wrapper-funcs/__openat64_2.c +++ b/libsandbox/wrapper-funcs/__openat64_2.c @@ -5,6 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define sb_openat_pre_check sb_openat64_pre_check #include "__openat_2.c" -#include "__64_post.h" +#undef sb_openat_pre_check diff --git a/libsandbox/wrapper-funcs/__openat_2.c b/libsandbox/wrapper-funcs/__openat_2.c index 4549a23..f2e85ea 100644 --- a/libsandbox/wrapper-funcs/__openat_2.c +++ b/libsandbox/wrapper-funcs/__openat_2.c @@ -13,11 +13,7 @@ # define dirfd AT_FDCWD #endif -#ifdef SB64 -# define WRAPPER_PRE_CHECKS() sb_openat64_pre_check(STRING_NAME, pathname, dirfd, flags) -#else -# define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) -#endif +#define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/fopen.c b/libsandbox/wrapper-funcs/fopen.c index ce2fdf3..5d36ffa 100644 --- a/libsandbox/wrapper-funcs/fopen.c +++ b/libsandbox/wrapper-funcs/fopen.c @@ -10,11 +10,6 @@ #define WRAPPER_SAFE() SB_SAFE_OPEN_CHAR(pathname, mode) #define WRAPPER_RET_TYPE FILE * #define WRAPPER_RET_DEFAULT NULL - -#ifdef SB64 -# define WRAPPER_PRE_CHECKS() sb_fopen64_pre_check(STRING_NAME, pathname, mode) -#else -# define WRAPPER_PRE_CHECKS() sb_fopen_pre_check(STRING_NAME, pathname, mode) -#endif +#define WRAPPER_PRE_CHECKS() sb_fopen_pre_check(STRING_NAME, pathname, mode) #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/fopen64.c b/libsandbox/wrapper-funcs/fopen64.c index 8e0cdb0..c9b42ef 100644 --- a/libsandbox/wrapper-funcs/fopen64.c +++ b/libsandbox/wrapper-funcs/fopen64.c @@ -5,6 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define sb_fopen_pre_check sb_fopen64_pre_check #include "fopen.c" -#include "__64_post.h" +#undef sb_fopen_pre_check diff --git a/libsandbox/wrapper-funcs/fopen64_pre_check.c b/libsandbox/wrapper-funcs/fopen64_pre_check.c index 3f7a737..4dbd171 100644 --- a/libsandbox/wrapper-funcs/fopen64_pre_check.c +++ b/libsandbox/wrapper-funcs/fopen64_pre_check.c @@ -5,8 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" #define sb_fopen_pre_check sb_fopen64_pre_check #include "fopen_pre_check.c" #undef sb_fopen_pre_check -#include "__64_post.h" diff --git a/libsandbox/wrapper-funcs/open64.c b/libsandbox/wrapper-funcs/open64.c index 622b8ea..8b03ea8 100644 --- a/libsandbox/wrapper-funcs/open64.c +++ b/libsandbox/wrapper-funcs/open64.c @@ -5,6 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define sb_openat_pre_check sb_openat64_pre_check #include "open.c" -#include "__64_post.h" +#undef sb_openat_pre_check diff --git a/libsandbox/wrapper-funcs/openat.c b/libsandbox/wrapper-funcs/openat.c index 846c63f..d09e63d 100644 --- a/libsandbox/wrapper-funcs/openat.c +++ b/libsandbox/wrapper-funcs/openat.c @@ -16,11 +16,7 @@ # define dirfd AT_FDCWD #endif -#ifdef SB64 -# define WRAPPER_PRE_CHECKS() sb_openat64_pre_check(STRING_NAME, pathname, dirfd, flags) -#else -# define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) -#endif +#define WRAPPER_PRE_CHECKS() sb_openat_pre_check(STRING_NAME, pathname, dirfd, flags) #define WRAPPER_SAFE_POST_EXPAND \ int mode = 0; \ diff --git a/libsandbox/wrapper-funcs/openat64.c b/libsandbox/wrapper-funcs/openat64.c index b410af2..66c2089 100644 --- a/libsandbox/wrapper-funcs/openat64.c +++ b/libsandbox/wrapper-funcs/openat64.c @@ -5,6 +5,6 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define sb_openat_pre_check sb_openat64_pre_check #include "openat.c" -#include "__64_post.h" +#undef sb_openat_pre_check diff --git a/libsandbox/wrapper-funcs/truncate.c b/libsandbox/wrapper-funcs/truncate.c index b0b5674..2bfbec7 100644 --- a/libsandbox/wrapper-funcs/truncate.c +++ b/libsandbox/wrapper-funcs/truncate.c @@ -5,7 +5,9 @@ * Licensed under the GPL-2 */ -#define WRAPPER_ARGS_PROTO const char *path, off_t length +#ifndef WRAPPER_ARGS_PROTO +# define WRAPPER_ARGS_PROTO const char *path, off_t length +#endif #define WRAPPER_ARGS path, length #define WRAPPER_SAFE() SB_SAFE(path) #include "__wrapper_simple.c" diff --git a/libsandbox/wrapper-funcs/truncate64.c b/libsandbox/wrapper-funcs/truncate64.c index a06b895..6e2266d 100644 --- a/libsandbox/wrapper-funcs/truncate64.c +++ b/libsandbox/wrapper-funcs/truncate64.c @@ -5,6 +5,5 @@ * Licensed under the GPL-2 */ -#include "__64_pre.h" +#define WRAPPER_ARGS_PROTO const char *path, off64_t length #include "truncate.c" -#include "__64_post.h" |