diff options
| author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-02-16 20:43:16 -0200 |
|---|---|---|
| committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2012-02-16 21:18:00 -0200 |
| commit | 3805274bf5e1e0acbd072ac7d523db8c8057130c (patch) | |
| tree | d76e86a4042b6514782bc8edb8dff67c30f56467 /libkmod/libkmod-module.c | |
| parent | a7f5300d50b7a45667322877132f7c321cd9ac35 (diff) | |
| download | kmod-3805274bf5e1e0acbd072ac7d523db8c8057130c.tar.gz | |
kmod-module: lookup: search modules.builtin file too
Search modules.builtin file before saying the module was not found.
Note: these "modules" should not appear as dependencies of other modules
(in modules.dep) even if they appear in modinfo. This fixes the return
code of modprobe with builtin modules.
Also fixes a small coding style issue in module_is_inkernel().
Diffstat (limited to 'libkmod/libkmod-module.c')
| -rw-r--r-- | libkmod/libkmod-module.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 835896f..4226bbb 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -80,6 +80,13 @@ struct kmod_module { * whether the module's command and softdep should be ignored */ bool ignorecmd : 1; + + /* + * if module was created by searching the modules.builtin file, this + * is set. There's nothing much useful one can do with such a + * "module", except knowing it's builtin. + */ + bool builtin : 1; }; static inline const char *path_join(const char *path, size_t prefixlen, @@ -101,12 +108,13 @@ static inline const char *path_join(const char *path, size_t prefixlen, static inline bool module_is_inkernel(struct kmod_module *mod) { int state = kmod_module_get_initstate(mod); + if (state == KMOD_MODULE_LIVE || state == KMOD_MODULE_COMING || state == KMOD_MODULE_BUILTIN) return true; - else - return false; + + return false; } int kmod_module_parse_depline(struct kmod_module *mod, char *line) @@ -191,6 +199,11 @@ void kmod_module_set_visited(struct kmod_module *mod, bool visited) mod->visited = visited; } +void kmod_module_set_builtin(struct kmod_module *mod, bool builtin) +{ + mod->builtin = builtin; +} + /* * Memory layout with alias: * @@ -526,6 +539,10 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx, err = kmod_lookup_alias_from_aliases_file(ctx, alias, list); CHECK_ERR_AND_FINISH(err, fail, list, finish); + DBG(ctx, "lookup modules.builtin %s\n", alias); + err = kmod_lookup_alias_from_builtin_file(ctx, alias, list); + CHECK_ERR_AND_FINISH(err, fail, list, finish); + finish: DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list); return err; @@ -1593,6 +1610,9 @@ KMOD_EXPORT int kmod_module_get_initstate(const struct kmod_module *mod) if (mod == NULL) return -ENOENT; + if (mod->builtin) + return KMOD_MODULE_BUILTIN; + pathlen = snprintf(path, sizeof(path), "/sys/module/%s/initstate", mod->name); fd = open(path, O_RDONLY|O_CLOEXEC); |
