Hello community,

here is the log from the commit of package xosview for openSUSE:Factory checked 
in at 2015-02-04 09:32:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/xosview (Old)
 and      /work/SRC/openSUSE:Factory/.xosview.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "xosview"

Changes:
--------
--- /work/SRC/openSUSE:Factory/xosview/xosview.changes  2015-01-20 
19:01:16.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.xosview.new/xosview.changes     2015-02-04 
13:05:30.000000000 +0100
@@ -1,0 +2,15 @@
+Tue Feb  3 13:41:24 UTC 2015 - wer...@suse.de
+
+- Rename patches
+  xosview-appdef.patch becomes xosview-1.16-appdef.patch
+  xosview-configuration.patch becomes xosview-1.16.dif
+  xosview-diskstat.patch becomes xosview-1.16-diskstat.patch 
+  xosview-serial.patch becomes xosview-1.16-serial.patch
+- Remove superfluous patches
+  xosview-maxlimit.patch, xosview-pixmap.patch, and xosview-sysinfo.patch
+- Port coretemp changes from Upstream to this (boo#896632)
+  therefore add patch xosview-1.16-coretemp.patch
+- Add code to make coretemp reading work with kernel 3.17+ work (boo#896632) 
+  therefore add patch xosview-1.16-coretemp2.patch
+
+-------------------------------------------------------------------

Old:
----
  xosview-appdef.patch
  xosview-configuration.patch
  xosview-diskstat.patch
  xosview-maxlimit.patch
  xosview-pixmap.patch
  xosview-serial.patch
  xosview-sysinfo.patch

New:
----
  xosview-1.16-appdef.patch
  xosview-1.16-coretemp.patch
  xosview-1.16-coretemp2.patch
  xosview-1.16-diskstat.patch
  xosview-1.16-serial.patch
  xosview-1.16.dif

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ xosview.spec ++++++
--- /var/tmp/diff_new_pack.da7iI1/_old  2015-02-04 13:05:31.000000000 +0100
+++ /var/tmp/diff_new_pack.da7iI1/_new  2015-02-04 13:05:31.000000000 +0100
@@ -32,21 +32,19 @@
 Summary:        System Load Information
 License:        GPL-2.0+
 Group:          System/Monitoring
-Url:            http://www.pogo.org.uk/~mark/xosview/
-Source:         xosview-%{version}.tar.gz
+Url:            https://github.com/hills/xosview
+Source:         
http://www.pogo.org.uk/~mark/xosview/releases/xosview-%{version}.tar.gz
 Source1:        rc.config.xosview
 Source2:        xosview.png
 Source3:        xosview.desktop
 Source4:        xosview.sh
 Source5:        xosview-rpmlintrc
-Patch1:         xosview-serial.patch
-Patch3:         xosview-maxlimit.patch
-Patch8:         xosview-sysinfo.patch
-Patch10:        xosview-appdef.patch
-Patch11:        xosview-diskstat.patch
-# PATCH-FIX-OPENSUSE: Re-add xpm background pximap support (bnc#817558)
-Patch12:        xosview-pixmap.patch
-Patch13:        xosview-configuration.patch
+Patch0:         xosview-%{version}.dif
+Patch1:         xosview-%{version}-serial.patch
+Patch2:         xosview-%{version}-coretemp.patch
+Patch3:         xosview-%{version}-coretemp2.patch
+Patch10:        xosview-%{version}-appdef.patch
+Patch11:        xosview-%{version}-diskstat.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 %define _appdefdir  %{_datadir}/X11/app-defaults
 
@@ -57,13 +55,12 @@
 
 %prep
 %setup -q
-%patch1  -p1
-%patch3  -p1
-%patch8  -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
+%patch1  -p0 -b .serial
+%patch2  -p0 -b .coretemp
+%patch3  -p0 -b .coretemp2
+%patch10 -p0 -b .appdef
+%patch11 -p0 -b .diskstat
+%patch0  -p0 -b .p0
 
 %build
   OPTFLAGS="$RPM_OPT_FLAGS"

++++++ xosview-1.16-appdef.patch ++++++
---
 Xrm.cc |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--- Xrm.cc
+++ Xrm.cc      2015-02-03 10:01:53.129518512 +0000
@@ -9,6 +9,7 @@
 #include <stdio.h>     //  For snprintf().
 #include <ctype.h>
 #include <iostream>
+#include <sys/stat.h>  //  For stat().
 #include <unistd.h>  //  for access(), etc.  BCG
 #ifndef NULL
 #define NULL 0
@@ -138,34 +139,35 @@ Listed from weakest to strongest:
 
   //  Merge in the system resource database.
   char rfilename[2048];
+  struct stat st;
   int result;
   const int rlen = sizeof rfilename;
 
   // Get the app-defaults
   result = snprintf(rfilename, sizeof rfilename, "/etc/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, 
"/usr/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, 
"/usr/X11R6/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, 
"/usr/share/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   //  Try a few more, for SunOS/Solaris folks.
   result = snprintf(rfilename, sizeof rfilename, 
"/usr/openwin/lib/X11/app-defaults/%s",
     XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
   result = snprintf(rfilename, sizeof rfilename, 
"/usr/local/X11R6/lib/X11/app-defaults/%s",
       XrmQuarkToString(_class));
-  if (result >= 0 && result < rlen)
+  if (result >= 0 && result < rlen && stat(rfilename, &st) == 0)
     XrmCombineFileDatabase (rfilename, &_db, 1);
 
   //  Now, check for an XOSView file in the XAPPLRESDIR directory...
++++++ xosview-1.16-coretemp.patch ++++++
---
 linux/MeterMaker.cc |    2 
 linux/coretemp.cc   |  314 +++++++++++++++++++++++++++++-----------------------
 linux/coretemp.h    |   10 -
 3 files changed, 188 insertions(+), 138 deletions(-)

--- linux/MeterMaker.cc
+++ linux/MeterMaker.cc 2015-02-03 13:12:04.257518200 +0000
@@ -166,7 +166,7 @@ void MeterMaker::makeMeters(void){
       snprintf(s, 80, "coretemp%dDisplayType", i);
       displayType = _xos->getResourceOrUseDefault( s, displayType );
       if (strncmp(displayType, "separate", 1) == 0) {
-        unsigned int cpuCount = CoreTemp::countCpus(pkg);
+        unsigned int cpuCount = CoreTemp::countCpus();
         char name[10];
         for (uint cpu = 0; cpu < cpuCount; cpu++) {
           sprintf(name, "CPU%d", cpu);
--- linux/coretemp.cc
+++ linux/coretemp.cc   2015-02-03 10:32:16.237529561 +0100
@@ -1,7 +1,7 @@
 //
-//  Copyright (c) 2008 by Tomi Tapper <tomi.o.tap...@jyu.fi>
+//  Copyright (c) 2008-2014 by Tomi Tapper <tomi.o.tap...@jyu.fi>
 //
-//  Read coretemp reading from /sys and display actual temperature.
+//  Read CPU temperature readings from /sys and display actual temperature.
 //  If actual >= high, actual temp changes color to indicate alarm.
 //
 //  File based on linux/lmstemp.* by
@@ -10,24 +10,29 @@
 //  This file may be distributed under terms of the GPL
 //
 //
-//
+
 #include "coretemp.h"
-#include "xosview.h"
 #include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
 #include <glob.h>
-#include <dirent.h>
-#include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
 #include <fstream>
+#include <iostream>
+#include <string>
 
 #define PATH_SIZE 128
 
 static const char SYS_HWMON[] = "/sys/class/hwmon";
 static const char SYS_CORETEMP[] = "/sys/devices/platform/coretemp";
+static const char SYS_VIATEMP[] = "/sys/devices/platform/via_cputemp";
 
 
 CoreTemp::CoreTemp( XOSView *parent, const char *label, const char *caption, 
int pkg, int cpu )
   : FieldMeter( parent, 3, label, caption, 1, 1, 1 ), _pkg(pkg), _cpu(cpu) {
+  metric_ = true;
   _high = 0;
 }
 
@@ -46,20 +51,91 @@ void CoreTemp::checkResources( void ) {
   priority_ = atoi( parent_->getResource( "coretempPriority" ) );
   SetUsedFormat( parent_->getResource( "coretempUsedFormat" ) );
 
-  unsigned int cpucount = countCpus(_pkg);
+  findSysFiles();
+  if ( _cpus.empty() ) {  // should not happen at this point
+    std::cerr << "BUG: Could not determine sysfs file(s) for coretemp." << 
std::endl;
+    parent_->done(1);
+  }
+
+  // Get TjMax and use it for total, if available.
+  // Not found on k8temp and via-cputemp.
+  std::ifstream file;
+  std::string dummy = _cpus.front();
+  dummy.replace(dummy.find_last_of('_'), 6, "_crit");
+  file.open(dummy.c_str());
+  if ( file.good() ) {
+    file >> total_;
+    file.close();
+    total_ /= 1000.0;
+  }
+  else
+    total_ = atoi( parent_->getResourceOrUseDefault("coretempHighest", "100") 
);
+
+  // Use tTarget/tCtl (when maximum cooling needs to be turned on) as high,
+  // if found. On older Cores this MSR is empty and kernel sets this equal to
+  // tjMax. Not found on k8temp and via-cputemp. On k10temp this is fixed 
value.
+  char l[32];
+  dummy = _cpus.front();
+  dummy.replace(dummy.find_last_of('_'), 6, "_max");
+  file.open(dummy.c_str());
+  if ( file.good() ) {
+    file >> _high;
+    file.close();
+    _high /= 1000.0;
+    snprintf(l, 32, "ACT(\260C)/%d/%d", (int)_high, (int)total_);
+  }
+  else
+    _high = total_;
+
+  if (_high == total_) {  // No tTarget/tCtl
+    // Use user-defined high, or "no high".
+    const char *high = parent_->getResourceOrUseDefault("coretempHigh", NULL);
+    if (high) {
+      _high = atoi(high);
+      snprintf(l, 32, "ACT(\260C)/%d/%d", (int)_high, (int)total_);
+    }
+    else
+      snprintf(l, 32, "ACT(\260C)/HIGH/%d", (int)total_);
+  }
+  legend(l);
+}
+
+/* Find absolute paths of files to be used. */
+void CoreTemp::findSysFiles( void ) {
+  int cpu = 0;
+  unsigned int i = 0, cpucount = countCores(_pkg);
   char name[PATH_SIZE];
   std::string dummy;
   std::ifstream file;
+  glob_t gbuf;
   DIR *dir;
   struct dirent *dent;
 
-  dir = opendir(SYS_HWMON);
-  if (!dir) {
+  // Intel and VIA CPUs.
+  snprintf(name, PATH_SIZE, "%s.%d/temp*_label", SYS_CORETEMP, _pkg);
+  glob(name, 0, NULL, &gbuf);
+  snprintf(name, PATH_SIZE, "%s.%d/temp*_label", SYS_VIATEMP, _pkg);
+  glob(name, GLOB_APPEND, NULL, &gbuf);
+  for (i = 0; i < gbuf.gl_pathc; i++) {
+    file.open(gbuf.gl_pathv[i]);
+    file >> dummy >> cpu;  // "Core n" or "Physical id n"
+    file.close();
+    if ( strncmp(dummy.c_str(), "Core", 4) == 0 ) {
+      strcpy(strrchr(gbuf.gl_pathv[i], '_'), "_input");
+      if (_cpu < 0 || cpu == _cpu)
+        _cpus.push_back(gbuf.gl_pathv[i]);
+    }
+  }
+  globfree(&gbuf);
+  if ( !_cpus.empty() )
+    return;
+
+  // AMD CPUs.
+  if ( !(dir = opendir(SYS_HWMON)) ) {
     std::cerr << "Can not open " << SYS_HWMON << " directory." << std::endl;
     parent_->done(1);
     return;
   }
-
   while ( (dent = readdir(dir)) ) {
     if ( !strncmp(dent->d_name, ".", 1) ||
          !strncmp(dent->d_name, "..", 2) )
@@ -72,73 +148,27 @@ void CoreTemp::checkResources( void ) {
     file >> dummy;
     file.close();
 
-    if (strncmp(dummy.c_str(), "k8temp", 6) == 0) {
-      // each core has two sensors with index starting from 1
+    if ( strncmp(dummy.c_str(), "k8temp", 6) == 0 ||
+         strncmp(dummy.c_str(), "k10temp", 7) == 0 ) {
+      if (cpu++ != _pkg)
+        continue;
+      // K8 core has two sensors with index starting from 1
+      // K10 has only one sensor per physical CPU
       if (_cpu < 0) {  // avg or max
-        for (uint i = 1; i <= cpucount; i++) {
-          snprintf(name, PATH_SIZE, "%s/%s/device/temp%d_input", SYS_HWMON, 
dent->d_name, i);
+        for (i = 1; i <= cpucount; i++) {
+          snprintf(name, PATH_SIZE, "%s/%s/device/temp%d_input",
+                   SYS_HWMON, dent->d_name, i);
           _cpus.push_back(name);
         }
       }
       else {  // single sensor
-        snprintf(name, PATH_SIZE, "%s/%s/device/temp%d_input", SYS_HWMON, 
dent->d_name, _cpu + 1);
+        snprintf(name, PATH_SIZE, "%s/%s/device/temp%d_input",
+                 SYS_HWMON, dent->d_name, _cpu + 1);
         _cpus.push_back(name);
       }
     }
-    else if (strncmp(dummy.c_str(), "coretemp", 8) == 0) {
-      int i = 0, cpu = 0;
-      // Gather the sysfs indices which are not the same as core numbers.
-      // Core numbers are not unique across physical CPUs, but sysfs indices 
are.
-      while (_cpus.size() != cpucount) {
-        snprintf(name, PATH_SIZE, "%s.%d/temp%d_label", SYS_CORETEMP, _pkg, i);
-        file.open(name);
-        if (!file) {
-          i++;
-          continue;
-        }
-        file >> dummy >> cpu;  // "Core n" or "Physical id n"
-        file.close();
-        if (strncmp(dummy.c_str(), "Core", 1) != 0) {
-          i++;
-          continue;
-        }
-        snprintf(name, PATH_SIZE, "%s.%d/temp%d_input", SYS_CORETEMP, _pkg, 
i++);
-        if (_cpu < 0)
-          _cpus.push_back(name);
-        else if (cpu == _cpu) {
-          _cpus.push_back(name);
-          break;
-        }
-      }
-    }
-    else if (strncmp(dummy.c_str(), "k10temp", 7) == 0) {
-      _cpu = 1;
-      snprintf(name, PATH_SIZE, "%s/%s/device/temp%d_input", SYS_HWMON, 
dent->d_name, _cpu);
-      _cpus.push_back(name);  // K10 has only one sensor per physical CPU
-    }
-
-    if (_cpus.empty())
-      continue;
-
-    // sysfs node was found
-    // get TjMax and use it for total if available
-    dummy = _cpus.front();
-    dummy.replace(dummy.find_last_of('_'), 6, "_crit");
-    file.open(dummy.c_str());
-    if (file) {
-      file >> total_;
-      file.close();
-      total_ /= 1000.0;
-    }
-    else
-      total_ = atoi(parent_->getResourceOrUseDefault("coretempHighest", 
"100"));
-
-    _high = total_;
-    closedir(dir);
-    return;
   }
-  std::cerr << "You do not seem to have CPU temperature sensor available." << 
std::endl;
-  parent_->done(1);
+  closedir(dir);
 }
 
 void CoreTemp::checkevent( void ) {
@@ -148,10 +178,8 @@ void CoreTemp::checkevent( void ) {
 
 void CoreTemp::getcoretemp( void ) {
   std::ifstream file;
-  double dummy, high;
-
+  double dummy;
   fields_[0] = 0.0;
-  high = 0.0;
 
   if (_cpu >= 0) {  // only one core
     file.open(_cpus.back().c_str());
@@ -197,24 +225,12 @@ void CoreTemp::getcoretemp( void ) {
     return;
   }
 
-  // Use tCase (when maximum cooling needs to be turned on) as high, if found.
-  // Not found on k8temp, which uses user defined total as high (or default 
100).
-  // This is the same for all cores in package. I don't know if this ever
-  // changes in real world, so it could be read once in checkResources().
-  std::string tcase = _cpus.front();
-  tcase.replace(tcase.find_last_of('_'), 6, "_max");
-  file.open(tcase.c_str());
-  if (file) {
-    file >> high;
-    file.close();
-    high /= 1000.0;
-  }
-  else
-    high = _high;
-
   fields_[0] /= 1000.0;
+  setUsed( fields_[0], total_ );
 
-  fields_[1] = high - fields_[0];
+  if (fields_[0] < 0)
+    fields_[0] = 0.0;
+  fields_[1] = _high - fields_[0];
   if (fields_[1] < 0) { // alarm: T > high
     fields_[1] = 0;
     if (colors_[0] != _highcolor) {
@@ -232,70 +248,102 @@ void CoreTemp::getcoretemp( void ) {
   fields_[2] = total_ - fields_[1] - fields_[0];
   if (fields_[2] < 0)
     fields_[2] = 0;
-
-  setUsed( fields_[0], total_ );
-
-  if (high != _high) {
-    char l[16];
-    _high = high;
-    snprintf(l, 16, "ACT/%d/%d", (int)high, (int)total_);
-    legend(l);
-    drawlegend();
-  }
 }
 
 /* Count sensors available to coretemp in the given package. */
-unsigned int CoreTemp::countCpus(int pkg)
+unsigned int CoreTemp::countCores( unsigned int pkg )
 {
   glob_t gbuf;
   char s[PATH_SIZE];
-  struct stat sbuf;
-  int count = 0;
+  unsigned int i, count = 0, cpu = 0;
+  DIR *dir;
+  struct dirent *dent;
   std::string dummy;
   std::ifstream file;
 
-  snprintf(s, PATH_SIZE, "%s.%d", SYS_CORETEMP, pkg);
-  if (stat(s, &sbuf) == 0) {
-    strncat(s, "/temp*_label", PATH_SIZE - strlen(s) - 1);
-    glob(s, 0, NULL, &gbuf);
-    // loop through paths in gbuf and check if it is a core or package
-    for (uint i = 0; i < gbuf.gl_pathc; i++) {
-      file.open(gbuf.gl_pathv[i]);
-      file >> dummy;
-      file.close();
-      if (strncmp(dummy.c_str(), "Core", 4) == 0)
-        count++;
-    }
-    globfree(&gbuf);
+  // Intel or VIA CPU.
+  snprintf(s, PATH_SIZE, "%s.%d/temp*_label", SYS_CORETEMP, pkg);
+  glob(s, 0, NULL, &gbuf);
+  snprintf(s, PATH_SIZE, "%s.%d/temp*_label", SYS_VIATEMP, pkg);
+  glob(s, GLOB_APPEND, NULL, &gbuf);
+  // loop through paths in gbuf and check if it is a core or package
+  for (i = 0; i < gbuf.gl_pathc; i++) {
+    file.open(gbuf.gl_pathv[i]);
+    file >> dummy;
+    file.close();
+    if ( strncmp(dummy.c_str(), "Core", 4) == 0 )
+      count++;
   }
-  else {
-    DIR *dir;
-    struct dirent *dent;
-    dir = opendir(SYS_HWMON);
-    if (!dir)
-      return 0;
-
-    // loop through hwmon devices and if AMD sensor if found, count its inputs
-    while ( (dent = readdir(dir)) ) {
-      if ( !strncmp(dent->d_name, ".", 1) ||
-           !strncmp(dent->d_name, "..", 2) )
-        continue;
-
-      snprintf(s, PATH_SIZE, "%s/%s/device/name", SYS_HWMON, dent->d_name);
-      file.open(s);
+  globfree(&gbuf);
+  if (count > 0)
+    return count;
+
+  // AMD CPU.
+  if ( !(dir = opendir(SYS_HWMON)) )
+    return 0;
+  // loop through hwmon devices and when AMD sensor is found, count its inputs
+  while ( (dent = readdir(dir)) ) {
+    if ( !strncmp(dent->d_name, ".", 1) ||
+         !strncmp(dent->d_name, "..", 2) )
+      continue;
+    snprintf(s, PATH_SIZE, "%s/%s/device/name", SYS_HWMON, dent->d_name);
+    file.open(s);
+    if ( file.good() ) {
       file >> dummy;
       file.close();
       if ( strncmp(dummy.c_str(), "k8temp", 6) == 0 ||
            strncmp(dummy.c_str(), "k10temp", 7) == 0 ) {
+        if (cpu++ < pkg)
+          continue;
         snprintf(s, PATH_SIZE, "%s/%s/device/temp*_input", SYS_HWMON, 
dent->d_name);
-        break;
+        glob(s, 0, NULL, &gbuf);
+        count += gbuf.gl_pathc;
+        globfree(&gbuf);
       }
     }
-    closedir(dir);
+  }
+  closedir(dir);
+  return count;
+}
+
+/* Count physical CPUs with sensors. */
+unsigned int CoreTemp::countCpus( void )
+{
+  glob_t gbuf;
+  char s[PATH_SIZE];
+  unsigned int count = 0;
+  DIR *dir;
+  struct dirent *dent;
+  std::string dummy;
+  std::ifstream file;
 
-    glob(s, 0, NULL, &gbuf);
-    count = gbuf.gl_pathc;
-    globfree(&gbuf);
+  // Count Intel and VIA packages.
+  snprintf(s, PATH_SIZE, "%s.*", SYS_CORETEMP);
+  glob(s, 0, NULL, &gbuf);
+  snprintf(s, PATH_SIZE, "%s.*", SYS_VIATEMP);
+  glob(s, GLOB_APPEND, NULL, &gbuf);
+  count += gbuf.gl_pathc;
+  globfree(&gbuf);
+  if (count > 0)
+    return count;
+
+  // Count AMD packages.
+  if ( !(dir = opendir(SYS_HWMON)) )
+    return 0;
+  while ( (dent = readdir(dir)) ) {
+    if ( !strncmp(dent->d_name, ".", 1) ||
+         !strncmp(dent->d_name, "..", 2) )
+      continue;
+    snprintf(s, PATH_SIZE, "%s/%s/device/name", SYS_HWMON, dent->d_name);
+    file.open(s);
+    if ( file.good() ) {
+      file >> dummy;
+      file.close();
+      if ( strncmp(dummy.c_str(), "k8temp", 6) == 0 ||
+           strncmp(dummy.c_str(), "k10temp", 7) == 0 )
+        count++;
+    }
   }
+  closedir(dir);
   return count;
 }
--- linux/coretemp.h
+++ linux/coretemp.h    2015-02-03 10:32:16.301619049 +0100
@@ -1,5 +1,5 @@
 //
-//  Copyright (c) 2008 by Tomi Tapper <tomi.o.tap...@jyu.fi>
+//  Copyright (c) 2008-2014 by Tomi Tapper <tomi.o.tap...@jyu.fi>
 //
 //  File based on linux/lmstemp.* by
 //  Copyright (c) 2000, 2006 by Leopold Toetsch <l...@toetsch.at>
@@ -7,12 +7,12 @@
 //  This file may be distributed under terms of the GPL
 //
 //
-//
+
 #ifndef _CORETEMP_H_
 #define _CORETEMP_H_
 
-#include "cpumeter.h"
 #include "fieldmeter.h"
+#include "xosview.h"
 #include <string>
 #include <vector>
 
@@ -26,12 +26,14 @@ public:
   void checkevent( void );
   void checkResources( void );
 
-  static unsigned int countCpus(int pkg);
+  static unsigned int countCores( unsigned int pkg );
+  static unsigned int countCpus( void );
 
 protected:
   void getcoretemp( void );
 
 private:
+  void findSysFiles( void );
   int _pkg, _cpu, _high;
   std::vector<std::string> _cpus;
   unsigned long _actcolor, _highcolor;
++++++ xosview-1.16-coretemp2.patch ++++++
---
 linux/coretemp.cc |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 78 insertions(+), 2 deletions(-)

--- linux/coretemp.cc
+++ linux/coretemp.cc   2015-02-03 13:52:45.786934745 +0100
@@ -1,5 +1,6 @@
 //
 //  Copyright (c) 2008-2014 by Tomi Tapper <tomi.o.tap...@jyu.fi>
+//  Copyright (c) 2015 by Werner Fink <wer...@suse.de>
 //
 //  Read CPU temperature readings from /sys and display actual temperature.
 //  If actual >= high, actual temp changes color to indicate alarm.
@@ -32,7 +33,6 @@ static const char SYS_VIATEMP[] = "/sys/
 
 CoreTemp::CoreTemp( XOSView *parent, const char *label, const char *caption, 
int pkg, int cpu )
   : FieldMeter( parent, 3, label, caption, 1, 1, 1 ), _pkg(pkg), _cpu(cpu) {
-  metric_ = true;
   _high = 0;
 }
 
@@ -55,6 +55,7 @@ void CoreTemp::checkResources( void ) {
   if ( _cpus.empty() ) {  // should not happen at this point
     std::cerr << "BUG: Could not determine sysfs file(s) for coretemp." << 
std::endl;
     parent_->done(1);
+    return;
   }
 
   // Get TjMax and use it for total, if available.
@@ -111,6 +112,44 @@ void CoreTemp::findSysFiles( void ) {
   DIR *dir;
   struct dirent *dent;
 
+  if ((dir = opendir(SYS_HWMON))) {
+    while ( (dent = readdir(dir)) ) {
+      char *core, *path;
+      if ( !strncmp(dent->d_name, ".", 1) ||
+           !strncmp(dent->d_name, "..", 2) )
+        continue;
+      snprintf(name, PATH_SIZE, "%s/%s/device", SYS_HWMON, dent->d_name);
+      core = realpath(name, NULL);
+      if (!core)
+       break;
+      path = strrchr(core, '/');
+      if (path)
+       path++;
+      if (strncmp(path, "coretemp.", 9) == 0) {
+       path = strrchr(name, '/');
+       *path = '\0';
+       snprintf(path, PATH_SIZE - strlen(name), "/temp*_label");
+       glob(name, 0, NULL, &gbuf);
+       for (i = 0; i < gbuf.gl_pathc; i++) {
+         file.open(gbuf.gl_pathv[i]);
+         if (file.good()) {
+           file >> dummy >> cpu;
+           file.close();
+           strcpy(strrchr(gbuf.gl_pathv[i], '_'), "_input");
+           if (_cpu < 0 || cpu == _cpu) {
+             _cpus.push_back(gbuf.gl_pathv[i]);
+           }
+         }
+       }
+       globfree(&gbuf);
+      }
+      free(core);
+    }
+    closedir(dir);
+    if ( !_cpus.empty() )
+      return;
+  }
+
   // Intel and VIA CPUs.
   snprintf(name, PATH_SIZE, "%s.%d/temp*_label", SYS_CORETEMP, _pkg);
   glob(name, 0, NULL, &gbuf);
@@ -122,8 +161,9 @@ void CoreTemp::findSysFiles( void ) {
     file.close();
     if ( strncmp(dummy.c_str(), "Core", 4) == 0 ) {
       strcpy(strrchr(gbuf.gl_pathv[i], '_'), "_input");
-      if (_cpu < 0 || cpu == _cpu)
+      if (_cpu < 0 || cpu == _cpu) {
         _cpus.push_back(gbuf.gl_pathv[i]);
+      }
     }
   }
   globfree(&gbuf);
@@ -261,6 +301,42 @@ unsigned int CoreTemp::countCores( unsig
   std::string dummy;
   std::ifstream file;
 
+  if ((dir = opendir(SYS_HWMON))) {
+    while ( (dent = readdir(dir)) ) {
+      char *core, *path;
+      if ( !strncmp(dent->d_name, ".", 1) ||
+           !strncmp(dent->d_name, "..", 2) )
+        continue;
+      snprintf(s, PATH_SIZE, "%s/%s/device", SYS_HWMON, dent->d_name);
+      core = realpath(s, NULL);
+      if (!core)
+       break;
+      path = strrchr(core, '/');
+      if (path)
+       path++;
+      if (strncmp(path, "coretemp.", 9) == 0) {
+       path = strrchr(s, '/');
+       *path = '\0';
+       snprintf(path, PATH_SIZE - strlen(s), "/temp*_label");
+       glob(s, 0, NULL, &gbuf);
+       for (i = 0; i < gbuf.gl_pathc; i++) {
+         file.open(gbuf.gl_pathv[i]);
+         if (file.good()) {
+           file >> dummy;
+           file.close();
+           if (strncmp(dummy.c_str(), "Core", 4) == 0)
+             count++;
+         }
+       }
+       globfree(&gbuf);
+      }
+      free(core);
+    }
+    closedir(dir);
+    if (count > 0)
+      return count;
+  }
+
   // Intel or VIA CPU.
   snprintf(s, PATH_SIZE, "%s.%d/temp*_label", SYS_CORETEMP, pkg);
   glob(s, 0, NULL, &gbuf);
++++++ xosview-1.16-diskstat.patch ++++++
---
 linux/diskmeter.cc |   58 ++++++++++++++++++++++++++++++++++++++++++++---------
 linux/diskmeter.h  |    3 --
 2 files changed, 50 insertions(+), 11 deletions(-)

--- linux/diskmeter.cc
+++ linux/diskmeter.cc  2015-02-03 10:40:40.646018929 +0000
@@ -209,7 +209,6 @@ void DiskMeter::update_info(const diskma
     float itim = IntervalTimeInMicrosecs();
     // the sum of all disks
     unsigned long long all_bytes_read = 0, all_bytes_written = 0;
-    unsigned int sect_size = 512; // from 
linux-3.10/Documentation/block/stat.txt
 
     // avoid strange values at first call
     // (by this - the first value displayed becomes zero)
@@ -235,13 +234,11 @@ void DiskMeter::update_info(const diskma
             all_bytes_written += it->second - sysfs_write_prev_[it->first];
     }
 
-    all_bytes_read *= sect_size;
-    all_bytes_written *= sect_size;
     XOSDEBUG("disk: read: %llu, written: %llu\n", all_bytes_read, 
all_bytes_written);
 
     // convert rate from bytes/microsec into bytes/second
-    fields_[0] = all_bytes_read * ( 1e6 / itim );
-    fields_[1] = all_bytes_written * ( 1e6 / itim );
+    fields_[0] = all_bytes_read * ( 1e5 / itim );
+    fields_[1] = all_bytes_written * ( 1e5 / itim );
 
     // fix overflow (conversion bug?)
     if (fields_[0] < 0.0)
@@ -273,8 +270,6 @@ void DiskMeter::getsysfsdiskinfo( void )
         // just sum up everything in /sys/block/*/stat
 
   std::string sysfs_dir = _statFileName;
-  std::string disk, tmp;
-  std::ifstream diskstat;
   struct stat buf;
   char line[128];
   unsigned long vals[7];
@@ -292,6 +287,10 @@ void DiskMeter::getsysfsdiskinfo( void )
 
   // visit every /sys/block/*/stat and sum up the values:
   for (struct dirent *dirent; (dirent = readdir(dir)) != NULL; ) {
+    std::string disk;
+    std::ifstream diskstat;
+    unsigned long sect_size;
+
     if (strncmp(dirent->d_name, ".", 1) == 0 ||
         strncmp(dirent->d_name, "..", 2) == 0 ||
         strncmp(dirent->d_name, "loop", 4) == 0 ||
@@ -300,11 +299,52 @@ void DiskMeter::getsysfsdiskinfo( void )
 
     disk = sysfs_dir + dirent->d_name;
     if (stat(disk.c_str(), &buf) == 0 && buf.st_mode & S_IFDIR) {
+      std::string tmp;
+
       // only scan for real HW (raid, md, and lvm all mapped on them)
       tmp = disk + "/device";
       if (lstat(tmp.c_str(), &buf) != 0 || (buf.st_mode & S_IFLNK) == 0)
         continue;
 
+      // ignore removable devices
+      tmp = disk + "/removable";
+      if (stat(tmp.c_str(), &buf) == 0 && buf.st_mode & S_IFREG) {
+       std::ifstream removable;
+       int isremovable = 0;
+
+       removable.open(tmp.c_str());
+       if (removable.good()) {
+         removable >> isremovable;
+         removable.close();
+         removable.clear();
+       }
+       if (isremovable)
+         continue;
+      }
+
+      tmp = "/dev/";
+      tmp += dirent->d_name;
+      if (lstat(tmp.c_str(), &buf) == 0)
+       sect_size = (unsigned long)buf.st_blksize;
+
+      if (sect_size == 0UL) {
+       tmp = disk + "/queue/hw_sectors_kb";
+       if (stat(tmp.c_str(), &buf) == 0 && (buf.st_mode & S_IFREG)) {
+         std::ifstream hw_sectors_kb;
+
+         hw_sectors_kb.open(tmp.c_str());
+         if (hw_sectors_kb.good()) {
+           hw_sectors_kb >> sect_size;
+           //XOSDEBUG("disk stat: %lu\n", sect_size);
+           hw_sectors_kb.close();
+           hw_sectors_kb.clear();
+         }
+       }
+      }
+
+      if (sect_size == 0UL)
+       sect_size = 512;
+
       // is a dir, locate 'stat' file in it
       disk += "/stat";
       diskstat.open(disk.c_str());
@@ -315,8 +355,8 @@ void DiskMeter::getsysfsdiskinfo( void )
           vals[i] = strtoul(cur, &end, 10);
           cur = end;
         }
-        reads[dirent->d_name]  = vals[2];
-        writes[dirent->d_name] = vals[6];
+        reads[dirent->d_name]  = (unsigned long long)vals[2] * (unsigned long 
long)sect_size;
+        writes[dirent->d_name] = (unsigned long long)vals[6] * (unsigned long 
long)sect_size;
 
         XOSDEBUG("disk stat: %s | read: %lu, written: %lu\n", disk.c_str(), 
vals[2], vals[6]);
         diskstat.close();
--- linux/diskmeter.h
+++ linux/diskmeter.h   2013-04-09 10:52:05.000000000 +0000
@@ -11,8 +11,7 @@
 #include <map>
 #include <string>
 
-typedef std::map<std::string, unsigned long> diskmap;
-
+typedef std::map<std::string, unsigned long long> diskmap;
 
 class DiskMeter : public FieldMeterGraph
     {
++++++ xosview-1.16-serial.patch ++++++
---
 linux/serialmeter.cc |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- linux/serialmeter.cc
+++ linux/serialmeter.cc        2015-02-03 09:44:09.245705213 +0000
@@ -29,10 +29,10 @@ typedef unsigned long long u64;
 
 #include <unistd.h>
 #if defined(GNULIBC) || defined(__GLIBC__)
-#if !defined(__powerpc__) && !defined(__hppa__) && !defined(__mips__) && 
!defined(__sparc__) && !defined(__sh__) && !defined(__s390__) && 
!defined(__s390x__) && !defined(__m68k__)
+#if !defined(__aarch64__) && !defined(__powerpc__) && !defined(__hppa__) && 
!defined(__mips__) && !defined(__sparc__) && !defined(__sh__) && 
!defined(__s390__) && !defined(__s390x__) && !defined(__m68k__)
 #include <sys/io.h>
 #endif
-#if !defined(__alpha__) && !defined(__sparc__) && !defined(__powerpc__) && 
!defined(__ia64__) && !defined(__hppa__) && !defined(__arm__) && 
!defined(__mips__) && !defined(__sh__) && !defined(__s390__) && !defined 
(__s390x__) && !defined(__m68k__)
+#if !defined(__aarch64__) && !defined(__alpha__) && !defined(__sparc__) && 
!defined(__powerpc__) && !defined(__ia64__) && !defined(__hppa__) && 
!defined(__arm__) && !defined(__mips__) && !defined(__sh__) && 
!defined(__s390__) && !defined (__s390x__) && !defined(__m68k__)
 #include <sys/perm.h>
 #define HAVE_IOPERM
 #endif
++++++ xosview-1.16.dif ++++++
++++ 891 lines (skipped)


-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to