%define KMOD_PATH %{_libdir}/stability-monitor/proc-tsm.ko
Name: stability-monitor
-Version: 6.1.1
+Version: 6.2.1
Release: 0
License: Apache-2.0
Source0: %{name}-%{version}.tar.xz
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(crash-service)
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libkmod)
ExclusiveArch: armv7l
Requires: %{KMOD_PATH}
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
+#include <libkmod.h>
#include "log.h"
#include "raw_data.h"
#define PROC_TSM_MODULE_NAME "proc_tsm"
#define PROC_TSM_PATH "/proc/tsm"
#define MAX_LINE 100
-#define finit_module(fd, params, flags) syscall(__NR_finit_module, fd, params, flags)
static int str_to_ullarray(char *str, unsigned long long *array)
/* Load kernel module if not loaded */
static int init(void)
{
- int fd, ret = 0;
+ struct kmod_ctx *ctx;
+ struct kmod_module *mod;
+ int ret = 0;
if (access(PROC_TSM_PATH, O_RDONLY) == 0) {
_I("Kernel module already loaded");
return 0;
}
- fd = open(KMOD_PATH, O_RDONLY);
- if (fd == -1) {
- _E("Unable to open file descriptor");
+ ctx = kmod_new(NULL, NULL);
+ if (!ctx) {
+ _E("kmod_new() failed");
return -1;
}
- ret = finit_module(fd, "", 0);
- if (ret)
- _E("Unable to load kernel module: %m");
- close(fd);
+ ret = kmod_module_new_from_name(ctx, PROC_TSM_MODULE_NAME, &mod);
+ if (ret) {
+ _E("Unable to find module " PROC_TSM_MODULE_NAME);
+ goto kmod_unref;
+ }
+
+ ret = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
+ if (ret) {
+ errno = -ret;
+ _E("Unable to insert %s: %m", kmod_module_get_name(mod));
+ goto module_unref;
+ }
+
+module_unref:
+ kmod_module_unref(mod);
+kmod_unref:
+ kmod_unref(ctx);
return ret;
}