blob: b45bbe297a7e495d8b6ac0210bfd35a9d9db41a4 [file] [log] [blame]
Lucas De Marchi14070642013-04-09 04:00:20 -03001#pragma once
2
Lucas De Marchi55112d12013-04-09 04:16:57 -03003#include <unistd.h>
4#include <sys/syscall.h>
5
Lucas De Marchi14070642013-04-09 04:00:20 -03006#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 Marchi55112d12013-04-09 04:16:57 -030017
Lucas De Marchi03f7dfb2013-05-11 00:50:32 -030018#ifndef __NR_finit_module
19# define __NR_finit_module -1
20#endif
21
Lucas De Marchi55112d12013-04-09 04:16:57 -030022#ifndef HAVE_FINIT_MODULE
Jan Luebbe5eac7952013-05-02 16:47:12 +020023#include <errno.h>
24
Lucas De Marchi55112d12013-04-09 04:16:57 -030025static inline int finit_module(int fd, const char *uargs, int flags)
26{
Jan Luebbe5eac7952013-05-02 16:47:12 +020027 if (__NR_finit_module == -1) {
28 errno = ENOSYS;
29 return -1;
30 }
31
Lucas De Marchi55112d12013-04-09 04:16:57 -030032 return syscall(__NR_finit_module, fd, uargs, flags);
33}
34#endif