summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2011-10-18 17:27:35 +0000
committerThierry Vignaud <tv@mageia.org>2011-10-18 17:27:35 +0000
commit4361eadeb306f67569608d6ed993c9ff1fac69d0 (patch)
treea4424477a23ef24d8ba918f2cd87be689fd1b4a3
parent421172fe5c3640a09a2b0592f3c174e5004abc65 (diff)
downloadldetect-4361eadeb306f67569608d6ed993c9ff1fac69d0.tar
ldetect-4361eadeb306f67569608d6ed993c9ff1fac69d0.tar.gz
ldetect-4361eadeb306f67569608d6ed993c9ff1fac69d0.tar.bz2
ldetect-4361eadeb306f67569608d6ed993c9ff1fac69d0.tar.xz
ldetect-4361eadeb306f67569608d6ed993c9ff1fac69d0.zip
adapt to new module-init-tools-3.16's API
-rw-r--r--NEWS1
-rw-r--r--modalias.c41
2 files changed, 29 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index e14a5d4..44a9d02 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,4 @@
+- adapt to new module-init-tools-3.16's API
- add new API for drakx's stage1 in order to find unknown PCI devices
- don't exit(1) on systems without pci (eg: ARM) (rtp)
diff --git a/modalias.c b/modalias.c
index 86494c6..868fa43 100644
--- a/modalias.c
+++ b/modalias.c
@@ -8,11 +8,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <list.h>
+#include <logging.h>
#include <modprobe.h>
#include <dirent.h>
#include "common.h"
static char *aliasdefault = NULL;
+static char * version = NULL;
+
+static void get_version(void) {
+ if (version != NULL)
+ return;
+ struct utsname buf;
+ uname(&buf);
+ version = strdup(buf.release);
+}
static void free_aliases(struct module_alias *aliases) {
if (aliases == NULL)
@@ -68,6 +79,8 @@ static void free_blacklist(struct module_blacklist *blacklist) {
free(blacklist);
}
+char*dirname;
+
static void set_default_alias_file(void) {
struct utsname rel_buf;
if (!aliasdefault) {
@@ -93,41 +106,43 @@ static void set_default_alias_file(void) {
}
char *modalias_resolve_module(const char *modalias) {
- struct module_command *commands = NULL;
- struct module_options *modoptions = NULL;
struct module_alias *aliases = NULL;
struct module_blacklist *blacklist = NULL;
- const char *config = NULL;
+ struct modprobe_conf conf = {};
+ LIST_HEAD(list);
if (!aliasdefault)
set_default_alias_file();
+ get_version();
/* Returns the resolved alias, options */
- read_toplevel_config(config, modalias, 0,
- 0, &modoptions, &commands, &aliases, &blacklist);
+ parse_toplevel_config(NULL, &conf, 0, 0);
+
+ errfn_t error;
+ aliases = find_matching_aliases(modalias, "", &conf, dirname, error, mit_dry_run, &list);
+
+ /* only load blacklisted modules with specific request (no alias) */
+ apply_blacklist(&aliases, conf.blacklist);
if (!aliases) {
/* We only use canned aliases as last resort. */
char *dkms_file = table_name_to_file("dkms-modules.alias");
- char *alias_filelist[] = {
+ const char *alias_filelist[] = {
"/lib/module-init-tools/ldetect-lst-modules.alias",
aliasdefault,
dkms_file,
NULL,
};
- char **alias_file = alias_filelist;
+ const char **alias_file = alias_filelist;
while (!aliases && *alias_file) {
- read_config(*alias_file, modalias, 0,
- 0, &modoptions, &commands,
- &aliases, &blacklist);
- aliases = apply_blacklist(aliases, blacklist);
+ parse_config_file(*alias_file, &conf, 0, 0);
+ aliases = find_matching_aliases(modalias, "", &conf, dirname, error, mit_dry_run, &list);
+ apply_blacklist(&aliases, blacklist);
alias_file++;
}
free(dkms_file);
}
free_blacklist(blacklist);
- free_commands(commands);
- free_options(modoptions);
if (aliases) {
char *result;
// take the last one because we find eg: generic/ata_generic/sata_sil