@@ -577,13 +577,13 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
DBG(ctx, "lookup modules.builtin.modinfo %s\n", alias);
err = kmod_lookup_alias_from_kernel_builtin_file(ctx, alias, list);
- CHECK_ERR_AND_FINISH(err, fail, list, finish);
-
- if (err == 0) {
+ if (err == -ENOSYS) {
+ /* Optional index missing, try the old one */
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);
}
+ CHECK_ERR_AND_FINISH(err, fail, list, finish);
+
finish:
DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list);
@@ -528,20 +528,17 @@ int kmod_lookup_alias_from_kernel_builtin_file(struct kmod_ctx *ctx,
struct kmod_list **list)
{
struct kmod_list *l;
- int ret = kmod_lookup_alias_from_alias_bin(ctx,
- KMOD_INDEX_MODULES_BUILTIN_ALIAS,
- name, list);
- if (ret > 0) {
- kmod_list_foreach(l, *list) {
- struct kmod_module *mod = l->data;
- kmod_module_set_builtin(mod, true);
- }
- } else if (ret == -ENOSYS) {
- /*
- * If the system does not support this yet, then
- * there is no need to return an error.
- */
- ret = 0;
+ int ret;
+
+ assert(*list == NULL);
+
+ ret = kmod_lookup_alias_from_alias_bin(ctx,
+ KMOD_INDEX_MODULES_BUILTIN_ALIAS,
+ name, list);
+
+ kmod_list_foreach(l, *list) {
+ struct kmod_module *mod = l->data;
+ kmod_module_set_builtin(mod, true);
}
return ret;