From: Lucas De Marchi Date: Wed, 11 Jan 2012 23:48:08 +0000 (-0200) Subject: modprobe: show if module is in kernel X-Git-Tag: v4~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92122614b21c1203fcb8b29f03846f0085113df0;p=thirdparty%2Fkmod.git modprobe: show if module is in kernel Now with './tools/modprobe --show-depends ahci' (ahci is builtin) we have the following output: $ ./tools/modprobe --show-depends ahci builtin ahci Just like modprobe from m-i-t. Previously we had: $ ./tools/modprobe --show-depends ahci FATAL: Module ahci not found. --- diff --git a/TODO b/TODO index bd29f25b..ad908539 100644 --- a/TODO +++ b/TODO @@ -19,8 +19,16 @@ Features: * provide 1:1 compatibility with module-init-tools's modprobe - dump configuration - deal with dependency loop - - break dependency loop when all it needs is to check if the module is - already loaded + - fix dependency listing in --show-depends + $ modprobe -S 3.2.0-2-ARCH --show-depends ahci + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/ata/libata.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/ata/libata.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/ata/libahci.ko.gz + insmod /lib/modules/3.2.0-2-ARCH/kernel/drivers/ata/ahci.ko.gz * Add manpages: copy them from module-init-tools and make the necessary changes @@ -84,6 +92,10 @@ modprobe * kmod-modprobe doesn't parse 'config' and 'include' commands in configuration files. +* we don't use /modules.builtin{,.bin} indexes. Instead we rely on + module appearing on /sys/modules/* without a initstate file to determine if + it is builtin. + depmod ------ diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index 6ed605c8..863d2c18 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -869,6 +869,34 @@ static int insmod_path(struct kmod_ctx *ctx, const char *path, return err; } +static int handle_failed_lookup(struct kmod_ctx *ctx, const char *alias) +{ + struct kmod_module *mod; + int state, err; + + DBG("lookup failed - trying to check if it's builtin\n"); + + err = kmod_module_new_from_name(ctx, alias, &mod); + if (err < 0) + return err; + + state = kmod_module_get_initstate(mod); + kmod_module_unref(mod); + + if (state != KMOD_MODULE_BUILTIN) { + LOG("Module %s not found.\n", alias); + return -ENOENT; + } + + if (first_time) { + LOG("Module %s already in kernel (builtin).\n", alias); + return -ENOENT; + } + + SHOW("builtin %s\n", alias); + return 0; +} + static int insmod_alias(struct kmod_ctx *ctx, const char *alias, const char *extra_options) { @@ -879,10 +907,8 @@ static int insmod_alias(struct kmod_ctx *ctx, const char *alias, if (err < 0) return err; - if (list == NULL) { - LOG("Module %s not found.\n", alias); - return -ENOENT; - } + if (list == NULL) + return handle_failed_lookup(ctx, alias); if (use_blacklist) { struct kmod_list *filtered = NULL;