diff options
Diffstat (limited to 'arch/linux/common/modules.h')
-rw-r--r-- | arch/linux/common/modules.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/arch/linux/common/modules.h b/arch/linux/common/modules.h index 69f7ebd6..9b895ee8 100644 --- a/arch/linux/common/modules.h +++ b/arch/linux/common/modules.h @@ -16,12 +16,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -void -scan_modules(void) +#define GET_STR(field_name,ptr) \ + if (!ptr && strstr(tmp[0], field_name)) { \ + ptr = g_markup_escape_text(g_strstrip(tmp[1]), strlen(tmp[1])); \ + g_strfreev(tmp); \ + continue; \ + } + +static gboolean +remove_module_devices(gpointer key, gpointer value, gpointer data) +{ + if (!strncmp((gchar *) key, "MOD", 3)) { + g_free((gchar *) key); + g_free((GtkTreeIter *) value); + return TRUE; + } + return FALSE; +} + +static void +scan_modules_do(void) { FILE *lsmod; gchar buffer[1024]; + if (module_list) { + g_free(module_list); + module_list = NULL; + } + + g_hash_table_foreach_remove(moreinfo, remove_module_devices, NULL); + lsmod = popen("/sbin/lsmod", "r"); if (!lsmod) return; @@ -44,7 +69,7 @@ scan_modules(void) sscanf(buf, "%s %ld", modname, &memory); hashkey = g_strdup_printf("MOD%s", modname); - buf = g_strdup_printf("/sbin/modinfo %s", modname); + buf = g_strdup_printf("/sbin/modinfo %s 2>/dev/null", modname); modi = popen(buf, "r"); while (fgets(buffer, 1024, modi)) { @@ -72,14 +97,14 @@ scan_modules(void) /* old modutils displays <none> when there's no value for a given field; this is not desirable in the module name display, so change it to an empty string */ - if (description && !strcmp(description, "<none>")) { + if (description && g_str_equal(description, "<none>")) { g_free(description); description = g_strdup(""); } /* append this module to the list of modules */ module_list = g_strdup_printf("%s$%s$%s=%s\n", - module_list, + module_list ? module_list : "", hashkey, modname, description ? description : ""); @@ -117,7 +142,7 @@ scan_modules(void) g_free(deps); } - g_hash_table_insert(devices, hashkey, strmodule); + g_hash_table_insert(moreinfo, hashkey, strmodule); g_free(license); g_free(description); |