[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH] [1/2] modprobe: Add -S option to use a different kernel version
From: Jeff Pohlmeyer <yetanothergeek () gmail ! com>
Date: 2024-02-07 13:55:03
Message-ID: CAEuRe+3RmNdK0Nw43Nofo6a4oZdsVcA+Y+3HwCvJDP2zinNg9A () mail ! gmail ! com
[Download RAW message or body]
(These two patches are somewhat related but do not depend on each other and
can be applied separately.)
Support -S to use another kernel version (66 bytes)
Normally modprobe will use version information from the currently running
kernel (similar to `uname -r`). This patch adds a compile-time configuration
option to enable the -S switch, which allows specifying a different kernel
version. This can be useful when used with the -D option to determine module
dependencies when building a new initramfs after a kernel upgrade.
function old new delta
packed_usage 34776 34812 +36
modprobe_main 946 974 +28
.rodata 103911 103913 +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 66/0) Total: 66 bytes
text data bss dec hex filename
1180482 7435 4984 1192901 1233c5 busybox_old
1180548 7435 4984 1192967 123407 busybox_unstripped
["modprobe-add-set-version-option.patch" (text/x-patch)]
From c724000013e2b185d63b9adf969fe771033d5908 Mon Sep 17 00:00:00 2001
From: Jeff Pohlmeyer <yetanothergeek@gmail.com>
Date: Fri, 2 Feb 2024 06:18:52 -0600
Subject: [PATCH] modprobe: Add -S option to use a different kernel version
---
modutils/modprobe.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 543f53e99..8bec5ffb0 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -24,6 +24,17 @@
//config: blacklisted modules. This is useful if you want to prevent your
//config: hardware autodetection scripts to load modules like evdev, frame
//config: buffer drivers etc.
+//config:config FEATURE_MODPROBE_SET_VER
+//config: bool "Support -S to use another kernel version (66 bytes)"
+//config: default n
+//config: depends on MODPROBE && !MODPROBE_SMALL
+//config: help
+//config: Normally modprobe will use version information from the currently
+//config: running kernel (a la `uname -r`). Say 'y' here to enable the -S
+//config: option, which will allow specifying a different kernel version.
+//config: This can be useful in conjunction with the -D option to determine
+//config: module dependencies when building a new initramfs after a kernel
+//config: upgrade.
//applet:IF_MODPROBE(IF_NOT_MODPROBE_SMALL(APPLET_NOEXEC(modprobe, modprobe, \
BB_DIR_SBIN, BB_SUID_DROP, modprobe)))
@@ -110,7 +121,7 @@
//usage: " from the command line\n"
//usage:
//usage:#define modprobe_trivial_usage
-//usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
+//usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") \
IF_FEATURE_MODPROBE_SET_VER("S:") "]" //usage: " MODULE" \
IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...") //usage:#define \
modprobe_full_usage "\n\n" //usage: " -a Load multiple MODULEs"
@@ -123,6 +134,9 @@
//usage: IF_FEATURE_MODPROBE_BLACKLIST(
//usage: "\n -b Apply blacklist to module names too"
//usage: )
+//usage: IF_FEATURE_MODPROBE_SET_VER(
+//usage: "\n -S VERSION Use kernel VERSION"
+//usage: )
//usage:#endif /* !ENABLE_MODPROBE_SMALL */
/* Note: usage text doesn't document various 2.4 options
@@ -130,7 +144,7 @@
* Note2: -b is always accepted, but if !FEATURE_MODPROBE_BLACKLIST,
* it is a no-op.
*/
-#define MODPROBE_OPTS "alrDb"
+#define MODPROBE_OPTS "alrDb" IF_FEATURE_MODPROBE_SET_VER("S:")
/* -a and -D _are_ in fact compatible */
#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--arD:r--alD:a--lr:D--rl"
//#define MODPROBE_OPTS "acd:lnrt:C:b"
@@ -147,6 +161,7 @@ enum {
//OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */
OPT_SHOW_DEPS = (INSMOD_OPT_UNUSED << 3), /* D */
OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
+ OPT_SET_VER = (INSMOD_OPT_UNUSED << 5) * ENABLE_FEATURE_MODPROBE_SET_VER,
};
#if ENABLE_LONG_OPTS
static const char modprobe_longopts[] ALIGN1 =
@@ -559,18 +574,24 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
int rc;
unsigned opt;
struct module_entry *me;
+ IF_FEATURE_MODPROBE_SET_VER(const char *version;)
INIT_G();
opt = getopt32long(argv, "^" INSMOD_OPTS MODPROBE_OPTS "\0" MODPROBE_COMPLEMENTARY,
modprobe_longopts
INSMOD_ARGS
+ IF_FEATURE_MODPROBE_SET_VER(, &version)
);
argv += optind;
/* Goto modules location */
xchdir(CONFIG_DEFAULT_MODULES_DIR);
uname(&G.uts);
+ IF_FEATURE_MODPROBE_SET_VER(
+ if (opt & OPT_SET_VER)
+ safe_strncpy(G.uts.release, version, sizeof(G.uts.release));
+ )
xchdir(G.uts.release);
if (opt & OPT_LIST_ONLY) {
--
2.43.0
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic