Re: [PATCH] kbuild: generate modules.builtin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
From d60a4a56f5d484a6076c606a111510ce40a4ccd8 Mon Sep 17 00:00:00 2001
From: Andreas Robinson <andr345@xxxxxxxxx>
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@xxxxxxxxx>
---
 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


[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux