diff options
Diffstat (limited to '0001-Module-replace-the-module-with-new-module.patch')
-rw-r--r-- | 0001-Module-replace-the-module-with-new-module.patch | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/0001-Module-replace-the-module-with-new-module.patch b/0001-Module-replace-the-module-with-new-module.patch new file mode 100644 index 0000000..0cbc3fa --- /dev/null +++ b/0001-Module-replace-the-module-with-new-module.patch @@ -0,0 +1,108 @@ +From 0eac0869e201a08170cb2255b623eab9d78072f8 Mon Sep 17 00:00:00 2001 +From: Jason Luan <luanjianhai@huawei.com> +Date: Wed, 16 Sep 2020 01:21:50 +0000 +Subject: [PATCH 1/2] Module: replace the module with new module + +Signed-off-by: fu.lin <fu.lin10@huawei.com> +--- + libkmod/libkmod-module.c | 3 +++ + libkmod/libkmod.h | 6 ++++++ + shared/missing.h | 7 +++++++ + tools/insmod.c | 7 ++++++- + 4 files changed, 22 insertions(+), 1 deletion(-) + +diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c +index c095e63..4c0f159 100644 +--- a/libkmod/libkmod-module.c ++++ b/libkmod/libkmod-module.c +@@ -873,8 +873,11 @@ static int do_finit_module(struct kmod_module *mod, unsigned int flags, + kernel_flags |= MODULE_INIT_IGNORE_VERMAGIC; + if (flags & KMOD_INSERT_FORCE_MODVERSION) + kernel_flags |= MODULE_INIT_IGNORE_MODVERSIONS; ++ if (flags & KMOD_INSERT_REPLACE) ++ kernel_flags |= MODULE_REPLACE_MODULE; + + err = finit_module(kmod_file_get_fd(mod->file), args, kernel_flags); ++ + if (err < 0) + err = -errno; + +diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h +index f3376f5..ef1576f 100644 +--- a/libkmod/libkmod.h ++++ b/libkmod/libkmod.h +@@ -140,6 +140,9 @@ enum kmod_remove { + enum kmod_insert { + KMOD_INSERT_FORCE_VERMAGIC = 0x1, + KMOD_INSERT_FORCE_MODVERSION = 0x2, ++ ++ /* custom flag */ ++ KMOD_INSERT_REPLACE = 0x1000, + }; + + /* Flags to kmod_module_probe_insert_module() */ +@@ -151,6 +154,9 @@ enum kmod_probe { + KMOD_PROBE_DRY_RUN = 0x00010, + KMOD_PROBE_FAIL_ON_LOADED = 0x00020, + ++ /* custom flag */ ++ KMOD_PROBE_REPLACE = 0x01000, ++ + /* codes below can be used in return value, too */ + KMOD_PROBE_APPLY_BLACKLIST_ALL = 0x10000, + KMOD_PROBE_APPLY_BLACKLIST = 0x20000, +diff --git a/shared/missing.h b/shared/missing.h +index 7df6235..3bd0cfa 100644 +--- a/shared/missing.h ++++ b/shared/missing.h +@@ -19,6 +19,13 @@ + # define MODULE_INIT_COMPRESSED_FILE 4 + #endif + ++#ifndef MODULE_REPLACE_MODULE ++# define MODULE_REPLACE_MODULE 0x1000 ++#else ++_Static_assert(MODULE_REPLACE_MODULE == 0x1000, ++ "MODULE_REPLACE_MODULE != 0x1000, change `KMOD_INSERT_REPLACE` and `KMOD_PROBE_REPLACE` defination"); ++#endif ++ + #ifndef __NR_finit_module + # define __NR_finit_module -1 + #endif +diff --git a/tools/insmod.c b/tools/insmod.c +index 4a1d11d..7e58ed3 100644 +--- a/tools/insmod.c ++++ b/tools/insmod.c +@@ -15,9 +15,10 @@ + + #include "kmod.h" + +-static const char cmdopts_s[] = "psfVh"; ++static const char cmdopts_s[] = "psfVrh"; + static const struct option cmdopts[] = { + {"version", no_argument, 0, 'V'}, ++ {"replace", no_argument, 0, 'r'}, + {"help", no_argument, 0, 'h'}, + {NULL, 0, 0, 0} + }; +@@ -28,6 +29,7 @@ static void help(void) + "\t%s [options] filename [args]\n" + "Options:\n" + "\t-V, --version show version\n" ++ "\t-r, --replace replace module\n" + "\t-h, --help show this help\n", + program_invocation_short_name); + } +@@ -76,6 +78,9 @@ static int do_insmod(int argc, char *argv[]) + case 'h': + help(); + return EXIT_SUCCESS; ++ case 'r': ++ flags |= KMOD_INSERT_REPLACE; ++ break; + case 'V': + puts(PACKAGE " version " VERSION); + puts(KMOD_FEATURES); +-- +2.46.0 + |