Lucas De Marchi | 1407064 | 2013-04-09 04:00:20 -0300 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Lucas De Marchi | 55112d1 | 2013-04-09 04:16:57 -0300 | [diff] [blame] | 3 | #include <unistd.h> |
| 4 | #include <sys/syscall.h> |
| 5 | |
Lucas De Marchi | 1407064 | 2013-04-09 04:00:20 -0300 | [diff] [blame] | 6 | #ifdef HAVE_LINUX_MODULE_H |
| 7 | #include <linux/module.h> |
| 8 | #endif |
| 9 | |
| 10 | #ifndef MODULE_INIT_IGNORE_MODVERSIONS |
| 11 | # define MODULE_INIT_IGNORE_MODVERSIONS 1 |
| 12 | #endif |
| 13 | |
| 14 | #ifndef MODULE_INIT_IGNORE_VERMAGIC |
| 15 | # define MODULE_INIT_IGNORE_VERMAGIC 2 |
| 16 | #endif |
Lucas De Marchi | 55112d1 | 2013-04-09 04:16:57 -0300 | [diff] [blame] | 17 | |
Lucas De Marchi | 03f7dfb | 2013-05-11 00:50:32 -0300 | [diff] [blame] | 18 | #ifndef __NR_finit_module |
| 19 | # define __NR_finit_module -1 |
| 20 | #endif |
| 21 | |
Lucas De Marchi | 55112d1 | 2013-04-09 04:16:57 -0300 | [diff] [blame] | 22 | #ifndef HAVE_FINIT_MODULE |
Jan Luebbe | 5eac795 | 2013-05-02 16:47:12 +0200 | [diff] [blame^] | 23 | #include <errno.h> |
| 24 | |
Lucas De Marchi | 55112d1 | 2013-04-09 04:16:57 -0300 | [diff] [blame] | 25 | static inline int finit_module(int fd, const char *uargs, int flags) |
| 26 | { |
Jan Luebbe | 5eac795 | 2013-05-02 16:47:12 +0200 | [diff] [blame^] | 27 | if (__NR_finit_module == -1) { |
| 28 | errno = ENOSYS; |
| 29 | return -1; |
| 30 | } |
| 31 | |
Lucas De Marchi | 55112d1 | 2013-04-09 04:16:57 -0300 | [diff] [blame] | 32 | return syscall(__NR_finit_module, fd, uargs, flags); |
| 33 | } |
| 34 | #endif |