linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: sam@ravnborg.org, Linux Kernel <linux-kernel@vger.kernel.org>,
	notting@redhat.com, rusty@rustcorp.com.au, kay.sievers@vrfy.org,
	greg@kroah.com
Subject: [PATCH] depmod: sort output according to modules.order
Date: Tue, 04 Dec 2007 22:55:48 +0900	[thread overview]
Message-ID: <47555C64.8070607@gmail.com> (raw)
In-Reply-To: <47555AF1.8090304@gmail.com>

Kbuild now generates and installs modules.order along with modules.
This patch updates depmod such that it sorts module list according to
the file before generating output files.  Modules which aren't on
modules.order are put after modules which are ordered by
modules.order.

This makes modprobe to prioritize modules according to kernel
Makefile's just as built-in modules are link-ordered by them.

This patch is against module-init-tools 3.3-pre1.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Bill Nottingham <notting@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
---
 depmod.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/depmod.c b/depmod.c
index ea7ad05..e5b9bc3 100644
--- a/depmod.c
+++ b/depmod.c
@@ -585,6 +585,52 @@ static struct module *grab_basedir(const char *dirname)
 	return list;
 }
 
+static void sort_modules(const char *dirname, struct module **listp)
+{
+	struct module *list = *listp, *tlist = NULL, **tpos = &tlist;
+	FILE *modorder;
+	int dir_len = strlen(dirname) + 1;
+	char file_name[dir_len + strlen("modules.order") + 1];
+	char line[dir_len + 10240];
+
+	sprintf(file_name, "%s/%s", dirname, "modules.order");
+
+	modorder = fopen(file_name, "r");
+	if (!modorder) {
+		if (errno == ENOENT)
+			return;
+		fatal("Could not open '%s': %s\n", file_name, strerror(errno));
+	}
+
+	sprintf(line, "%s/", dirname);
+
+	/* move modules listed in modorder file to tlist in order */
+	while (fgets(line + dir_len, sizeof(line) - dir_len, modorder)) {
+		struct module **pos, *mod;
+		int len = strlen(line);
+
+		if (line[len - 1] == '\n')
+			line[len - 1] = '\0';
+
+		for (pos = &list; (mod = *pos); pos = &(*pos)->next) {
+			if (strcmp(line, mod->pathname) == 0) {
+				*pos = mod->next;
+				mod->next = NULL;
+				*tpos = mod;
+				tpos = &mod->next;
+				break;
+			}
+		}
+	}
+
+	/* append the rest */
+	*tpos = list;
+
+	fclose(modorder);
+
+	*listp = tlist;
+}
+
 static void parse_modules(struct module *list)
 {
 	struct module *i;
@@ -857,6 +903,7 @@ int main(int argc, char *argv[])
 	} else {
 		list = grab_basedir(dirname);
 	}
+	sort_modules(dirname, &list);
 	parse_modules(list);
 
 	for (i = 0; i < sizeof(depfiles)/sizeof(depfiles[0]); i++) {

  reply	other threads:[~2007-12-04 13:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 13:49 [PATCH] kbuild: implement modules.order Tejun Heo
2007-12-04 13:55 ` Tejun Heo [this message]
2007-12-05  7:25   ` [PATCH] depmod: sort output according to modules.order Sam Ravnborg
2007-12-05  7:33     ` Tejun Heo
2007-12-05  7:34       ` Tejun Heo
2007-12-05 19:06         ` Sam Ravnborg
2007-12-05 23:28           ` Tejun Heo
2007-12-06 22:37             ` Sam Ravnborg
2007-12-07  0:59               ` Tejun Heo
2007-12-07  5:14                 ` Sam Ravnborg
2007-12-08  8:09             ` Jon Masters
2007-12-08 12:39               ` Alan Cox
2007-12-08  8:03   ` Jon Masters
2007-12-08  8:19     ` Jon Masters
2007-12-09  5:48     ` Tejun Heo
2007-12-04 15:07 ` [PATCH] kbuild: implement modules.order WANG Cong
2007-12-04 15:21   ` Tejun Heo
2007-12-05  7:01     ` WANG Cong
2007-12-05  7:11       ` Tejun Heo
2007-12-05  7:22         ` Li Zefan
2007-12-06  3:02         ` Rusty Russell
2007-12-07 17:48 ` Adrian Bunk
2007-12-07 23:59   ` Tejun Heo
2007-12-08 14:28     ` Adrian Bunk
2007-12-09  5:44       ` Tejun Heo

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=47555C64.8070607@gmail.com \
    --to=htejun@gmail.com \
    --cc=greg@kroah.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=notting@redhat.com \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    /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;
as well as URLs for NNTP newsgroup(s).