aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtrace/libtrace.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2015-10-25 09:27:34 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2015-10-25 09:27:34 -0400
commit801164566924c41d18d66bdc9ca8b2305103fb82 (patch)
tree3384c10df8b38fb4af945f90fecd2c3876941fdf /src/libtrace/libtrace.c
parentignore option testing (diff)
downloadfirejail-801164566924c41d18d66bdc9ca8b2305103fb82.tar.gz
firejail-801164566924c41d18d66bdc9ca8b2305103fb82.tar.zst
firejail-801164566924c41d18d66bdc9ca8b2305103fb82.zip
fix struct stat64 problem for musl libc
Diffstat (limited to 'src/libtrace/libtrace.c')
-rw-r--r--src/libtrace/libtrace.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c
index 1eb1cf931..2ce74d331 100644
--- a/src/libtrace/libtrace.c
+++ b/src/libtrace/libtrace.c
@@ -18,7 +18,11 @@
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/ 19*/
20#define _GNU_SOURCE 20#define _GNU_SOURCE
21#ifdef HAVE_MUSL_LIBC
22#include "musl_defs.h"
23#else
21#include <stdio.h> 24#include <stdio.h>
25#endif
22#include <stdlib.h> 26#include <stdlib.h>
23#include <string.h> 27#include <string.h>
24#include <dlfcn.h> 28#include <dlfcn.h>
@@ -28,7 +32,9 @@
28#include <netinet/in.h> 32#include <netinet/in.h>
29#include <arpa/inet.h> 33#include <arpa/inet.h>
30#include <sys/un.h> 34#include <sys/un.h>
35#ifndef HAVE_MUSL_LIBC
31#include <sys/stat.h> 36#include <sys/stat.h>
37#endif
32 38
33// break recursivity on fopen call 39// break recursivity on fopen call
34typedef FILE *(*orig_fopen_t)(const char *pathname, const char *mode); 40typedef FILE *(*orig_fopen_t)(const char *pathname, const char *mode);
@@ -414,9 +420,17 @@ int stat(const char *pathname, struct stat *buf) {
414 return rv; 420 return rv;
415} 421}
416 422
423#ifdef HAVE_MUSL_LIBC
424typedef int (*orig_stat64_t)(const char *pathname, struct stat *buf);
425#else
417typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf); 426typedef int (*orig_stat64_t)(const char *pathname, struct stat64 *buf);
427#endif
418static orig_stat64_t orig_stat64 = NULL; 428static orig_stat64_t orig_stat64 = NULL;
429#ifdef HAVE_MUSL_LIBC
430int stat64(const char *pathname, struct stat *buf) {
431#else
419int stat64(const char *pathname, struct stat64 *buf) { 432int stat64(const char *pathname, struct stat64 *buf) {
433#endif
420 if (!orig_stat) 434 if (!orig_stat)
421 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat"); 435 orig_stat64 = (orig_stat64_t)dlsym(RTLD_NEXT, "stat");
422 436