summaryrefslogtreecommitdiff
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
parent2229253e11ae5c729a703f0c72e006f46746c592 (diff)
downloadlibgtop-ea08151ae6582a438db76b738293a0194c964b88.tar.gz
Revert "Code clean up and add example"
This reverts commit 7396970afe2290488fd072612a650353dd13a16d.
-rwxr-xr-xautogen.sh28
-rw-r--r--configure.ac10
-rw-r--r--doc/reference/libgtop-sections.txt34
-rw-r--r--examples/Makefile.am3
-rw-r--r--examples/disk.c65
-rw-r--r--features.def1
-rw-r--r--include/glibtop/Makefile.am2
-rw-r--r--include/glibtop/command.h3
-rw-r--r--include/glibtop/disk.h6
-rw-r--r--include/glibtop/union.h2
-rw-r--r--lib/sysdeps.c3
-rw-r--r--libgtop-2.0.pc.in2
-rw-r--r--libgtop.spec.in1
-rw-r--r--src/daemon/main.c2
-rw-r--r--src/daemon/slave.c6
-rw-r--r--sysdeps/common/default.c4
-rw-r--r--sysdeps/linux/disk.c33
-rw-r--r--sysdeps/linux/glibtop_private.h2
-rw-r--r--sysdeps/stub/Makefile.am2
-rw-r--r--sysdeps/stub_suid/Makefile.am2
-rw-r--r--sysdeps/stub_suid/disk.c47
21 files changed, 20 insertions, 238 deletions
diff --git a/autogen.sh b/autogen.sh
index ab75b974..9d394bff 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,33 +1,5 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
-RED='\033[0;31m'
-NC='\033[0m' # No Color
-
-case "$(uname -s)" in
- Linux)
- if ! [ -x "$(command -v lsblk)" ]; then
- echo '' >&2
- echo -e "${RED}*** ERROR:${NC} lsblk cannot be found. Try installing util-linux or util-linux-ng ${RED}***${NC}" >&2
- echo '' >&2
- exit 1
- fi
- if ! [ -x "$(command -v sed)" ]; then
- echo '' >&2
- echo -e "${RED}*** ERROR:${NC} sed cannot be found. ***" >&2
- echo '' >&2
- exit 1
- fi
- if ! [ -x "$(command -v tr)" ]; then
- echo '' >&2
- echo -e "${RED}*** ERROR:${NC} tr cannot be found. ***" >&2
- echo '' >&2
- exit 1
- fi
- ;;
- *)
- ;;
-esac
-
test -n "$srcdir" || srcdir=$(dirname "$0")
test -n "$srcdir" || srcdir=.
diff --git a/configure.ac b/configure.ac
index 5426daf1..d7215bf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,16 +71,6 @@ dnl Most people should have a working perl interpreter on their system
AC_CHECK_PROGS(PERL, perl5 perl)
test -z "$PERL" && AC_MSG_ERROR([You need to have a working perl interpreter.])
-case "${host_os}" in
- linux*)
- AC_CHECK_TOOL(LSBLK,lsblk)
- AC_CHECK_TOOL(SED,sed)
- AC_CHECK_TOOL(TR,tr)
- ;;
- *)
- ;;
-esac
-
AC_CHECK_TOOL(CC,gcc)
AC_CHECK_TOOL(RANLIB,ranlib)
AC_CHECK_TOOL(AS,as)
diff --git a/doc/reference/libgtop-sections.txt b/doc/reference/libgtop-sections.txt
index 3d6d710d..ba878943 100644
--- a/doc/reference/libgtop-sections.txt
+++ b/doc/reference/libgtop-sections.txt
@@ -29,7 +29,6 @@ glibtop_close_p
GLIBTOP_CMND_QUIT
GLIBTOP_CMND_SYSDEPS
GLIBTOP_CMND_CPU
-GLIBTOP_CMND_DISK
GLIBTOP_CMND_MEM
GLIBTOP_CMND_SWAP
GLIBTOP_CMND_UPTIME
@@ -679,39 +678,6 @@ glibtop_init_cpu_s
glibtop_get_cpu_s
</SECTION>
-<INCLUDE>glibtop/disk.h</INCLUDE>
-<SECTION>
-<FILE>disk</FILE>
-GLIBTOP_DISK_TOTAL
-GLIBTOP_DISK_USER
-GLIBTOP_DISK_NICE
-GLIBTOP_DISK_SYS
-GLIBTOP_DISK_IDLE
-GLIBTOP_DISK_FREQUENCY
-GLIBTOP_XDISK_TOTAL
-GLIBTOP_XDISK_USER
-GLIBTOP_XDISK_NICE
-GLIBTOP_XDISK_SYS
-GLIBTOP_XDISK_IDLE
-GLIBTOP_XDISK_FLAGS
-GLIBTOP_DISK_IOWAIT
-GLIBTOP_DISK_IRQ
-GLIBTOP_DISK_SOFTIRQ
-GLIBTOP_XDISK_IOWAIT
-GLIBTOP_XDISK_IRQ
-GLIBTOP_XDISK_SOFTIRQ
-GLIBTOP_MAX_DISK
-GLIBTOP_NDISK
-glibtop_disk
-glibtop_get_disk
-glibtop_get_disk_r
-glibtop_get_disk_l
-glibtop_init_disk_p
-glibtop_get_disk_p
-glibtop_init_disk_s
-glibtop_get_disk_s
-</SECTION>
-
<INCLUDE>glibtop/swap.h</INCLUDE>
<SECTION>
<FILE>swap</FILE>
diff --git a/examples/Makefile.am b/examples/Makefile.am
index ef192787..25585e04 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -34,9 +34,6 @@ mountlist_LDADD = $(top_builddir)/lib/libgtop-2.0.la
smp_SOURCES = smp.c
smp_LDADD = $(top_builddir)/lib/libgtop-2.0.la -lm
-disk_SOURCES = disk.c
-disk_LDADD = $(top_builddir)/lib/libgtop-2.0.la -lm
-
timings_SOURCES = timings.c
timings_LDADD = $(top_builddir)/lib/libgtop-2.0.la
diff --git a/examples/disk.c b/examples/disk.c
deleted file mode 100644
index c3c61142..00000000
--- a/examples/disk.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (C) 1998-99 Martin Baulig
- This file is part of LibGTop 1.0.
-
- Contributed by James Dominic P. Guana <guana.histark@gmail.com>, May 2020.
-
- LibGTop is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License,
- or (at your option) any later version.
-
- LibGTop is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with LibGTop; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <config.h>
-
-#include <locale.h>
-#include <libintl.h>
-#include <math.h>
-#include <stdio.h>
-
-#include <glibtop.h>
-#include <glibtop/disk.h>
-
-int
-main (int argc, char *argv [])
-{
- glibtop_disk disk;
- char separator [BUFSIZ];
- int ndisk, i;
-
- glibtop_init();
-
- glibtop_get_disk (&disk);
-
- ndisk = glibtop_global_server->ndisk ? glibtop_global_server->ndisk : 1;
-
- memset (separator, '-', 91);
- separator [92] = '\0';
-
- printf("\n\n");
- printf ("ELAPSE ");
- printf ("Read Time Read Write Time Write\n");
- printf ("%s\n", separator);
-
- for (i = 0; i < ndisk; i++) {
- printf ("DISK %3d : %12lu %12lu %12lu %12lu\n", i,
- (unsigned long) disk.xdisk_sectors_read [i],
- (unsigned long) disk.xdisk_time_read [i],
- (unsigned long) disk.xdisk_sectors_write [i],
- (unsigned long) disk.xdisk_time_write [i]);
-
- }
-
- printf ("%s\n\n\n", separator);
-
- exit (0);
-}
diff --git a/features.def b/features.def
index 50cbe72a..faab87b1 100644
--- a/features.def
+++ b/features.def
@@ -1,5 +1,4 @@
void|cpu
-void|disk
void|mem
void|swap
void|uptime
diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am
index da78ca93..6d0e055f 100644
--- a/include/glibtop/Makefile.am
+++ b/include/glibtop/Makefile.am
@@ -2,7 +2,7 @@ glibtopdir = $(includedir)/libgtop-2.0/glibtop
glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
sem_limits.h uptime.h command.h mem.h proclist.h \
- proctime.h shm_limits.h cpu.h disk.h msg_limits.h \
+ proctime.h shm_limits.h cpu.h msg_limits.h \
procmem.h procuid.h swap.h \
procsegment.h sysdeps.h global.h \
procsignal.h union.h gnuserv.h \
diff --git a/include/glibtop/command.h b/include/glibtop/command.h
index 31e89589..9a0e47b1 100644
--- a/include/glibtop/command.h
+++ b/include/glibtop/command.h
@@ -60,9 +60,8 @@ G_BEGIN_DECLS
#define GLIBTOP_CMND_PROC_WD 26
#define GLIBTOP_CMND_PROC_AFFINITY 27
#define GLIBTOP_CMND_PROC_IO 28
-#define GLIBTOP_CMND_DISK 29
-#define GLIBTOP_MAX_CMND 30
+#define GLIBTOP_MAX_CMND 29
#define _GLIBTOP_PARAM_SIZE 16
diff --git a/include/glibtop/disk.h b/include/glibtop/disk.h
index 292924f6..cdde7796 100644
--- a/include/glibtop/disk.h
+++ b/include/glibtop/disk.h
@@ -46,20 +46,16 @@ struct _partition_info
{
char name[256];
char type[256];
- char raid_num[256];
+ char raid_num[256];
int max;
};
-typedef struct _partition_info partition_info;
-
struct _glibtop_disk
{
- guint64 flags;
guint64 xdisk_sectors_read [GLIBTOP_NDISK]; /* GLIBTOP_XDISK_SECTORS_READ */
guint64 xdisk_time_read [GLIBTOP_NDISK]; /* GLIBTOP_XDISK_TIME_READ */
guint64 xdisk_sectors_write [GLIBTOP_NDISK]; /* GLIBTOP_XDISK_SECTORS_WRITE */
guint64 xdisk_time_write [GLIBTOP_NDISK]; /* GLIBTOP_XDISK_TIME_WRITE */
- guint64 xdisk_flags;
};
void glibtop_get_disk (glibtop_disk *buf);
diff --git a/include/glibtop/union.h b/include/glibtop/union.h
index eb57cfc0..bda7c576 100644
--- a/include/glibtop/union.h
+++ b/include/glibtop/union.h
@@ -61,7 +61,7 @@ typedef union _glibtop_union glibtop_union;
union _glibtop_union
{
glibtop_cpu cpu;
- glibtop_disk disk;
+ glibtop_disk disk;
glibtop_mem mem;
glibtop_swap swap;
glibtop_uptime uptime;
diff --git a/lib/sysdeps.c b/lib/sysdeps.c
index beb950e8..96292568 100644
--- a/lib/sysdeps.c
+++ b/lib/sysdeps.c
@@ -139,9 +139,6 @@ const _glibtop_init_func_t _glibtop_init_hook_p [] = {
#if GLIBTOP_SUID_CPU
_glibtop_init_cpu_p,
#endif
-#if GLIBTOP_SUID_DISK
- _glibtop_init_disk_p,
-#endif
#if GLIBTOP_SUID_MEM
_glibtop_init_mem_p,
#endif
diff --git a/libgtop-2.0.pc.in b/libgtop-2.0.pc.in
index 4381ab20..e1753322 100644
--- a/libgtop-2.0.pc.in
+++ b/libgtop-2.0.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
Name: libgtop
Description: Portable System Access Library
-Requires: glib-2.0, util-linux
+Requires: glib-2.0
Version: @VERSION@
Libs: -L${libdir} -lgtop-2.0
Cflags: -I${includedir}/libgtop-2.0
diff --git a/libgtop.spec.in b/libgtop.spec.in
index f4fefa5b..5957868e 100644
--- a/libgtop.spec.in
+++ b/libgtop.spec.in
@@ -5,7 +5,6 @@
%define prefix /usr
Summary: LibGTop library
-Requires: util-linux, sed
Name: libgtop
Version: %ver
Release: %rel
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 88e19a09..34cbaf50 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -98,7 +98,7 @@ handle_parent_connection (int s)
do_output (s, resp, _offset_data (cpu), 0, NULL);
break;
case GLIBTOP_CMND_DISK:
- glibtop_get_disk_l (server, &resp->u.data.disk);
+ glibtop_get_disk_l (server, &resp->u.disk.cpu);
do_output (s, resp, _offset_data (disk), 0, NULL);
break;
case GLIBTOP_CMND_MEM:
diff --git a/src/daemon/slave.c b/src/daemon/slave.c
index 6e80b2b8..e15f1efc 100644
--- a/src/daemon/slave.c
+++ b/src/daemon/slave.c
@@ -135,12 +135,6 @@ handle_slave_command (glibtop_command *cmnd, glibtop_response *resp,
resp->offset = _offset_data (cpu);
break;
#endif
-#if GLIBTOP_SUID_DISK
- case GLIBTOP_CMND_DISK:
- glibtop_get_disk_p (server, &resp->u.data.disk);
- resp->offset = _offset_data (disk);
- break;
-#endif
#if GLIBTOP_SUID_MEM
case GLIBTOP_CMND_MEM:
glibtop_get_mem_p (server, &resp->u.data.mem);
diff --git a/sysdeps/common/default.c b/sysdeps/common/default.c
index ff6c3ecd..653a4f5a 100644
--- a/sysdeps/common/default.c
+++ b/sysdeps/common/default.c
@@ -72,9 +72,9 @@ glibtop_get_cpu(glibtop_cpu *buf)
*
*/
void
-glibtop_get_disk (glibtop_disk *buf)
+glibtop_get_cpu (glibtop_cpu *buf)
{
- glibtop_get_disk_l (glibtop_global_server, buf);
+ glibtop_get_cpu_l (glibtop_global_server, buf);
}
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
diff --git a/sysdeps/stub/Makefile.am b/sysdeps/stub/Makefile.am
index 6d9ce727..f4219edb 100644
--- a/sysdeps/stub/Makefile.am
+++ b/sysdeps/stub/Makefile.am
@@ -3,7 +3,7 @@ AM_CPPFLAGS = @AM_CPPFLAGS@
noinst_LTLIBRARIES = libgtop_sysdeps-2.0.la
-libgtop_sysdeps_2_0_la_SOURCES = open.c close.c siglist.c cpu.c disk.c mem.c swap.c \
+libgtop_sysdeps_2_0_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \
uptime.c loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
diff --git a/sysdeps/stub_suid/Makefile.am b/sysdeps/stub_suid/Makefile.am
index 3f1bf958..fcc7daf9 100644
--- a/sysdeps/stub_suid/Makefile.am
+++ b/sysdeps/stub_suid/Makefile.am
@@ -7,7 +7,7 @@ libgtop_sysdeps_2_0_la_SOURCES = nosuid.c siglist.c
libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
-libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c siglist.c cpu.c disk.c mem.c swap.c \
+libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c siglist.c cpu.c mem.c swap.c \
uptime.c loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
diff --git a/sysdeps/stub_suid/disk.c b/sysdeps/stub_suid/disk.c
deleted file mode 100644
index ed5cda02..00000000
--- a/sysdeps/stub_suid/disk.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (C) 1998-99 Martin Baulig
- This file is part of LibGTop 1.0.
-
- Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
-
- LibGTop is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License,
- or (at your option) any later version.
-
- LibGTop is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with LibGTop; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include <config.h>
-#include <glibtop.h>
-#include <glibtop/error.h>
-#include <glibtop/disk.h>
-
-#include <glibtop_suid.h>
-
-static const unsigned long _glibtop_sysdeps_disk = 0;
-
-/* Init function. */
-
-void
-_glibtop_init_disk_p (glibtop *server)
-{
- server->sysdeps.disk = _glibtop_sysdeps_disk;
-}
-
-/* Provides information about disk usage. */
-
-void
-glibtop_get_disk_p (glibtop *server, glibtop_disk *buf)
-{
- glibtop_init_p (server, GLIBTOP_SYSDEPS_DISK, 0);
-
- memset (buf, 0, sizeof (glibtop_disk));
-}