]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: also wrap gettid in syscall()
authorLucas De Marchi <lucas.demarchi@intel.com>
Mon, 8 Jan 2018 16:22:29 +0000 (08:22 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 8 Jan 2018 21:32:38 +0000 (13:32 -0800)
Not a perfect solution for overriding syscall(), but at least
it makes the testsuite to pass in a modified nsswitch.conf (one that has
a module which calls syscall() to get the thread id).

testsuite/init_module.c

index 199186b8d48091467ec14bb63f66c4564ca64e78..503e703a00b0fd80702dddc726e7a58d3ec51014 100644 (file)
@@ -355,6 +355,27 @@ TS_EXPORT long int syscall(long int __sysno, ...)
                return ret;
        }
 
+       if (__sysno == __NR_gettid) {
+               static void *nextlib = NULL;
+               static long (*nextlib_syscall)(long number, ...);
+
+               if (nextlib_syscall == NULL) {
+#ifdef RTLD_NEXT
+                       nextlib = RTLD_NEXT;
+#else
+                       nextlib = dlopen("libc.so.6", RTLD_LAZY);
+#endif
+                       nextlib_syscall = dlsym(nextlib, "syscall");
+                       if (nextlib_syscall == NULL) {
+                               fprintf(stderr, "FIXME FIXME FIXME: could not load syscall symbol: %s\n",
+                                       dlerror());
+                               abort();
+                       }
+               }
+
+               return nextlib_syscall(__NR_gettid);
+       }
+
        /*
         * FIXME: no way to call the libc function due since this is a
         * variadic argument function and we don't have a vsyscall() variant