Linux Hotplug development
 help / color / mirror / Atom feed
From: Erik van Konijnenburg <ekonijn@xs4all.nl>
To: Greg KH <gregkh@suse.de>,
	"Alexander E. Patrakov" <patrakov@ums.usu.ru>,
	Rusty Russell <rusty@rustcorp.com.au>,
	linux-hotplug-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Roman Kagan <rkagan@mail.ru>
Subject: [PATCH] Re: [ANNOUNCE] hotplug-ng 002 release
Date: Tue, 10 May 2005 23:55:09 +0000	[thread overview]
Message-ID: <20050511015509.B7594@banaan.localdomain> (raw)
In-Reply-To: <20050510232207.A7594@banaan.localdomain>; from ekonijn@xs4all.nl on Tue, May 10, 2005 at 11:22:07PM +0200

Hi,

Patch against module-init-tools-3.2-pre4 to ignore modules
listed in /etc/hotplug/blacklist or blacklist.d (recursively).

* blacklist is only effective during adding,
  not during remove or match with -a,
  and not for modules required to resolve a dependency.
* tested only with -n, -v and --showdeps, not in live use.
* in particular, no testing for interaction with /etc/init.d scripts
* Roman, I'm not sure how this meshes with your patch to pass $MODNAME
  from the driver to hotplug, discussed in:
  http://marc.theaimsgroup.com/?l=linux-hotplug-devel&m\x110994425816837
  Perhaps you could have a look at it?

Regards,
Erik

Signed-off-by: Erik van Konijnenburg <ekonijn@xs4all.nl>

diff -urN module-init-tools-3.2-pre4/modprobe.c module-init-tools-3.2-pre4-new/modprobe.c
--- module-init-tools-3.2-pre4/modprobe.c	2005-05-08 09:38:52.000000000 +0200
+++ module-init-tools-3.2-pre4-new/modprobe.c	2005-05-11 01:14:16.000000000 +0200
@@ -1291,6 +1291,123 @@
 	return 0;
 }
 
+
+struct blacklist
+{
+	struct blacklist *next;
+	char *module;
+};
+
+/* Link in a blacklist line */
+static struct blacklist *
+add_blacklist (const char *modname, struct blacklist *blacklist)
+{
+	struct blacklist *new;
+
+	new = NOFAIL(malloc(sizeof(*new)));
+	new->module = NOFAIL(strdup(modname));
+	new->next = blacklist;
+	return new;
+}
+
+/* add stuff from file to list, return false on error */
+static int
+read_blacklist_file (const char *filename, struct blacklist **blacklist)
+{
+	char *line;
+	unsigned int linenum = 0;
+	FILE *cfile;
+
+	cfile = fopen(filename, "r");
+	if (!cfile)
+		return 0;
+
+	while ((line = getline_wrapped(cfile, &linenum)) != NULL) {
+		char *ptr = line;
+		char *modname;
+
+		modname = strsep_skipspace(&ptr, "\t ");
+		if (modname = NULL || modname[0] = '#' || modname[0] = '\0')
+			continue;
+
+		*blacklist = add_blacklist(modname, *blacklist);
+		free(line);
+	}
+	fclose(cfile);
+	return 1;
+}
+
+/* add stuff from file or dir to list, return false on error */
+static int
+read_blacklist (const char *filename, struct blacklist **blacklist)
+{
+	DIR *dir;
+
+	/* If it's a directory, recurse. */
+	dir = opendir(filename);
+	if (dir) {
+		struct dirent *i;
+
+		/* FIXME: don't we want .rpmnew protection? */
+		while ((i = readdir(dir)) != NULL) {
+			if (!streq(i->d_name,".") && !streq(i->d_name,"..")) {
+				char sub[strlen(filename) + 1
+					 + strlen(i->d_name) + 1];
+
+				sprintf(sub, "%s/%s", filename, i->d_name);
+				if (!read_blacklist(sub, blacklist))
+					warn("Failed to open"
+					      " blacklist file %s: %s\n",
+					      sub, strerror(errno));
+			}
+		}
+		closedir(dir);
+		return 1;
+	}
+
+	return read_blacklist_file(filename, blacklist);
+}
+
+static const char *default_blacklists[] = 
+{
+	"/etc/hotplug/blacklist",
+	"/etc/hotplug/blacklist.d",
+};
+
+static void
+read_toplevel_blacklist(const char *filename, struct blacklist **blacklist)
+{
+	unsigned int i;
+
+	if (filename) {
+		if (!read_blacklist(filename, blacklist))
+			fatal("Failed to open blacklist file %s: %s\n",
+			      filename, strerror(errno));
+		return;
+	}
+
+	/* Try defaults. */
+	for (i = 0; i < ARRAY_SIZE(default_blacklists); i++) {
+		if (!read_blacklist(default_blacklists[i], blacklist))
+			warn("Failed to open blacklist file %s: %s\n",
+			      filename, strerror(errno));
+	}
+}
+
+static int is_blacklisted (struct blacklist *blacklist, char *modulename)
+{
+	int result = 0;
+	
+	while (blacklist) {
+		if (strcmp (blacklist->module, modulename) = 0) {
+			result = 1;
+			break;
+		}
+		blacklist = blacklist->next;
+	}
+	return result;
+}
+
 int main(int argc, char *argv[])
 {
 	struct utsname buf;
@@ -1315,6 +1432,7 @@
 	char *newname = NULL;
 	char *aliasfilename, *symfilename;
 	errfn_t error = fatal;
+	struct blacklist *blacklist = NULL;
 
 	/* Prepend options from environment. */
 	argv = merge_args(getenv("MODPROBE_OPTIONS"), argv, &argc);
@@ -1475,6 +1593,9 @@
 		optstring = gather_options(argv+optind+1);
 	}
 
+	/* FIXME: extra option for alternate blacklist file? */
+	read_toplevel_blacklist (NULL, &blacklist);
+
 	/* num_modules is always 1 except for -r or -a. */
 	for (i = 0; i < num_modules; i++) {
 		struct module_command *commands = NULL;
@@ -1486,6 +1607,11 @@
 		/* Convert name we are looking for */
 		underscores(modulearg);
 
+		/* FIXME: do we blacklist on -a? */
+		if (is_blacklisted (blacklist, modulearg) && !remove) {
+			continue;
+		}
+
 		/* Returns the resolved alias, options */
 		read_toplevel_config(config, modulearg, 0,
 				     remove, &modoptions, &commands, &aliases);


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_ids93&alloc_id\x16281&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

  reply	other threads:[~2005-05-10 23:55 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-06 21:22 [ANNOUNCE] hotplug-ng 002 release Greg KH
2005-05-08 22:52 ` Per Liden
2005-05-09 21:13   ` Per Svennerbrandt
2005-05-10 22:17     ` Per Liden
2005-05-10 22:41       ` Greg KH
2005-05-10 23:56         ` Per Liden
2005-05-11  1:22           ` Brian Gerst
2005-05-11  5:33           ` Greg KH
2005-05-18 23:00       ` Per Svennerbrandt
2005-05-18 23:00       ` [PATCH][RFC] __request_module: fixed argument request_module with waitflag Per Svennerbrandt
2005-05-18 23:01       ` [PATCH][RFC] request_modalias: MODALIAS based module loading Per Svennerbrandt
2005-05-18 23:37         ` Per Svennerbrandt
2005-05-10 22:41     ` [ANNOUNCE] hotplug-ng 002 release Greg KH
2005-05-12 21:42     ` Greg KH
2005-05-13  8:19       ` Michael Tokarev
2005-05-13 16:02         ` Greg KH
2005-05-13 23:21       ` Per Svennerbrandt
2005-05-14  5:59         ` Greg KH
2005-05-18  9:27     ` David Weinehall
2005-05-09 23:22   ` Greg KH
2005-05-10 21:51     ` Per Liden
2005-05-11  5:36       ` Greg KH
2005-05-09  3:57 ` Rusty Russell
2005-05-09 23:21   ` Greg KH
2005-05-10  9:29     ` Rusty Russell
2005-05-10  9:43       ` Marco d'Itri
2005-05-10 12:58         ` Alexander E. Patrakov
2005-05-10 17:24           ` Marco d'Itri
2005-05-10 20:13             ` Greg KH
2005-05-10 20:28               ` Lee Revell
2005-05-10 20:59                 ` Greg KH
2005-05-10 21:02                   ` Marco d'Itri
2005-05-10 20:31               ` Marco d'Itri
2005-05-10 20:52                 ` Greg KH
2005-05-10 20:59                   ` Bill Nottingham
2005-05-10 21:08                   ` Marco d'Itri
2005-05-10 21:22                     ` Erik van Konijnenburg
2005-05-10 23:55                       ` Erik van Konijnenburg [this message]
2005-05-11  0:05                         ` Marco d'Itri
2005-05-11  5:40                           ` Greg KH
2005-05-11  0:08                         ` [PATCH] " Rusty Russell
2005-05-11  1:11                           ` Erik van Konijnenburg
2005-05-11  3:39                             ` Rusty Russell
2005-05-11  9:59                               ` Erik van Konijnenburg
2005-05-11 10:52                                 ` Rusty Russell
2005-05-11 10:58                                   ` Marco d'Itri
2005-05-11 13:06                                     ` Erik van Konijnenburg
2005-05-12  4:39                                       ` Rusty Russell
2005-05-12  7:47                                         ` Erik van Konijnenburg
2005-05-11  0:01               ` Rusty Russell
2005-05-11  0:10                 ` Marco d'Itri
2005-05-11  1:09                   ` Rusty Russell
2005-05-11  7:31 ` Christian Zoz
2005-05-14 23:02 ` Michael Tokarev
2005-05-16 19:11   ` Greg KH
2005-05-16 21:24 ` Marco d'Itri

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=20050511015509.B7594@banaan.localdomain \
    --to=ekonijn@xs4all.nl \
    --cc=gregkh@suse.de \
    --cc=linux-hotplug-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patrakov@ums.usu.ru \
    --cc=rkagan@mail.ru \
    --cc=rusty@rustcorp.com.au \
    /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