diff options
author | David Cantrell <dcantrell@redhat.com> | 2010-07-21 06:06:48 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2010-07-26 21:31:39 -1000 |
commit | 053916c0951f6edc98e64bb747f1766a290a7f53 (patch) | |
tree | c600801a8c1c5f3f86f5cfb48b686d96b1c4be70 /loader/modules.c | |
parent | ba4e78f1f0bf4b2a5e86f8effbacb2e18e59c2fb (diff) | |
download | anaconda-053916c0951f6edc98e64bb747f1766a290a7f53.tar.gz anaconda-053916c0951f6edc98e64bb747f1766a290a7f53.tar.xz anaconda-053916c0951f6edc98e64bb747f1766a290a7f53.zip |
Use readvars_parse_file() in loader/modules.c
Diffstat (limited to 'loader/modules.c')
-rw-r--r-- | loader/modules.c | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/loader/modules.c b/loader/modules.c index cf699697b..8fc07dfde 100644 --- a/loader/modules.c +++ b/loader/modules.c @@ -44,6 +44,7 @@ #include "../pyanaconda/isys/log.h" #include "modules.h" +#include "readvars.h" /* boot flags */ extern uint64_t flags; @@ -244,60 +245,40 @@ static gboolean _doLoadModule(const gchar *module, gchar **args) { } gboolean mlInitModuleConfig(void) { - gint i = 0; - gchar *cmdline = NULL; - gchar **options = NULL; - GError *readErr = NULL; - - /* read module options out of /proc/cmdline and into a structure */ - if (!g_file_get_contents("/proc/cmdline", &cmdline, NULL, &readErr)) { - logMessage(ERROR, "unable to read /proc/cmdline: %s", readErr->message); - g_error_free(readErr); - return _writeModulesConf(MODULES_CONF); - } - - cmdline = g_strchomp(cmdline); - options = g_strsplit(cmdline, " ", 0); - g_free(cmdline); + GHashTableIter iter; + gpointer key = NULL, value = NULL; + GHashTable *cmdline = readvars_parse_file("/proc/cmdline"); - if (options == NULL) { + if (cmdline == NULL) { return _writeModulesConf(MODULES_CONF); } - while (options[i] != NULL) { - gchar *tmpmod = NULL; - gchar **fields = NULL; + g_hash_table_iter_init(&iter, cmdline); - if (g_strstr_len(options[i], -1, "=") == NULL) { - i++; - continue; - } + while (g_hash_table_iter_next(&iter, &key, &value)) { + gchar *k = (gchar *) key; + gchar *v = (gchar *) value; - if (!strncmp(options[i], "blacklist=", 10)) { - if ((fields = g_strsplit(options[i], "=", 0)) != NULL) { - if (g_strv_length(fields) == 2) { - tmpmod = g_strdup(fields[1]); - blacklist = g_slist_append(blacklist, tmpmod); - } - } - } else if ((fields = g_strsplit(options[i], ".", 0)) != NULL) { - if (g_strv_length(fields) == 2) { - if (_isValidModule(fields[0])) { - _addOption(fields[0], fields[1]); - } + if (v == NULL) { + continue; + } else if (!strcasecmp(k, "blacklist")) { + gchar *tmpmod = g_strdup(v); + blacklist = g_slist_append(blacklist, tmpmod); + } else if (!strstr(k, ".")) { + gchar **fields = g_strsplit(k, ".", 0); + + if (g_strv_length(fields) == 2 && _isValidModule(fields[0])) { + GString *tmp = g_string_new(fields[1]); + g_string_append_printf(tmp, "=%s", v); + _addOption(fields[0], tmp->str); + g_string_free(tmp, TRUE); } - } - if (fields != NULL) { g_strfreev(fields); } - - i++; } - if (options != NULL) { - g_strfreev(options); - } + g_hash_table_destroy(cmdline); return _writeModulesConf(MODULES_CONF); } |