On Wed, 12 Jan 2000, Keith Owens wrote:
> Use a real function instead, then changing CONFIG_KMOD only recompiles
> one source.
the patch below does just that. I only converted a few pieces like fs and
some block drivers just for the proof of concept. If everyone agrees with
the concept I will convert everything that needs converting this evening
and send it to Linus.
http://www.ocston.org/~tigran/patches/kmod-2.3.40-p1.patch
Regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.ocston.org/~tigran
diff -urN -X dontdiff linux/drivers/block/ide.c linux-kmod/drivers/block/ide.c
--- linux/drivers/block/ide.c Sun Jan 9 01:41:16 2000
+++ linux-kmod/drivers/block/ide.c Wed Jan 12 09:12:15 2000
@@ -136,6 +136,7 @@
#include <linux/genhd.h>
#include <linux/blkpg.h>
#include <linux/malloc.h>
+#include <linux/kmod.h>
#ifndef MODULE
#include <linux/init.h>
#endif /* MODULE */
@@ -151,9 +152,6 @@
#include "ide_modes.h"
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif /* CONFIG_KMOD */
#ifdef CONFIG_BLK_DEV_VIA82CXXX
extern byte fifoconfig; /* defined in via82cxxx.c used by ide_setup() */
@@ -1795,10 +1793,8 @@
module = module->next;
}
revalidate_drives();
-#ifdef CONFIG_KMOD
if (!found && type == IDE_PROBE_MODULE)
(void) request_module("ide-probe");
-#endif /* CONFIG_KMOD */
}
static int ide_open (struct inode * inode, struct file * filp)
@@ -1811,7 +1807,6 @@
MOD_INC_USE_COUNT;
if (drive->driver == NULL)
ide_init_module(IDE_DRIVER_MODULE);
-#ifdef CONFIG_KMOD
if (drive->driver == NULL) {
if (drive->media == ide_disk)
(void) request_module("ide-disk");
@@ -1822,7 +1817,6 @@
if (drive->media == ide_floppy)
(void) request_module("ide-floppy");
}
-#endif /* CONFIG_KMOD */
while (drive->busy)
sleep_on(&drive->wqueue);
drive->usage++;
diff -urN -X dontdiff linux/drivers/block/md.c linux-kmod/drivers/block/md.c
--- linux/drivers/block/md.c Sun Jan 9 01:41:16 2000
+++ linux-kmod/drivers/block/md.c Wed Jan 12 09:12:58 2000
@@ -46,9 +46,7 @@
#include <linux/blkdev.h>
#include <linux/genhd.h>
#include <linux/smp_lock.h>
-#ifdef CONFIG_KMOD
#include <linux/kmod.h>
-#endif
#include <linux/errno.h>
#include <linux/init.h>
@@ -406,12 +404,8 @@
}
if (!pers[pnum])
{
-#ifdef CONFIG_KMOD
- char module_name[80];
- sprintf (module_name, "md-personality-%d", pnum);
- request_module (module_name);
+ request_modulef ("md-personality-%d", pnum);
if (!pers[pnum])
-#endif
return -EINVAL;
}
diff -urN -X dontdiff linux/fs/block_dev.c linux-kmod/fs/block_dev.c
--- linux/fs/block_dev.c Mon Jan 10 00:51:37 2000
+++ linux-kmod/fs/block_dev.c Wed Jan 12 09:07:12 2000
@@ -446,13 +446,8 @@
/* major 0 is used for non-device mounts */
if (major && major < MAX_BLKDEV) {
-#ifdef CONFIG_KMOD
- if (!blkdevs[major].bdops) {
- char name[20];
- sprintf(name, "block-major-%d", major);
- request_module(name);
- }
-#endif
+ if (!blkdevs[major].bdops)
+ request_modulef("block-major-%d", major);
ret = blkdevs[major].bdops;
}
return ret;
diff -urN -X dontdiff linux/fs/devices.c linux-kmod/fs/devices.c
--- linux/fs/devices.c Thu Jan 6 18:14:36 2000
+++ linux-kmod/fs/devices.c Wed Jan 12 09:09:16 2000
@@ -17,16 +17,13 @@
#include <linux/stat.h>
#include <linux/fcntl.h>
#include <linux/errno.h>
-#ifdef CONFIG_KMOD
#include <linux/kmod.h>
-
#include <linux/tty.h>
/* serial module kmod load support */
struct tty_driver *get_tty_driver(kdev_t device);
#define isa_tty_dev(ma) (ma == TTY_MAJOR || ma == TTYAUX_MAJOR)
#define need_serial(ma,mi) (get_tty_driver(MKDEV(ma,mi)) == NULL)
-#endif
struct device_struct {
const char * name;
@@ -68,7 +65,6 @@
struct file_operations *ret = NULL;
if (major < maxdev){
-#ifdef CONFIG_KMOD
/*
* I do get request for device 0. I have no idea why. It happen
* at shutdown time for one. Without the following test, the
@@ -85,12 +81,8 @@
* as there is no other loadable dev on these majors
*/
if ((isa_tty_dev(major) && need_serial(major,minor)) ||
- (major != 0 && !tb[major].fops)) {
- char name[20];
- sprintf(name, mangle, major);
- request_module(name);
- }
-#endif
+ (major != 0 && !tb[major].fops))
+ request_modulef(mangle, major);
ret = tb[major].fops;
}
return ret;
diff -urN -X dontdiff linux/fs/exec.c linux-kmod/fs/exec.c
--- linux/fs/exec.c Wed Dec 29 19:42:07 1999
+++ linux-kmod/fs/exec.c Wed Jan 12 09:10:23 2000
@@ -33,14 +33,12 @@
#include <linux/init.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
+#include <linux/kmod.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
#include <asm/mmu_context.h>
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
static struct linux_binfmt *formats = (struct linux_binfmt *) NULL;
@@ -779,18 +777,14 @@
}
if (retval != -ENOEXEC) {
break;
-#ifdef CONFIG_KMOD
}else{
#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
- char modname[20];
if (printable(bprm->buf[0]) &&
printable(bprm->buf[1]) &&
printable(bprm->buf[2]) &&
printable(bprm->buf[3]))
break; /* -ENOEXEC */
- sprintf(modname, "binfmt-%04x", *(unsigned short *)(&bprm->buf[2]));
- request_module(modname);
-#endif
+ request_modulef("binfmt-%04x", *(unsigned short *)(&bprm->buf[2]));
}
}
return retval;
diff -urN -X dontdiff linux/fs/filesystems.c linux-kmod/fs/filesystems.c
--- linux/fs/filesystems.c Mon Jan 3 20:01:31 2000
+++ linux-kmod/fs/filesystems.c Wed Jan 12 09:10:52 2000
@@ -36,9 +36,7 @@
#include <linux/major.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
-#ifdef CONFIG_KMOD
#include <linux/kmod.h>
-#endif
#include <linux/lockd/bind.h>
#include <linux/lockd/xdr.h>
#include <linux/init.h>
@@ -188,12 +186,10 @@
ret = do_nfsservctl(cmd, argp, resp);
goto out;
}
-#ifdef CONFIG_KMOD
if (request_module ("nfsd") == 0) {
if (do_nfsservctl)
ret = do_nfsservctl(cmd, argp, resp);
}
-#endif /* CONFIG_KMOD */
out:
unlock_kernel();
return ret;
diff -urN -X dontdiff linux/fs/super.c linux-kmod/fs/super.c
--- linux/fs/super.c Thu Jan 6 18:14:36 2000
+++ linux-kmod/fs/super.c Wed Jan 12 09:11:21 2000
@@ -25,6 +25,7 @@
#include <linux/init.h>
#include <linux/quotaops.h>
#include <linux/acct.h>
+#include <linux/kmod.h>
#include <asm/uaccess.h>
@@ -32,9 +33,6 @@
#include <linux/nfs_fs_sb.h>
#include <linux/nfs_mount.h>
-#ifdef CONFIG_KMOD
-#include <linux/kmod.h>
-#endif
/*
* We use a semaphore to synchronize all mount/umount
@@ -394,12 +392,10 @@
return fs;
for (fs = file_systems; fs && strcmp(fs->name, name); fs = fs->next)
;
-#ifdef CONFIG_KMOD
if (!fs && (request_module(name) == 0)) {
for (fs = file_systems; fs && strcmp(fs->name, name); fs = fs->next)
;
}
-#endif
return fs;
}
diff -urN -X dontdiff linux/include/linux/kmod.h linux-kmod/include/linux/kmod.h
--- linux/include/linux/kmod.h Tue Jan 11 02:29:09 2000
+++ linux-kmod/include/linux/kmod.h Wed Jan 12 09:15:08 2000
@@ -3,6 +3,9 @@
*/
#include <linux/config.h>
+#include <stdarg.h>
+
+extern int request_modulef(const char * fmt, ...);
#ifdef CONFIG_KMOD
extern int request_module(const char * name);
diff -urN -X dontdiff linux/kernel/kmod.c linux-kmod/kernel/kmod.c
--- linux/kernel/kmod.c Fri Jan 7 00:17:18 2000
+++ linux-kmod/kernel/kmod.c Wed Jan 12 09:13:11 2000
@@ -11,6 +11,8 @@
Limit the concurrent number of kmod modprobes to catch loops from
"modprobe needs a service that is in a module".
Keith Owens <kaos@ocs.com.au> December 1999
+
+ Added request_modulef(), Tigran Aivazian <tigran@sco.com>, Jan 2000.
*/
#define __KERNEL_SYSCALLS__
@@ -180,4 +182,19 @@
module_name, pid, -waitpid_result);
}
return 0;
+}
+
+int request_modulef(const char * fmt, ...)
+{
+#ifdef CONFIG_KMOD
+ va_list args;
+ char name[64];
+
+ va_start(args, fmt);
+ vsprintf(name, fmt, args);
+ va_end(args);
+ return request_module(name);
+#else
+ return -1;
+#endif
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:20 EST