Fixed stat parsing for md devices. Patch by Martin Bailey
2007-03-13 Benoît Dejean <benoit@placenet.org> * fsusage.c: (get_sys_path), (linux_2_6_0): Fixed stat parsing for md devices. Patch by Martin Bailey <martin@pcalpha.com>. svn path=/trunk/; revision=2566
This commit is contained in:
committed by
Benoît Dejean
parent
44ff5b7599
commit
2f6439a239
@@ -1,3 +1,10 @@
|
|||||||
|
2007-03-13 Benoît Dejean <benoit@placenet.org>
|
||||||
|
|
||||||
|
* fsusage.c: (get_sys_path), (linux_2_6_0):
|
||||||
|
|
||||||
|
Fixed stat parsing for md devices.
|
||||||
|
Patch by Martin Bailey <martin@pcalpha.com>.
|
||||||
|
|
||||||
2007-02-15 Benoît Dejean <benoit@placenet.org>
|
2007-02-15 Benoît Dejean <benoit@placenet.org>
|
||||||
|
|
||||||
* procmap.c: (add_smaps):
|
* procmap.c: (add_smaps):
|
||||||
|
@@ -62,8 +62,8 @@ get_partition(const char *mountpoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static void
|
||||||
get_sys_path(const char *device)
|
get_sys_path(const char *device, char **stat_path, const char **parse_format)
|
||||||
{
|
{
|
||||||
if(g_str_has_prefix(device, "hd") || g_str_has_prefix(device, "sd"))
|
if(g_str_has_prefix(device, "hd") || g_str_has_prefix(device, "sd"))
|
||||||
{
|
{
|
||||||
@@ -80,12 +80,14 @@ get_sys_path(const char *device)
|
|||||||
prefix, device);
|
prefix, device);
|
||||||
|
|
||||||
g_free(prefix);
|
g_free(prefix);
|
||||||
return path;
|
|
||||||
|
|
||||||
|
*stat_path = path;
|
||||||
|
*parse_format = "%*llu %llu %*llu %llu";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return g_strdup_printf("/sys/block/%s/stat", device);
|
*stat_path = g_strdup_printf("/sys/block/%s/stat", device);
|
||||||
|
*parse_format = "%*llu %*llu %llu %*llu %*llu %*llu %llu";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,26 +97,26 @@ static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
|||||||
{
|
{
|
||||||
char *device;
|
char *device;
|
||||||
char *filename;
|
char *filename;
|
||||||
|
const char *format;
|
||||||
int ret;
|
int ret;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
char *p;
|
|
||||||
|
|
||||||
device = get_partition(path);
|
device = get_partition(path);
|
||||||
if(!device) return;
|
if(!device) return;
|
||||||
|
|
||||||
filename = get_sys_path(device);
|
get_sys_path(device, &filename, &format);
|
||||||
g_free(device);
|
g_free(device);
|
||||||
|
|
||||||
ret = try_file_to_buffer(buffer, filename);
|
ret = try_file_to_buffer(buffer, filename);
|
||||||
g_free(filename);
|
|
||||||
|
|
||||||
if(ret < 0) return;
|
if(ret < 0) return;
|
||||||
|
|
||||||
p = buffer;
|
if (sscanf(buffer, format, &buf->read, &buf->write) != 2) {
|
||||||
p = skip_token(p);
|
glibtop_warn_io_r(server, "Could not parse %s", filename);
|
||||||
buf->read = strtoull(p, &p, 0);
|
return;
|
||||||
p = skip_token(p);
|
}
|
||||||
buf->write = strtoull(p, &p, 0);
|
|
||||||
|
g_free(filename);
|
||||||
|
|
||||||
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user