From: Kees Cook Date: Mon, 18 Feb 2013 20:02:33 +0000 (-0800) Subject: testsuite: handle finit_module X-Git-Tag: v13~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e87352d289aa19ed388e9e19507d86a39936f3b4;p=thirdparty%2Fkmod.git testsuite: handle finit_module This adds the finit_module logic to the testsuite. --- diff --git a/testsuite/init_module.c b/testsuite/init_module.c index c4d7efba..ca9f84c7 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -274,6 +275,29 @@ long init_module(void *mem, unsigned long len, const char *args) return err; } +TS_EXPORT int finit_module(const int fd, const char *args, const int flags); + +int finit_module(const int fd, const char *args, const int flags) +{ + int err; + void *mem; + unsigned long len; + struct stat st; + + if (fstat(fd, &st) < 0) + return -1; + + len = st.st_size; + mem = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); + if (mem == MAP_FAILED) + return -1; + + err = init_module(mem, len, args); + munmap(mem, len); + + return err; +} + /* the test is going away anyway, but lets keep valgrind happy */ void free_resources(void) __attribute__((destructor)); void free_resources(void)