Compare commits
5 Commits
2.34.1
...
LIBGTOP_2_
Author | SHA1 | Date | |
---|---|---|---|
|
e1b9c9599b | ||
|
41df52e5c4 | ||
|
2ec06b3d60 | ||
|
e1d6e713fc | ||
|
1634698050 |
11
NEWS
11
NEWS
@@ -1,3 +1,14 @@
|
||||
30 June 2008: Overview of changes in 2.22.3
|
||||
===========================================
|
||||
* linux:
|
||||
- Fixed glibtop_get_fsusage with kernel >= 2.6.25.
|
||||
Closes #539360.
|
||||
|
||||
24 May 2008: Overview of changes in 2.22.2
|
||||
==========================================
|
||||
* linux:
|
||||
- fixed parsing of huge /proc/stat.
|
||||
|
||||
04 April 2008: Overview of changes in 2.22.1
|
||||
============================================
|
||||
* Fixed compilation/dist for !linux.
|
||||
|
@@ -4,7 +4,7 @@ dnl
|
||||
|
||||
m4_define([libgtop_major_version], [2])
|
||||
m4_define([libgtop_minor_version], [22])
|
||||
m4_define([libgtop_micro_version], [1])
|
||||
m4_define([libgtop_micro_version], [3])
|
||||
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
|
||||
|
||||
dnl increment if the interface has additions, changes, removals.
|
||||
|
@@ -59,9 +59,35 @@ get_partition(const char *mountpoint)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Bug #539360.
|
||||
/sys/.../stat format is partially defined in
|
||||
linux/Documentation/block/stat.txt (looks outdated). Before linux
|
||||
2.5.25, /sys/block/%s/stat and /sys/block/%s/%s/stat were not the
|
||||
same, but the following commit changed the latter to have the same
|
||||
format and broke compatibility.
|
||||
|
||||
Commit 34e8beac92c27d292938065f8375842d2840767c
|
||||
Author: Jerome Marchand <jmarchan@redhat.com>
|
||||
Date: Fri Feb 8 11:04:55 2008 +0100
|
||||
|
||||
Enhanced partition statistics: sysfs
|
||||
|
||||
Reports enhanced partition statistics in sysfs.
|
||||
|
||||
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
||||
|
||||
fs/partitions/check.c | 22 +++++++++++++++++++---
|
||||
1 files changed, 19 insertions(+), 3 deletions(-)
|
||||
|
||||
*/
|
||||
|
||||
static void
|
||||
get_sys_path(const char *device, char **stat_path, const char **parse_format)
|
||||
get_sys_path(glibtop* server, const char *device, char **stat_path, const char **parse_format)
|
||||
{
|
||||
const char* linux_2_6_25_format = "%*llu %*llu %llu %*llu"
|
||||
"%*llu %*llu %llu %*llu";
|
||||
|
||||
if(g_str_has_prefix(device, "hd") || g_str_has_prefix(device, "sd"))
|
||||
{
|
||||
char *prefix;
|
||||
@@ -79,12 +105,18 @@ get_sys_path(const char *device, char **stat_path, const char **parse_format)
|
||||
g_free(prefix);
|
||||
|
||||
*stat_path = path;
|
||||
*parse_format = "%*llu %llu %*llu %llu";
|
||||
if (server->os_version_code < LINUX_VERSION_CODE(2, 6, 25))
|
||||
*parse_format = "%*llu %llu %*llu %llu";
|
||||
else
|
||||
*parse_format = linux_2_6_25_format;
|
||||
}
|
||||
else
|
||||
{
|
||||
*stat_path = g_strdup_printf("/sys/block/%s/stat", device);
|
||||
*parse_format = "%*llu %*llu %llu %*llu %*llu %*llu %llu";
|
||||
if (server->os_version_code < LINUX_VERSION_CODE(2, 6, 25))
|
||||
*parse_format = "%*llu %*llu %llu %*llu %*llu %*llu %llu";
|
||||
else
|
||||
*parse_format = linux_2_6_25_format;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +133,7 @@ static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||
device = get_partition(path);
|
||||
if(!device) return;
|
||||
|
||||
get_sys_path(device, &filename, &format);
|
||||
get_sys_path(server, device, &filename, &format);
|
||||
g_free(device);
|
||||
|
||||
ret = try_file_to_buffer(buffer, sizeof buffer, filename);
|
||||
|
@@ -119,20 +119,27 @@ file_to_buffer(glibtop *server, char *buffer, size_t bufsiz, const char *filenam
|
||||
static unsigned long
|
||||
read_boot_time(glibtop *server)
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
char *btime;
|
||||
char* line = NULL;
|
||||
size_t size = 0;
|
||||
FILE* stat;
|
||||
unsigned long btime = 0;
|
||||
|
||||
file_to_buffer(server, buffer, sizeof buffer, "/proc/stat");
|
||||
|
||||
btime = strstr(buffer, "btime");
|
||||
|
||||
if (!btime) {
|
||||
glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
|
||||
return 0UL;
|
||||
if (!(stat = fopen("/proc/stat", "r"))) {
|
||||
glibtop_error_io_r(server, "fopen(\"/proc/stat\")");
|
||||
goto out;
|
||||
}
|
||||
|
||||
btime = skip_token(btime);
|
||||
return strtoul(btime, NULL, 10);
|
||||
while (getline(&line, &size, stat) != -1) {
|
||||
if (!strncmp(line, "btime", 5)) {
|
||||
btime = strtoul(skip_token(line), NULL, 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(line);
|
||||
fclose(stat);
|
||||
out:
|
||||
return btime;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user