summaryrefslogtreecommitdiff
path: root/sysdeps/linux
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2020-11-06 09:52:00 -0600
committerMichael Catanzaro <mcatanzaro@gnome.org>2020-11-06 09:52:00 -0600
commitea08151ae6582a438db76b738293a0194c964b88 (patch)
tree2456ecc117edf25ce43fecf625946a40e72007f6 /sysdeps/linux
parent2229253e11ae5c729a703f0c72e006f46746c592 (diff)
downloadlibgtop-ea08151ae6582a438db76b738293a0194c964b88.tar.gz
Revert "Code clean up and add example"
This reverts commit 7396970afe2290488fd072612a650353dd13a16d.
Diffstat (limited to 'sysdeps/linux')
-rw-r--r--sysdeps/linux/disk.c33
-rw-r--r--sysdeps/linux/glibtop_private.h2
2 files changed, 10 insertions, 25 deletions
diff --git a/sysdeps/linux/disk.c b/sysdeps/linux/disk.c
index c2d341f6..3ad74bcc 100644
--- a/sysdeps/linux/disk.c
+++ b/sysdeps/linux/disk.c
@@ -48,7 +48,7 @@ _glibtop_init_disk_s (glibtop *server)
// Handle LVM and RAID //
void
-find_primary_part (partition_info *primary_part, const char *m)
+find_primary_part (_partition_info *primary_part, const char *m)
{
int n = 0, tlvl = 0;
char name[256]="",type[256]="";
@@ -190,7 +190,7 @@ find_primary_part (partition_info *primary_part, const char *m)
}
int
-is_virtual_drive (partition_info *primary_part, const char *p)
+is_virtual_drive (_partition_info *primary_part, const char *p)
{
int i;
char name[256];
@@ -220,27 +220,10 @@ is_virtual_drive (partition_info *primary_part, const char *p)
return test;
}
-int
-max_lines (const char *p)
-{
- char temp[10];
- int count = 0;
-
- while (sscanf (p, "%s", temp) == 1)
- {
-
- p = skip_line(p);
- count++;
-
- }
-
- return count;
-}
-
void
glibtop_get_disk_s (glibtop *server, glibtop_disk *buf)
{
- partition_info primary_part[GLIBTOP_NDISK];
+ _partition_info primary_part[GLIBTOP_NDISK];
char buffer [STAT_BUFSIZ], *p, map_buffer [STAT_BUFSIZ], *m;
int i;
@@ -250,6 +233,8 @@ glibtop_get_disk_s (glibtop *server, glibtop_disk *buf)
get_from_pipe (map_buffer, CMD_PIPE);
+ server->ndisk = GLIBTOP_NDISK;
+
/*
* GLOBAL
*/
@@ -261,23 +246,23 @@ glibtop_get_disk_s (glibtop *server, glibtop_disk *buf)
* PER DISK
*/
- server->ndisk = max_lines(p);
-
find_primary_part (primary_part, m);
- for (i = 0; i < server->ndisk; i++) {
+ for (i = 0; i <= server->ndisk; i++) {
p = skip_multiple_token (p,2);
// skip if disk is the raw device
if (!is_virtual_drive (primary_part, p)) {
- server->ndisk--;
p = skip_line (p); /* move to ^ */
p = skip_multiple_token (p, 2);
}
+ if (!check_disk_line_warn (server, p, i))
+ break;
+
p = skip_token (p); /* prev xdisk_name */
p = skip_token (p); /* prev xdisk_reads_completed */
p = skip_token (p); /* prev xdisk_reads_merged */
diff --git a/sysdeps/linux/glibtop_private.h b/sysdeps/linux/glibtop_private.h
index 39101163..66fed54c 100644
--- a/sysdeps/linux/glibtop_private.h
+++ b/sysdeps/linux/glibtop_private.h
@@ -62,7 +62,7 @@ skip_line (const char *p)
}
void
-get_from_pipe (char *buffer, const char *cmd);
+get_from_pipe (char *buffer, const char *cmd)
/*
* Smart strtoul which handles binary suffixes