SHA256
1
0
forked from pool/kmod
kmod/0006-testsuite-Do-not-provide-finit_module-2-on-older-ker.patch
Jan Engelhardt 237161f1b6 Accepting request 224726 from home:michal-m:branches:Base:System
- testsuite: Check the list of loaded modules after a test
- testsuite: Add test for modprobe --force
- testsuite: Do not provide finit_module(2) on older kernels
- Add some tests for kernels without finit_module(2)
- libkmod-module: Simplify kmod_module_insert_module()
- libkmod: Implement filtering of unsupported modules (fate#316971)
- modprobe: Implement --allow-unsupported-modules (fate#316971)
- make the %check section fatal

OBS-URL: https://build.opensuse.org/request/show/224726
OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=65
2014-03-05 15:59:07 +00:00

68 lines
1.8 KiB
Diff

From 970b96f070b3f9ccd9c1850db44116a2b02da424 Mon Sep 17 00:00:00 2001
From: Michal Marek <mmarek@suse.cz>
Date: Thu, 27 Feb 2014 23:31:33 +0100
Subject: [PATCH 06/10] testsuite: Do not provide finit_module(2) on older
kernels
If the test's uname -r is less that 3.8, return -ENOSYS from
finit_module(), so that the fallback is tested.
Patch-mainline: v17
Git-commit: 063086e038657de64f9980bc51954b0817fa8e6c
---
testsuite/init_module.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/testsuite/init_module.c b/testsuite/init_module.c
index 42177e7..269a471 100644
--- a/testsuite/init_module.c
+++ b/testsuite/init_module.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syscall.h>
+#include <sys/utsname.h>
#include <unistd.h>
/* kmod_elf_get_section() is not exported, we need the private header */
@@ -280,6 +281,25 @@ long init_module(void *mem, unsigned long len, const char *args)
return err;
}
+static int check_kernel_version(int major, int minor)
+{
+ struct utsname u;
+ const char *p;
+ int maj = 0, min = 0;
+
+ if (uname(&u) < 0)
+ return false;
+ for (p = u.release; *p >= '0' && *p <= '9'; p++)
+ maj = maj * 10 + *p - '0';
+ if (*p == '.')
+ for (p++; *p >= '0' && *p <= '9'; p++)
+ min = min * 10 + *p - '0';
+ if (maj > major || (maj == major && min >= minor))
+ return true;
+ return false;
+}
+
+
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)
@@ -289,6 +309,10 @@ int finit_module(const int fd, const char *args, const int flags)
unsigned long len;
struct stat st;
+ if (!check_kernel_version(3, 8)) {
+ errno = ENOSYS;
+ return -1;
+ }
if (fstat(fd, &st) < 0)
return -1;
--
1.8.4.5