mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-12-12 05:03:47 +08:00
testsuite: Wrap syscall() to get calls to finit_module()
When we don't have finit_module() in libc (most likely because as of today glibc didn't add it yet), we end up using syscall(__NR_finit_module, ...). In this case we would not wrap the function in the testsuite and thus having some tests failing: TESTSUITE: ERR: could not insert module: Operation not permitted This implementation relies on the fact that this is the only caller of syscall(2), because we can't call libc's syscall(). There's an abort() in place to be future safe: as soon as we need more calls to syscall(), we can detect (and decide what to do). Now we have all tests passing in the testsuite again.
This commit is contained in:
parent
55112d19f7
commit
0ae58609dc
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 ProFUSION embedded systems
|
||||
* Copyright (C) 2012-2013 Lucas De Marchi <lucas.de.marchi@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -35,6 +36,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* kmod_elf_get_section() is not exported, we need the private header */
|
||||
@ -302,6 +304,40 @@ int finit_module(const int fd, const char *args, const int flags)
|
||||
return err;
|
||||
}
|
||||
|
||||
TS_EXPORT long int syscall(long int __sysno, ...)
|
||||
{
|
||||
va_list ap;
|
||||
long ret;
|
||||
|
||||
switch (__sysno) {
|
||||
case -1:
|
||||
errno = -ENOSYS;
|
||||
return -1;
|
||||
case __NR_finit_module: {
|
||||
const char *args;
|
||||
int flags;
|
||||
int fd;
|
||||
|
||||
va_start(ap, __sysno);
|
||||
|
||||
fd = va_arg(ap, int);
|
||||
args = va_arg(ap, const char *);
|
||||
flags = va_arg(ap, int);
|
||||
|
||||
ret = finit_module(fd, args, flags);
|
||||
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: no way to call the libc function - let's hope there are no
|
||||
* other users.
|
||||
*/
|
||||
abort();
|
||||
}
|
||||
|
||||
/* the test is going away anyway, but lets keep valgrind happy */
|
||||
void free_resources(void) __attribute__((destructor));
|
||||
void free_resources(void)
|
||||
|
Loading…
Reference in New Issue
Block a user