diff options
author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-04-22 00:35:53 -0300 |
---|---|---|
committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2024-04-22 00:35:53 -0300 |
commit | 5f01c706267c595de92406a32e7f31ef5056c2d0 (patch) | |
tree | d1e74ef54efc41ada622900fe3e2a50dee44a237 /modules/devices/devicetree.c | |
parent | 09fcc751ef158898c315ebc9299a0fa3a722d914 (diff) |
New upstream version 2.0.3preupstream/2.0.3pre
Diffstat (limited to 'modules/devices/devicetree.c')
-rw-r--r-- | modules/devices/devicetree.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index 4f3c85a2..7c798670 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -1,10 +1,10 @@ /* * HardInfo - Displays System Information - * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> + * Copyright (C) 2003-2007 L. A. F. Pereira <l@tia.mat.br> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2. + * the Free Software Foundation, version 2 or later. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,6 +28,10 @@ #include "devices.h" #include "cpu_util.h" #include "dt_util.h" +#include "appf.h" + +gchar *dtree_info = NULL; +const char *dtree_mem_str = NULL; /* used by memory devices when nothing else is available */ /* These should really go into CMakeLists.txt */ #if defined(__arm__) @@ -36,8 +40,6 @@ #include "devicetree/pmac_data.c" #endif -gchar *dtree_info = NULL; - static gchar *get_node(dtr *dt, char *np) { gchar *nodes = NULL, *props = NULL, *ret = NULL; gchar *tmp = NULL, *pstr = NULL, *lstr = NULL; @@ -216,13 +218,14 @@ static gchar *get_summary(dtr *dt) { return ret; } -static void mi_add(const char *key, const char *value) { +static void mi_add(const char *key, const char *value, int report_details) { gchar *ckey, *rkey; ckey = hardinfo_clean_label(key, 0); rkey = g_strdup_printf("%s:%s", "DTREE", ckey); - dtree_info = h_strdup_cprintf("$%s$%s=\n", dtree_info, rkey, ckey); + dtree_info = h_strdup_cprintf("$%s%s$%s=\n", dtree_info, + (report_details) ? "!" : "", rkey, ckey); moreinfo_add_with_prefix("DEV", rkey, g_strdup(value)); g_free(ckey); @@ -237,15 +240,14 @@ static void add_keys(dtr *dt, char *np) { GDir *dir; dtr_obj *obj; - /* add self */ - obj = dtr_obj_read(dt, np); - dt_path = dtr_obj_path(obj); - n_info = get_node(dt, dt_path); - mi_add(dt_path, n_info); - dir_path = g_strdup_printf("%s/%s", dtr_base_path(dt), np); dir = g_dir_open(dir_path, 0 , NULL); - if (dir) { + if(!dir){ /* add self */ + obj = dtr_obj_read(dt, np); + dt_path = dtr_obj_path(obj); + n_info = get_node(dt, dt_path); + mi_add(dt_path, n_info, 0); + }else { //dir while((fn = g_dir_read_name(dir)) != NULL) { ftmp = g_strdup_printf("%s/%s", dir_path, fn); if ( g_file_test(ftmp, G_FILE_TEST_IS_DIR) ) { @@ -253,24 +255,25 @@ static void add_keys(dtr *dt, char *np) { ntmp = g_strdup_printf("/%s", fn); else ntmp = g_strdup_printf("%s/%s", np, fn); - add_keys(dt, ntmp); + if(strlen(ntmp)>0) add_keys(dt, ntmp); g_free(ntmp); } g_free(ftmp); } + g_dir_close(dir); } - g_dir_close(dir); + g_free(dir_path); } static char *msg_section(dtr *dt, int dump) { gchar *aslbl = NULL; gchar *messages = dtr_messages(dt); - gchar *ret = g_strdup_printf("[%s]\n", _("Messages")); + gchar *ret = g_strdup_printf("[%s]", _("Messages")); gchar **lines = g_strsplit(messages, "\n", 0); int i = 0; while(lines[i] != NULL) { aslbl = hardinfo_clean_label(lines[i], 0); - ret = appf(ret, "%s=\n", aslbl); + ret = appfnl(ret, "%s=", aslbl); g_free(aslbl); i++; } @@ -289,13 +292,13 @@ void __scan_dtree() gchar *messages = NULL; dtree_info = g_strdup("[Device Tree]\n"); - mi_add("Summary", summary); - mi_add("Maps", maps); + mi_add("Summary", summary, 1); + mi_add("Maps", maps, 0); if(dtr_was_found(dt)) add_keys(dt, "/"); messages = msg_section(dt, 0); - mi_add("Messages", messages); + mi_add("Messages", messages, 0); g_free(summary); g_free(maps); |