diff options
author | Agney Lopes Roth Ferraz <agney@debian.org> | 2007-04-09 11:45:31 -0300 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:41 -0500 |
commit | adb3993ba087ede46f62d5f018e17b07e99b5260 (patch) | |
tree | 67b4fa7e224f09d21eb76060422ca23e50e6dfe0 /arch/linux/common/modules.h | |
parent | b3e31ae3787c8806f48c85a52bba9aa3554e2c07 (diff) | |
parent | 11b8179a57e675c6672cbe649c655230ae3e9744 (diff) |
Import Debian changes 0.4.2.1-1
hardinfo (0.4.2.1-1) unstable; urgency=low
* New upstream release.
* Fixed segfault on device entry (Closes: #387955)
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); |