[gnome-system-monitor] Handle NetBSD correctly in SysInfo.
- From: Benoît Dejean <bdejean src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-system-monitor] Handle NetBSD correctly in SysInfo.
- Date: Mon, 13 Jul 2009 11:08:40 +0000 (UTC)
commit a9923684ab00534bde41e8de737118747b03ab54
Author: Benoît Dejean <benoit placenet org>
Date: Mon Jul 13 13:05:36 2009 +0200
Handle NetBSD correctly in SysInfo.
Closes #583924.
Patch by Thomas Klausner <wiz danbala tuwien ac at>.
src/sysinfo.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index 999d673..76690eb 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -84,6 +84,11 @@ namespace {
g_free(markup);
}
+ static string system()
+ {
+ return uname().sysname;
+ }
+
private:
void load_memory_info()
@@ -141,15 +146,21 @@ namespace {
g_free(entries);
}
-
- void load_uname_info()
+ static const struct utsname & uname()
{
- struct utsname name;
+ static struct utsname name;
- uname(&name);
+ if (!name.sysname[0]) {
+ ::uname(&name);
+ }
- this->hostname = name.nodename;
- this->kernel = string(name.sysname) + ' ' + name.release;
+ return name;
+ }
+
+ void load_uname_info()
+ {
+ this->hostname = uname().nodename;
+ this->kernel = string(uname().sysname) + ' ' + uname().release;
}
@@ -354,14 +365,40 @@ namespace {
};
+ class NetBSDSysInfo
+ : public SysInfo
+ {
+ public:
+ NetBSDSysInfo()
+ {
+ this->load_netbsd_info();
+ }
+
+ private:
+ void load_netbsd_info()
+ {
+ this->distro_name = "NetBSD";
+
+ std::ifstream input("/etc/release");
+
+ if (input)
+ std::getline(input, this->distro_release);
+ }
+ };
+
+
SysInfo* get_sysinfo()
{
if (char *p = g_find_program_in_path("lsb_release")) {
g_free(p);
return new LSBSysInfo;
}
- else if (g_file_test("/etc/release", G_FILE_TEST_EXISTS))
+ else if (SysInfo::system() == "SunOS") {
return new SolarisSysInfo;
+ }
+ else if (SysInfo::system() == "NetBSD") {
+ return new NetBSDSysInfo;
+ }
return new SysInfo;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]