On (01/02/11 20:35), Arjan van de Ven wrote:
> On 1/2/2011 1:21 PM, Andreas Mohr wrote:
> >Hi,
> >
> >On Sun, Jan 02, 2011 at 11:50:50AM -0800, Arjan van de Ven wrote:
> >>Hi,
> >>
> >>I just cut the second alpha of the 2.x series of PowerTop:
> >Immediately tested, now builds fine on a Debian testing box.
> >
> >Nice stuff, except perhaps for some network weirdness:
> >
> > Good Wake-on-lan status for device eth0
> >
> >Well.... I don't even _have_ eth0. Even ifconfig -a lists eth1 only.
> >Unless it's that darn device renaming (it probably is).
> >In which case powertop had better adopt device renaming support, too
> >(you wouldn't want to display names of interfaces which don't actually
> >exist on the user side, right?).
>
> ok will check how to resolve this.. does make sense to only show
> those that exist.
>
Could you please try the following patch?
Though, we already read net dir in create_all_nics and instead we can export
`static map<string, class network *> nics'
and just iterate through the map to fill vector of tunables net device.
---
tuning/ethernet.cpp | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/tuning/ethernet.cpp b/tuning/ethernet.cpp
index b3ac0a5..986df9d 100644
--- a/tuning/ethernet.cpp
+++ b/tuning/ethernet.cpp
@@ -142,9 +142,24 @@ void ethernet_tunable::toggle(void)
void add_ethernet_tunable(void)
{
class ethernet_tunable *eth;
-
- eth = new class ethernet_tunable("eth0");
- if (eth)
- all_tunables.push_back(eth);
+ struct dirent *entry;
+ DIR *dir;
+ dir = opendir("/sys/class/net/");
+ if (!dir)
+ return;
+ while ((entry = readdir(dir))) {
+ if (!entry)
+ break;
+ if (entry->d_name[0] == '.')
+ continue;
+ if (strcmp(entry->d_name, "lo") == 0)
+ continue;
+
+ eth = new(std::nothrow) class ethernet_tunable(entry->d_name);
+ if (eth)
+ all_tunables.push_back(eth);
+ }
+
+ closedir(dir);
}
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power