* [PATCH] Module Alias back compat code
@ 2003-12-19 3:08 Rusty Russell
2003-12-19 16:16 ` OGAWA Hirofumi
0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2003-12-19 3:08 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel
The provides backwards compat for old char and block aliases.
MODULE_ALIAS_BLOCK() and MODULE_ALIAS_CHAR() define aliases of form
"XXX-<major>-<minor>", so we should probe for modules using this
form. Unfortunately in 2.4, block aliases were "XXX-<major>" and
char aliases were of both forms.
Ideally, all modules would now be using MODULE_ALIAS() macros to
define their aliases, and the old configuration files wouldn't
matter as much. Unfortunately, this hasn't happened, so we make
request_module() return the exit status of modprobe, and then
do fallback when probing for char and block devices.
Please apply.
Rusty.
Name: Backwards Compatibility For Old block and char Aliases
Author: Rusty Russell
Status: Tested on 2.6.0
D: MODULE_ALIAS_BLOCK() and MODULE_ALIAS_CHAR() define aliases of form
D: "XXX-<major>-<minor>", so we should probe for modules using this
D: form. Unfortunately in 2.4, block aliases were "XXX-<major>" and
D: char aliases were of both forms.
D:
D: Ideally, all modules would now be using MODULE_ALIAS() macros to
D: define their aliases, and the old configuration files wouldn't
D: matter as much. Unfortunately, this hasn't happened, so we make
D: request_module() return the exit status of modprobe, and then
D: do fallback when probing for char and block devices.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .1494-linux-2.6.0/drivers/block/genhd.c .1494-linux-2.6.0.updated/drivers/block/genhd.c
--- .1494-linux-2.6.0/drivers/block/genhd.c 2003-10-09 18:02:51.000000000 +1000
+++ .1494-linux-2.6.0.updated/drivers/block/genhd.c 2003-12-19 13:40:15.000000000 +1100
@@ -296,7 +296,9 @@ extern int blk_dev_init(void);
static struct kobject *base_probe(dev_t dev, int *part, void *data)
{
- request_module("block-major-%d", MAJOR(dev));
+ if (request_module("block-major-%d-%d", MAJOR(dev), MINOR(dev)) > 0)
+ /* Make old-style 2.4 aliases work */
+ request_module("block-major-%d", MAJOR(dev));
return NULL;
}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .1494-linux-2.6.0/fs/char_dev.c .1494-linux-2.6.0.updated/fs/char_dev.c
--- .1494-linux-2.6.0/fs/char_dev.c 2003-11-24 15:42:32.000000000 +1100
+++ .1494-linux-2.6.0.updated/fs/char_dev.c 2003-12-19 13:40:23.000000000 +1100
@@ -434,7 +434,9 @@ void cdev_init(struct cdev *cdev, struct
static struct kobject *base_probe(dev_t dev, int *part, void *data)
{
- request_module("char-major-%d-%d", MAJOR(dev), MINOR(dev));
+ if (request_module("char-major-%d-%d", MAJOR(dev), MINOR(dev)) > 0)
+ /* Make old-style 2.4 aliases work */
+ request_module("char-major-%d", MAJOR(dev));
return NULL;
}
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .1494-linux-2.6.0/include/linux/kmod.h .1494-linux-2.6.0.updated/include/linux/kmod.h
--- .1494-linux-2.6.0/include/linux/kmod.h 2003-09-22 10:28:12.000000000 +1000
+++ .1494-linux-2.6.0.updated/include/linux/kmod.h 2003-12-19 13:26:50.000000000 +1100
@@ -24,6 +24,8 @@
#include <linux/compiler.h>
#ifdef CONFIG_KMOD
+/* modprobe exit status on success, -ve on error. Return value
+ * usually useless though. */
extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));
#else
static inline int request_module(const char * name, ...) { return -ENOSYS; }
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .1494-linux-2.6.0/kernel/kmod.c .1494-linux-2.6.0.updated/kernel/kmod.c
--- .1494-linux-2.6.0/kernel/kmod.c 2003-10-26 14:52:50.000000000 +1100
+++ .1494-linux-2.6.0.updated/kernel/kmod.c 2003-12-19 13:25:48.000000000 +1100
@@ -182,16 +182,21 @@ static int wait_for_helper(void *data)
{
struct subprocess_info *sub_info = data;
pid_t pid;
+ struct k_sigaction sa;
+
+ /* Install a handler: if SIGCLD isn't handled sys_wait4 won't
+ * populate the status, but will return -ECHILD. */
+ sa.sa.sa_handler = SIG_IGN;
+ sa.sa.sa_flags = 0;
+ siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD));
+ do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);
+ allow_signal(SIGCHLD);
- sub_info->retval = 0;
pid = kernel_thread(____call_usermodehelper, sub_info, SIGCHLD);
if (pid < 0)
sub_info->retval = pid;
else
- /* We don't have a SIGCHLD signal handler, so this
- * always returns -ECHILD, but the important thing is
- * that it blocks. */
- sys_wait4(pid, NULL, 0, NULL);
+ sys_wait4(pid, &sub_info->retval, 0, NULL);
complete(sub_info->complete);
return 0;
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Module Alias back compat code
2003-12-19 3:08 [PATCH] Module Alias back compat code Rusty Russell
@ 2003-12-19 16:16 ` OGAWA Hirofumi
2003-12-21 23:59 ` Rusty Russell
0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2003-12-19 16:16 UTC (permalink / raw)
To: Rusty Russell; +Cc: akpm, linux-kernel
Rusty Russell <rusty@rustcorp.com.au> writes:
> The provides backwards compat for old char and block aliases.
>
> MODULE_ALIAS_BLOCK() and MODULE_ALIAS_CHAR() define aliases of form
> "XXX-<major>-<minor>", so we should probe for modules using this
> form. Unfortunately in 2.4, block aliases were "XXX-<major>" and
> char aliases were of both forms.
>
> Ideally, all modules would now be using MODULE_ALIAS() macros to
> define their aliases, and the old configuration files wouldn't
> matter as much. Unfortunately, this hasn't happened, so we make
> request_module() return the exit status of modprobe, and then
> do fallback when probing for char and block devices.
Umm.. Although I may be mis-understanding this problem, is the following
scripts the not enough?
This does
block-major-1 -> block-major-1-*
--- generate-modprobe.conf.orig 2003-08-12 05:03:59.000000000 +0900
+++ generate-modprobe.conf 2003-12-20 00:31:17.000000000 +0900
@@ -59,8 +59,9 @@
parse_alias()
{
PA_ALIAS=`resolve_alias $1 $3`
+ NAME=`echo $2|sed -e 's/\(block\|char\)-major-\([0-9]\+\)$/\1-major-\2-*/'`
- echo "alias $2 $PA_ALIAS"
+ echo "alias $NAME $PA_ALIAS"
}
# Parse options: args modulename aliasto.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Module Alias back compat code
2003-12-19 16:16 ` OGAWA Hirofumi
@ 2003-12-21 23:59 ` Rusty Russell
0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2003-12-21 23:59 UTC (permalink / raw)
To: OGAWA Hirofumi; +Cc: akpm, linux-kernel
In message <87hdzwye8i.fsf@devron.myhome.or.jp> you write:
> Rusty Russell <rusty@rustcorp.com.au> writes:
>
> Umm.. Although I may be mis-understanding this problem, is the following
> scripts the not enough?
>
> This does
>
> block-major-1 -> block-major-1-*
I've applied this, too, thanks.
But I still think we'll want the fallback for people who don't realize
the change or used older generate-modprobe.conf versions.
Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-12-22 1:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-19 3:08 [PATCH] Module Alias back compat code Rusty Russell
2003-12-19 16:16 ` OGAWA Hirofumi
2003-12-21 23:59 ` Rusty Russell
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.