All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Tejun Heo <htejun@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	notting@redhat.com, kay.sievers@vrfy.org,
	Greg KH <greg@kroah.com>, Jon Masters <jonathan@jonmasters.org>
Subject: Re: [PATCH] depmod: sort output according to modules.order, take #2
Date: Thu, 3 Jan 2008 10:12:21 +1100	[thread overview]
Message-ID: <200801031012.22776.rusty@rustcorp.com.au> (raw)
In-Reply-To: <477B71F0.8020706@gmail.com>

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

On Wednesday 02 January 2008 22:13:52 Tejun Heo wrote:
> Tejun Heo wrote:
> > Tejun Heo wrote:
> >> 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.
> >>
> > The kernel part is in now.  Rusty Russell, what do you think about this
> > depmod change?
>
> Ping?

Oh, sorry.  Jon is now module-init-tools maintainer, and I've cc'd him and 
forwarded your original patch.

Thanks,
Rusty.




[-- Attachment #2: Tejun Heo <htejun@gmail.com>: [PATCH] depmod: sort output according to modules.order, take #2 --]
[-- Type: message/rfc822, Size: 5415 bytes --]

From: Tejun Heo <htejun@gmail.com>
To: Sam Ravnborg <sam@ravnborg.org>, Linux Kernel <linux-kernel@vger.kernel.org>, notting@redhat.com, rusty@rustcorp.com.au, kay.sievers@vrfy.org, Greg KH <greg@kroah.com>
Subject: [PATCH] depmod: sort output according to modules.order, take #2
Date: Fri, 07 Dec 2007 21:07:57 +0900
Message-ID: <4759379D.8090201@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: Sam Ravnborg <sam@ravnborg.org>
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>
---
Comment added and path comparion logic slightly modified such that
dirname part of mode->pathname is ignored instead of prepending
dirname to lines read from modules.order.  Behavior-wise it's
identical to the previous version.

Thanks.

 depmod.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/depmod.c b/depmod.c
index ea7ad05..c3ae5a2 100644
--- a/depmod.c
+++ b/depmod.c
@@ -585,6 +585,54 @@ 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[10240];
+
+	sprintf(file_name, "%s/%s", dirname, "modules.order");
+
+	modorder = fopen(file_name, "r");
+	if (!modorder) {
+		/* Older kernels don't generate modules.order.  Just
+		   return if the file doesn't exist. */
+		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, sizeof(line), 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 + dir_len) == 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 +905,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:[~2008-01-02 23:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-07 12:04 [PATCH] kbuild: implement modules.order, take #2 Tejun Heo
2007-12-07 12:07 ` [PATCH] depmod: sort output according to " Tejun Heo
2007-12-09  9:30   ` Tejun Heo
2008-01-02 11:13     ` Tejun Heo
2008-01-02 23:12       ` Rusty Russell [this message]
2008-01-02 23:58         ` Jon Masters
2008-11-13 11:36           ` Tejun Heo
2008-11-13 19:30             ` Jon Masters
2008-11-15 19:20             ` Jon Masters
2008-11-16  5:25               ` Tejun Heo
2008-11-16 16:13                 ` Kay Sievers
2007-12-13  7:12   ` Greg KH
2007-12-09  8:11 ` [PATCH] kbuild: implement " Sam Ravnborg
2007-12-13  7:11 ` Greg KH

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=200801031012.22776.rusty@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=greg@kroah.com \
    --cc=htejun@gmail.com \
    --cc=jonathan@jonmasters.org \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=notting@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.