From 183eb02508f538e8200b62bbefc1c48aa0675d28 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Sat, 30 Jul 2016 23:42:53 +0200 Subject: libtrace: Add support for lstat() / lstat64() --- src/libtrace/libtrace.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/libtrace') diff --git a/src/libtrace/libtrace.c b/src/libtrace/libtrace.c index 9f2622c00..dde3df2ea 100644 --- a/src/libtrace/libtrace.c +++ b/src/libtrace/libtrace.c @@ -432,6 +432,31 @@ int stat64(const char *pathname, struct stat64 *buf) { } #endif /* __GLIBC__ */ +// lstat +typedef int (*orig_lstat_t)(const char *pathname, struct stat *buf); +static orig_lstat_t orig_lstat = NULL; +int lstat(const char *pathname, struct stat *buf) { + if (!orig_lstat) + orig_lstat = (orig_lstat_t)dlsym(RTLD_NEXT, "lstat"); + + int rv = orig_lstat(pathname, buf); + printf("%u:%s:lstat %s:%d\n", pid(), name(), pathname, rv); + return rv; +} + +#ifdef __GLIBC__ +typedef int (*orig_lstat64_t)(const char *pathname, struct stat64 *buf); +static orig_lstat64_t orig_lstat64 = NULL; +int lstat64(const char *pathname, struct stat64 *buf) { + if (!orig_lstat64) + orig_lstat64 = (orig_lstat64_t)dlsym(RTLD_NEXT, "lstat64"); + + int rv = orig_lstat64(pathname, buf); + printf("%u:%s:lstat64 %s:%d\n", pid(), name(), pathname, rv); + return rv; +} +#endif /* __GLIBC__ */ + // opendir typedef DIR *(*orig_opendir_t)(const char *pathname); static orig_opendir_t orig_opendir = NULL; -- cgit v1.2.3-54-g00ecf