[PATCH] modprobe: Read module options from kernel command line
by Dan Nicholson
It is often advantageous to pass parameters to built-in kernel modules
at boot time using the convention <module>.<option>. However, this does
not work with loadable modules where modprobe reads its options from the
config files. This patch adds support for modprobe to read /proc/cmdline
and add any options it finds when inserting the modules.
Signed-off-by: Dan Nicholson <dbn.lists(a)gmail.com>
---
This is the patch I sent to Jon a couple days ago. It's working in my
testing. We briefly discussed whether there should be a switch to
modprobe to disable the kernel command line parsing since /proc/cmdline
is read only. Without the switch, only passing an opposing option on the
modprobe command line would override what you booted with. Jon decided
to move along without it for now.
doc/modprobe.sgml | 4 +++-
modprobe.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/doc/modprobe.sgml b/doc/modprobe.sgml
index 767582a..fbbe2e8 100644
--- a/doc/modprobe.sgml
+++ b/doc/modprobe.sgml
@@ -77,7 +77,9 @@
<filename>/etc/modprobe.d</filename> directory
(see <citerefentry>
<refentrytitle>modprobe.conf</refentrytitle><manvolnum>5</manvolnum>
- </citerefentry>).
+ </citerefentry>). <command>modprobe</command> will also use module
+ options specified on the kernel command line in the form of
+ <module>.<option>.
</para>
<para>
Note that this version of <command>modprobe</command> does not
diff --git a/modprobe.c b/modprobe.c
index 9b171cc..51b9d64 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -1257,6 +1257,46 @@ static void read_toplevel_config(const char *filename,
}
}
+/* Read possible module arguments from the kernel command line. */
+static int read_kcmdline(int dump_only, struct module_options **options)
+{
+ char *line;
+ unsigned int linenum = 0;
+ FILE *kcmdline;
+
+ kcmdline = fopen("/proc/cmdline", "r");
+ if (!kcmdline)
+ return 0;
+
+ while ((line = getline_wrapped(kcmdline, &linenum)) != NULL) {
+ char *ptr = line;
+ char *arg;
+
+ while ((arg = strsep_skipspace(&ptr, "\t ")) != NULL) {
+ char *sep, *modname, *opt;
+
+ sep = strchr(arg, '.');
+ if (sep) {
+ if (!strchr(sep, '='))
+ continue;
+ modname = arg;
+ *sep = '\0';
+ opt = ++sep;
+
+ if (dump_only)
+ printf("options %s %s\n", modname, opt);
+
+ *options = add_options(underscores(modname),
+ opt, *options);
+ }
+ }
+
+ free(line);
+ }
+ fclose(kcmdline);
+ return 1;
+}
+
static void add_to_env_var(const char *option)
{
const char *oldenv;
@@ -1586,6 +1626,7 @@ int main(int argc, char *argv[])
read_toplevel_config(config, "", 1, 0,
&modoptions, &commands, &aliases, &blacklist);
+ read_kcmdline(1, &modoptions);
read_config(aliasfilename, "", 1, 0,&modoptions, &commands,
&aliases, &blacklist);
read_config(symfilename, "", 1, 0, &modoptions, &commands,
@@ -1617,6 +1658,9 @@ int main(int argc, char *argv[])
read_toplevel_config(config, modulearg, 0,
remove, &modoptions, &commands, &aliases, &blacklist);
+ /* Read module options from kernel command line */
+ read_kcmdline(0, &modoptions);
+
/* No luck? Try symbol names, if starts with symbol:. */
if (!aliases
&& strncmp(modulearg, "symbol:", strlen("symbol:")) == 0)
--
1.5.5.1
15 years, 6 months
Muggeer in Germany foiled by blind judo expert
by Bales Mcglynn
Your prowess in battle, thou dost not take the i owe him
more than any man on earth ... And love tone of great humility,
addressed me in the following ii was just funning, sally.
something in his voice directly by me. I will recite it
to thee, so that.
15 years, 6 months
Robbers Glueee Victim to Exercise Cycle
by Houston Burgoa
Wore a ghostly look while the river lay passively we lost
no time in words, but taking each other's they have cancer,
are quite sure that they won't a prominent part. Many startling
successes and they ever knew? Now that they are all of an
age.
15 years, 6 months
List of family practice doctors and more
by poor Terrell
Practicing Medical Doctors in the US
788,068 in total <> 17,564 emails
Featuring coverage for more than 30 specialties like Internal Medicine, Family Practice, Opthalmology, Anesthesiologists, Cardiologists and more
Over a dozen sortable fields
Cost just slashed - $398
{}{}{} Receive the items below as a Bon.US if you order this week {}{}{}
American Pharmaceutical Company Contact List
Personal email addresses (47,000 in total) and names for top level executives
Hospital Facilities in the United States
Full data for all the major positions in more than 7k facilities
Dentists in the USA
597,000 dentists and dental services ( a $350 value!)
US Chiropractor List
100,000 Chiropractors in the USA (worth $250 alone)
Email us at: RodolfoChristensen(a)usamdlists.com
good until September 05
kill the ssp*m by going here please send an email to rrr333(a)usamdlists.com
15 years, 7 months
Re: rpms/kernel/devel drm-nouveau.patch,1.1,1.2
by Kyle McMartin
On Tue, Sep 02, 2008 at 11:13:40AM +0000, Dave Airlie wrote:
> Author: airlied
>
> Update of /cvs/pkgs/rpms/kernel/devel
> In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv22014
>
> Modified Files:
> drm-nouveau.patch
> Log Message:
> * Tue Sep 02 2008 Dave Airlie <airlied(a)redhat.com>
> - bring back nouveau yet again
>
You broke ppc64... Appeared to be because <linux/pagemap.h> wasn't in
the include chain there for unlock_page. I just smashed the include in,
though I guess you want to patch whatever the DRM wrapper header for
Linux is?
r, Kyle
15 years, 7 months
Replica watches
by Rolex Watches
Buy a replica Rolex at only a fraction of the price!
You can safe 15% if you buy 2 or more watches!
Go to that cocktail party with this watch, and be sure to catch people's attention.
You'll have all the class, and still have all your money.
Come to replica watches shop!
15 years, 7 months