From 4c5553e792b9ad37634f68776607311d37ce4b19aec21f7e0772f92f2e738fe8 Mon Sep 17 00:00:00 2001 From: Robert Milasan Date: Thu, 21 Jun 2012 06:38:18 +0000 Subject: [PATCH] - Fix broken testsuites on 32bit systems. add: fix-32bits.diff OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=32 --- dont-assert-mkdir_p.patch | 15 -------- fix-32bits.diff | 79 +++++++++++++++++++++++++++++++++++++++ kmod.changes | 4 +- kmod.spec | 2 +- 4 files changed, 82 insertions(+), 18 deletions(-) delete mode 100644 dont-assert-mkdir_p.patch create mode 100644 fix-32bits.diff diff --git a/dont-assert-mkdir_p.patch b/dont-assert-mkdir_p.patch deleted file mode 100644 index 6cfe9c6..0000000 --- a/dont-assert-mkdir_p.patch +++ /dev/null @@ -1,15 +0,0 @@ -Index: kmod-9/testsuite/init_module.c -=================================================================== ---- kmod-9.orig/testsuite/init_module.c -+++ kmod-9/testsuite/init_module.c -@@ -147,7 +147,9 @@ static int create_sysfs_files(const char - strcpy(buf + len, modname); - len += strlen(modname); - -- assert(mkdir_p(buf, 0755) >= 0); -+ // This fails on 32bit systems, we can't use assert -+ // assert(mkdir_p(buf, 0755) >= 0); -+ mkdir_p(buf, 0755); - - strcpy(buf + len, "/initstate"); - return write_one_line_file(buf, "live\n", strlen("live\n")); diff --git a/fix-32bits.diff b/fix-32bits.diff new file mode 100644 index 0000000..20cafcc --- /dev/null +++ b/fix-32bits.diff @@ -0,0 +1,79 @@ +diff --git a/testsuite/init_module.c b/testsuite/init_module.c +index 814998a..ed8b9fc 100644 +--- a/testsuite/init_module.c ++++ b/testsuite/init_module.c +@@ -16,6 +16,7 @@ + */ + + #include ++#include + #include + #include + #include +@@ -206,6 +207,12 @@ static inline bool module_is_inkernel(const char *modname) + return ret; + } + ++static uint8_t elf_identify(void *mem) ++{ ++ uint8_t *p = mem; ++ return p[EI_CLASS]; ++} ++ + TS_EXPORT long init_module(void *mem, unsigned long len, const char *args); + + /* +@@ -225,6 +232,8 @@ long init_module(void *mem, unsigned long len, const char *args) + const void *buf; + uint64_t bufsize; + int err; ++ uint8_t class; ++ off_t offset; + + init_retcodes(); + +@@ -237,13 +246,20 @@ long init_module(void *mem, unsigned long len, const char *args) + kmod_elf_unref(elf); + + /* +- * We couldn't find the module's name inside the ELF file. Just exit +- * as if it was successful ++ * We couldn't find the parse the ELF file. Just exit as if it was ++ * successful + */ + if (err < 0) + return 0; + +- modname = (char *)buf + offsetof(struct module, name); ++ /* We need to open both 32 and 64 bits module - hack! */ ++ class = elf_identify(mem); ++ if (class == ELFCLASS64) ++ offset = MODULE_NAME_OFFSET_64; ++ else ++ offset = MODULE_NAME_OFFSET_32; ++ ++ modname = (char *)buf + offset; + mod = find_module(modules, modname); + if (mod != NULL) { + errno = mod->errcode; +diff --git a/testsuite/stripped-module.h b/testsuite/stripped-module.h +index 9f97dae..19862f3 100644 +--- a/testsuite/stripped-module.h ++++ b/testsuite/stripped-module.h +@@ -13,6 +13,7 @@ struct list_head { + }; + + #define MODULE_NAME_LEN (64 - sizeof(unsigned long)) ++ + struct module + { + enum module_state state; +@@ -24,4 +25,8 @@ struct module + char name[MODULE_NAME_LEN]; + }; + ++/* padding */ ++#define MODULE_NAME_OFFSET_64 4 + 4 + 2 * 8 ++#define MODULE_NAME_OFFSET_32 4 + 2 * 4 ++ + #endif diff --git a/kmod.changes b/kmod.changes index e2fe6f1..7c2757d 100644 --- a/kmod.changes +++ b/kmod.changes @@ -11,8 +11,8 @@ Wed Jun 20 08:41:03 UTC 2012 - rmilasan@suse.com * depmod: don't return error if modules.builtin don't exist * libkmod-util: split function for usec conversion * libkmod-util: add missing stdbool.h include -- Don't assert mkdir_p, it fails on 32bit systems. - add: dont-assert-mkdir_p.patch +- Fix broken testsuites on 32bit systems. + add: fix-32bits.diff ------------------------------------------------------------------- Sat Apr 21 01:55:30 UTC 2012 - jengelh@medozas.de diff --git a/kmod.spec b/kmod.spec index 93d5f72..88c1c16 100644 --- a/kmod.spec +++ b/kmod.spec @@ -30,7 +30,7 @@ Url: http://www.politreco.com/2011/12/announce-kmod-2/ Source: %name-%version.tar.xz Source2: %name-%version.tar.sign Patch1: kmod-so-version.diff -Patch2: dont-assert-mkdir_p.patch +Patch2: fix-32bits.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf