rd

tiny cpt ramdisk image generator meant for system rescue
git clone git://git.ckyln.com/rd
Log | Files | Refs | README | LICENSE

modprobe-kernel-version.patch (2437B)


      1 diff --git a/modutils/modprobe.c b/modutils/modprobe.c
      2 index 0a372a049..ecb29a8fd 100644
      3 --- a/modutils/modprobe.c
      4 +++ b/modutils/modprobe.c
      5 @@ -111,7 +111,7 @@
      6  //usage:       "   from the command line\n"
      7  //usage:
      8  //usage:#define modprobe_trivial_usage
      9 -//usage:	"[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]"
     10 +//usage:	"[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]" " [-S VERSION]"
     11  //usage:	" MODULE" IF_FEATURE_CMDLINE_MODULE_OPTIONS(" [SYMBOL=VALUE]...")
     12  //usage:#define modprobe_full_usage "\n\n"
     13  //usage:       "	-a	Load multiple MODULEs"
     14 @@ -121,6 +121,7 @@
     15  //usage:     "\n	-v	Verbose"
     16  //usage:     "\n	-s	Log to syslog"
     17  //usage:     "\n	-D	Show dependencies"
     18 +//usage:     "\n	-S	Set kernel version"
     19  //usage:	IF_FEATURE_MODPROBE_BLACKLIST(
     20  //usage:     "\n	-b	Apply blacklist to module names too"
     21  //usage:	)
     22 @@ -131,7 +132,7 @@
     23   * Note2: -b is always accepted, but if !FEATURE_MODPROBE_BLACKLIST,
     24   * it is a no-op.
     25   */
     26 -#define MODPROBE_OPTS  "alrDb"
     27 +#define MODPROBE_OPTS  "alrDS:b"
     28  /* -a and -D _are_ in fact compatible */
     29  #define MODPROBE_COMPLEMENTARY "q-v:v-q:l--arD:r--alD:a--lr:D--rl"
     30  //#define MODPROBE_OPTS  "acd:lnrt:C:b"
     31 @@ -147,7 +148,8 @@ enum {
     32  	//OPT_VERONLY    = (INSMOD_OPT_UNUSED << x), /* V */
     33  	//OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */
     34  	OPT_SHOW_DEPS    = (INSMOD_OPT_UNUSED << 3), /* D */
     35 -	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
     36 +	OPT_KERNEL       = (INSMOD_OPT_UNUSED << 4), /* S */
     37 +	OPT_BLACKLIST    = (INSMOD_OPT_UNUSED << 5) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
     38  };
     39  #if ENABLE_LONG_OPTS
     40  static const char modprobe_longopts[] ALIGN1 =
     41 @@ -560,6 +562,7 @@ int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     42  int modprobe_main(int argc UNUSED_PARAM, char **argv)
     43  {
     44  	int rc;
     45 +	char *kernel;
     46  	unsigned opt;
     47  	struct module_entry *me;
     48  
     49 @@ -567,13 +570,20 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
     50  
     51  	opt = getopt32long(argv, "^" INSMOD_OPTS MODPROBE_OPTS "\0" MODPROBE_COMPLEMENTARY,
     52  			modprobe_longopts
     53 -			INSMOD_ARGS
     54 +			INSMOD_ARGS,
     55 +			&kernel
     56  	);
     57  	argv += optind;
     58  
     59 +	/* Set user specified kernel version */
     60 +	if (opt & OPT_KERNEL) {
     61 +	    safe_strncpy(G.uts.release, kernel, sizeof(G.uts.release));
     62 +	} else {
     63 +	    uname(&G.uts);
     64 +	}
     65 +
     66  	/* Goto modules location */
     67  	xchdir(CONFIG_DEFAULT_MODULES_DIR);
     68 -	uname(&G.uts);
     69  	xchdir(G.uts.release);
     70  
     71  	if (opt & OPT_LIST_ONLY) {