char *options;
char *install_commands;
char *remove_commands;
+ char *alias; /* only set if this module was created from an alias */
int n_dep;
int refcount;
struct {
if (ctx == NULL || name == NULL)
return -ENOENT;
- modname_normalize(name, name_norm, &namelen);
+ alias_normalize(name, name_norm, &namelen);
m = kmod_pool_get_module(ctx, name_norm);
if (m != NULL) {
return 0;
}
+int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias,
+ const char *name, struct kmod_module **mod)
+{
+ int err;
+ struct kmod_module *m;
+
+ err = kmod_module_new_from_name(ctx, alias, mod);
+ if (err < 0)
+ return err;
+
+ m = *mod;
+
+ /* if module did not came from pool */
+ if (m->alias == NULL) {
+ m->alias = m->name;
+ m->name = strdup(name);
+ if (m->name == NULL)
+ goto fail_oom;
+ }
+
+ return 0;
+
+fail_oom:
+ ERR(ctx, "out of memory\n");
+ kmod_module_unref(m);
+ *mod = NULL;
+ return err;
+}
+
KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
const char *path,
struct kmod_module **mod)
free(mod->install_commands);
free(mod->remove_commands);
free(mod->path);
+ if (mod->alias != NULL)
+ free(mod->name);
free(mod);
return NULL;
}
/* libkmod-module.c */
+int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias, const char *name, struct kmod_module **mod);
char *modname_normalize(const char *modname, char buf[NAME_MAX], size_t *len) __attribute__((nonnull(1, 2)));
int kmod_module_parse_depline(struct kmod_module *mod, char *line) __attribute__((nonnull(1, 2)));