mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Robinson <andr345@gmail.com>
To: Kay Sievers <kay.sievers@vrfy.org>
Cc: Scott James Remnant <scott@ubuntu.com>,
	Michal Marek <mmarek@suse.cz>,
	linux-modules@vger.kernel.org, Sam Ravnborg <sam@ravnborg.org>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kbuild: generate modules.builtin
Date: Wed, 15 Jul 2009 20:04:24 +0200	[thread overview]
Message-ID: <cc43514a0907151104r6208a3dbm89dba496c1411fc0@mail.gmail.com> (raw)
In-Reply-To: <ac3eb2510907150946y461fee0dj6e8f5265b4f91215@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]

Guys,

is this patch what you need on the m-i-t end?

(Sorry for sending it as an attachment. I'm restricted to webmail at
the moment and can't prevent gmail from adding line breaks.)

Cheers,
Andreas

[-- Attachment #2: check_modules_builtin.patch --]
[-- Type: text/x-patch, Size: 2543 bytes --]

From d60a4a56f5d484a6076c606a111510ce40a4ccd8 Mon Sep 17 00:00:00 2001
From: Andreas Robinson <andr345@gmail.com>
Date: Wed, 15 Jul 2009 19:48:59 +0200
Subject: [PATCH] modprobe: warn when trying to insert a built-in module

The previous behaviour was to fail with "module foo not found".

Signed-off-by: Andreas Robinson <andr345@gmail.com>
---
 modprobe.c |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/modprobe.c b/modprobe.c
index 21a3111..a0943fe 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -1049,6 +1049,29 @@ static char *gather_options(char *argv[])
 	return optstring;
 }
 
+/* Check whether a module is built into the kernel */
+static int is_builtin(const char *modname, const char *dirname)
+{
+	char *filename;
+	FILE *file;
+	char *line;
+	int found = 0;
+
+	nofail_asprintf(&filename, "%s/modules.builtin", dirname);
+	file = fopen(filename, "r");
+	if (file) {
+		while ((line = getline_wrapped(file, NULL)) != NULL && !found) {
+			char *p = line;
+			char *builtin = underscores(strsep_skipspace(&p, "\t "));
+			found = streq(modname, builtin);
+			free(line);
+		}
+		fclose(file);
+	}
+	free(filename);
+	return found;
+}
+
 /* Do an install/remove command: replace $CMDLINE_OPTS if it's specified. */
 static void do_command(const char *modname,
 		       const char *command,
@@ -1256,6 +1279,7 @@ static int handle_module(const char *modname,
 			  struct module_options *modoptions,
 			  struct module_command *commands,
 			  const char *cmdline_opts,
+			  const char *dirname,
 			  errfn_t error,
 			  modprobe_flags_t flags)
 {
@@ -1271,6 +1295,11 @@ static int handle_module(const char *modname,
 			return 0;
 		}
 
+		if (is_builtin(modname, dirname)) {
+			warn("Module %s is built into the kernel.\n", modname);
+			return 0;
+		}
+
 		if (!quiet)
 			error("Module %s not found.\n", modname);
 		return 1;
@@ -1350,7 +1379,7 @@ int do_modprobe(char *modname,
 			read_depends(dirname, aliases->module, &list);
 			failed |= handle_module(aliases->module,
 				&list, newname, opts, modoptions,
-				commands, cmdline_opts, err, flags);
+				commands, cmdline_opts, dirname, err, flags);
 
 			aliases = aliases->next;
 			INIT_LIST_HEAD(&list);
@@ -1361,7 +1390,8 @@ int do_modprobe(char *modname,
 			return failed;
 
 		failed |= handle_module(modname, &list, newname, cmdline_opts,
-			modoptions, commands, cmdline_opts, error, flags);
+			modoptions, commands, cmdline_opts, dirname, error,
+			flags);
 	}
 	return failed;
 }
-- 
1.6.0.4


  reply	other threads:[~2009-07-15 18:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 15:25 Michal Marek
2009-05-27 21:26 ` Kay Sievers
2009-05-27 21:38   ` Scott James Remnant
2009-07-03 14:45 ` Michal Marek
2009-07-15 16:39   ` Scott James Remnant
2009-07-15 16:46     ` Kay Sievers
2009-07-15 18:04       ` Andreas Robinson [this message]
2009-07-15 19:08         ` Michal Marek
2009-07-15 20:12           ` Andreas Robinson
2009-07-15 20:16             ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc43514a0907151104r6208a3dbm89dba496c1411fc0@mail.gmail.com \
    --to=andr345@gmail.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=sam@ravnborg.org \
    --cc=scott@ubuntu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®