summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin@home-of-linux.org>1998-07-22 22:56:09 +0000
committerMartin Baulig <martin@src.gnome.org>1998-07-22 22:56:09 +0000
commit954a78f2007b2de71e8fba1078e11cd6c1456afc (patch)
tree66b759f492b68585d01876d7b678f8deb8f5c87a
parenta90bffbbf66ff569aee93f918c943aad87a37464 (diff)
downloadlibgtop-954a78f2007b2de71e8fba1078e11cd6c1456afc.tar.gz
New file.
1998-07-22 Martin Baulig <martin@home-of-linux.org> * include/glibtop/fsusage.h: New file. * features.def: Added new feature `fsusage'. * sysdeps/common/fsusage.c (glibtop_get_fsusage_s): New function. (get_fs_usage): Declared as `static'. * sysdeps/names/fsusage.c: New file.
-rw-r--r--ChangeLog9
-rw-r--r--examples/mountlist.c18
-rw-r--r--features.def1
-rw-r--r--include/glibtop/command.h3
-rw-r--r--include/glibtop/fsusage.h90
-rw-r--r--include/glibtop/sysdeps.h6
-rw-r--r--include/glibtop/union.h2
-rw-r--r--lib/lib.awk9
-rw-r--r--src/daemon/main.c6
-rw-r--r--sysdeps/common/fsusage.c29
-rw-r--r--sysdeps/common/fsusage.h10
-rw-r--r--sysdeps/guile/guile.awk6
-rw-r--r--sysdeps/names/Makefile.am3
-rw-r--r--sysdeps/names/fsusage.c51
-rw-r--r--sysdeps/names/sysdeps.c10
15 files changed, 234 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index ce2decfc..d1aecb00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
1998-07-22 Martin Baulig <martin@home-of-linux.org>
+ * include/glibtop/fsusage.h: New file.
+
+ * features.def: Added new feature `fsusage'.
+
+ * sysdeps/common/fsusage.c (glibtop_get_fsusage_s): New function.
+ (get_fs_usage): Declared as `static'.
+
+ * sysdeps/names/fsusage.c: New file.
+
* include/glibtop/mountlist.h: New file.
* features.def: Added new feature `mountlist'.
diff --git a/examples/mountlist.c b/examples/mountlist.c
index 035c57ea..5e2e72c4 100644
--- a/examples/mountlist.c
+++ b/examples/mountlist.c
@@ -29,6 +29,7 @@
#include <glibtop/parameter.h>
#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
#ifndef PROFILE_COUNT
#define PROFILE_COUNT 1000
@@ -37,6 +38,7 @@
int
main (int argc, char *argv [])
{
+ glibtop_fsusage fsusage;
glibtop_mountlist mount_list;
glibtop_mountentry *mount_entries;
unsigned c, index, method, count, port;
@@ -85,8 +87,24 @@ main (int argc, char *argv [])
mount_entries [index].type,
mount_entries [index].devname);
+ printf ("\n\n%-23s %9s %9s %9s %9s %9s\n\n",
+ "", "Blocks", "Free", "Avail", "Files", "Free");
+
+ for (index = 0; index < mount_list.number; index++) {
+ glibtop_get_fsusage (&fsusage,
+ mount_entries [index].mountdir);
+
+ printf ("Usage: %-16s %9lu %9lu %9lu %9lu %9lu\n",
+ mount_entries [index].mountdir,
+ fsusage.blocks, fsusage.bfree,
+ fsusage.bavail, fsusage.files,
+ fsusage.ffree);
+ }
+
glibtop_free (mount_entries);
+ printf ("\nsbrk (0) = %p\n\n", sbrk (0));
+
glibtop_close ();
exit (0);
diff --git a/features.def b/features.def
index 99bfb34a..91d922f8 100644
--- a/features.def
+++ b/features.def
@@ -15,3 +15,4 @@ proc_signal ulong(signal,blocked,sigignore,sigcatch)
proc_kernel ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)
proc_segment long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)
@mountlist ulong(number,size,total)
+fsusage ulong(blocks,bfree,bavail,files,ffree)
diff --git a/include/glibtop/command.h b/include/glibtop/command.h
index 1b7acd7a..ddd00055 100644
--- a/include/glibtop/command.h
+++ b/include/glibtop/command.h
@@ -49,8 +49,9 @@ __BEGIN_DECLS
#define GLIBTOP_CMND_PROC_SEGMENT 17
#define GLIBTOP_CMND_MOUNTLIST 18
+#define GLIBTOP_CMND_FSUSAGE 19
-#define GLIBTOP_MAX_CMND 19
+#define GLIBTOP_MAX_CMND 20
#define _GLIBTOP_PARAM_SIZE 16
diff --git a/include/glibtop/fsusage.h b/include/glibtop/fsusage.h
new file mode 100644
index 00000000..462eb6cd
--- /dev/null
+++ b/include/glibtop/fsusage.h
@@ -0,0 +1,90 @@
+/* $Id$ */
+
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the Gnome Top Library.
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ The Gnome Top Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Top Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef __GLIBTOP_FSUSAGE_H__
+#define __GLIBTOP_FSUSAGE_H__
+
+#include <glibtop.h>
+#include <glibtop/global.h>
+
+__BEGIN_DECLS
+
+#define GLIBTOP_FSUSAGE_BLOCKS 0
+#define GLIBTOP_FSUSAGE_BFREE 1
+#define GLIBTOP_FSUSAGE_BAVAIL 2
+#define GLIBTOP_FSUSAGE_FILES 3
+#define GLIBTOP_FSUSAGE_FFREE 4
+
+#define GLIBTOP_MAX_FSUSAGE 5
+
+typedef struct _glibtop_fsusage glibtop_fsusage;
+
+struct _glibtop_fsusage
+{
+ unsigned long flags,
+ blocks, /* Total blocks. */
+ bfree, /* Free blocks available to superuser. */
+ bavail, /* Free blocks available to non-superuser. */
+ files, /* Total file nodes. */
+ ffree; /* Free file nodes. */
+};
+
+#define glibtop_get_fsusage(fsusage,disk) glibtop_get_fsusage_l(glibtop_global_server, fsusage, disk)
+
+#define glibtop_get_fsusage_r glibtop_get_fsusage_s
+
+extern void glibtop_get_fsusage_l __P((glibtop *, glibtop_fsusage *, const char *));
+
+extern void glibtop_get_fsusage_s __P((glibtop *, glibtop_fsusage *, const char *));
+
+#ifdef HAVE_GUILE
+
+/* You need to link with -lgtop_guile to get this stuff here. */
+
+extern SCM glibtop_guile_get_fsusage __P((SCM));
+
+#endif
+
+#ifdef GLIBTOP_GUILE_NAMES
+
+/* You need to link with -lgtop_guile_names to get this stuff here. */
+
+extern SCM glibtop_guile_names_fsusage __P((void));
+extern SCM glibtop_guile_types_fsusage __P((void));
+extern SCM glibtop_guile_labels_fsusage __P((void));
+extern SCM glibtop_guile_descriptions_fsusage __P((void));
+
+#endif
+
+#ifdef GLIBTOP_NAMES
+
+/* You need to link with -lgtop_names to get this stuff here. */
+
+extern const char *glibtop_names_fsusage [];
+extern const unsigned glibtop_types_fsusage [];
+extern const char *glibtop_labels_fsusage [];
+extern const char *glibtop_descriptions_fsusage [];
+
+#endif
+
+__END_DECLS
+
+#endif
diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h
index 263245d3..b24e549e 100644
--- a/include/glibtop/sysdeps.h
+++ b/include/glibtop/sysdeps.h
@@ -45,8 +45,9 @@ __BEGIN_DECLS
#define GLIBTOP_SYSDEPS_PROC_KERNEL 15
#define GLIBTOP_SYSDEPS_PROC_SEGMENT 16
#define GLIBTOP_SYSDEPS_MOUNTLIST 17
+#define GLIBTOP_SYSDEPS_FSUSAGE 18
-#define GLIBTOP_MAX_SYSDEPS 18
+#define GLIBTOP_MAX_SYSDEPS 19
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
@@ -72,7 +73,8 @@ struct _glibtop_sysdeps
proc_signal, /* glibtop_proc_signal */
proc_kernel, /* glibtop_proc_kernel */
proc_segment, /* glibtop_proc_segment */
- mountlist; /* glibtop_mountlist */
+ mountlist, /* glibtop_mountlist */
+ fsusage; /* glibtop_fsusage */
};
#define glibtop_get_sysdeps(sysdeps) glibtop_get_sysdeps_r(glibtop_global_server,sysdeps)
diff --git a/include/glibtop/union.h b/include/glibtop/union.h
index c8a983f7..b04cf808 100644
--- a/include/glibtop/union.h
+++ b/include/glibtop/union.h
@@ -41,6 +41,7 @@
#include <glibtop/procsegment.h>
#include <glibtop/mountlist.h>
+#include <glibtop/fsusage.h>
__BEGIN_DECLS
@@ -65,6 +66,7 @@ union _glibtop_union
glibtop_proc_kernel proc_kernel;
glibtop_proc_segment proc_segment;
glibtop_mountlist mountlist;
+ glibtop_fsusage fsusage;
};
__END_DECLS
diff --git a/lib/lib.awk b/lib/lib.awk
index ee91d7d8..c89694e3 100644
--- a/lib/lib.awk
+++ b/lib/lib.awk
@@ -26,6 +26,8 @@ function output(feature) {
}
if (feature ~ /^proc_/) {
param = ", pid_t pid";
+ } else if (feature ~ /^fsusage$/) {
+ param = ", const char *mountdir";
} else {
param = "";
}
@@ -46,6 +48,13 @@ function output(feature) {
print "\t} else {";
print "#if (!GLIBTOP_SUID_"toupper(feature)")";
print "\t\tglibtop_get_"feature"_r (server, buf, pid);";
+ } else if (feature ~ /^fsusage$/) {
+ print "\t\tglibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)",";
+ print "\t\t\t\tstrlen (mountdir) + 1, mountdir,";
+ print "\t\t\t\tsizeof (glibtop_"feature"), buf);";
+ print "\t} else {";
+ print "#if (!GLIBTOP_SUID_"toupper(feature)")";
+ print "\t\tglibtop_get_"feature"_r (server, buf, mountdir);";
} else {
if (feature ~ /^mountlist$/) {
print "\t\treturn glibtop_call_l (server, GLIBTOP_CMND_MOUNTLIST,";
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 20e3e889..e7bb4b8f 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -166,6 +166,12 @@ handle_parent_connection (int s)
resp->u.data.mountlist.total, mount_list);
glibtop_free_r (server, mount_list);
break;
+ case GLIBTOP_CMND_FSUSAGE:
+ glibtop_get_fsusage_l
+ (server, &resp->u.data.fsusage, parameter);
+ do_output (s, resp, _offset_data (fsusage),
+ 0, NULL);
+ break;
default:
glibtop_warn ("Parent received unknown command %u",
cmnd->command);
diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c
index e90abf94..9e6a84af 100644
--- a/sysdeps/common/fsusage.c
+++ b/sysdeps/common/fsusage.c
@@ -62,6 +62,13 @@ int statfs ();
int statvfs ();
#endif
+#include <glibtop.h>
+#include <glibtop/error.h>
+#include <glibtop/fsusage.h>
+
+static int get_fs_usage __P ((const char *, const char *,
+ struct fs_usage *));
+
int safe_read ();
/* Return the number of TOSIZE-byte blocks used by
@@ -93,7 +100,7 @@ adjust_blocks (blocks, fromsize, tosize)
Return 0 if successful, -1 if not. When returning -1, ensure that
ERRNO is either a system error value, or zero if DISK is NULL
on a system that requires a non-NULL value. */
-int
+static int
get_fs_usage (path, disk, fsp)
const char *path;
const char *disk;
@@ -272,3 +279,23 @@ statfs (path, fsb)
}
#endif /* _AIX && _I386 */
+
+void
+glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
+ const char *disk)
+{
+ struct fs_usage fsp;
+
+ glibtop_init_r (&server, 0, 0);
+
+ memset (buf, 0, sizeof (glibtop_fsusage));
+
+ if (get_fs_usage (disk, disk, &fsp))
+ return;
+
+ buf->blocks = fsp.fsu_blocks;
+ buf->bfree = fsp.fsu_bfree;
+ buf->bavail = fsp.fsu_bavail;
+ buf->files = fsp.fsu_files;
+ buf->ffree = fsp.fsu_ffree;
+}
diff --git a/sysdeps/common/fsusage.h b/sysdeps/common/fsusage.h
index 227c5b45..0fb23efa 100644
--- a/sysdeps/common/fsusage.h
+++ b/sysdeps/common/fsusage.h
@@ -25,13 +25,3 @@ struct fs_usage
long fsu_ffree; /* Free file nodes. */
};
-#ifndef __P
-#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif /* GCC. */
-#endif /* Not __P. */
-
-int get_fs_usage __P ((const char *path, const char *disk,
- struct fs_usage *fsp));
diff --git a/sysdeps/guile/guile.awk b/sysdeps/guile/guile.awk
index 8722a6e3..3c99fab1 100644
--- a/sysdeps/guile/guile.awk
+++ b/sysdeps/guile/guile.awk
@@ -30,6 +30,10 @@ BEGIN {
output = "SCM\nglibtop_guile_get_"$1" (SCM pid)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1", (pid_t) gh_scm2long (pid));\n\n";
+ } else if ($1 ~ /^fsusage$/) {
+ output = "SCM\nglibtop_guile_get_"$1" (SCM mountdir)\n{\n";
+ output = output"\tglibtop_"$1" "$1";\n\n";
+ output = output"\tglibtop_get_"$1" (&"$1", gh_scm2newstr (mountdir, NULL));\n\n";
} else {
output = "SCM\nglibtop_guile_get_"$1" (void)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
@@ -77,6 +81,8 @@ END {
for (feature in features) {
if (feature ~ /^proc_/) {
print "\tgh_new_procedure1_0";
+ } else if (feature ~ /^fsusage$/) {
+ print "\tgh_new_procedure1_0";
} else {
print "\tgh_new_procedure0_0";
}
diff --git a/sysdeps/names/Makefile.am b/sysdeps/names/Makefile.am
index f650e158..ff530ad7 100644
--- a/sysdeps/names/Makefile.am
+++ b/sysdeps/names/Makefile.am
@@ -12,5 +12,4 @@ libgtop_names_la_SOURCES = cpu.c mem.c swap.c uptime.c loadavg.c \
shm_limits.c msg_limits.c sem_limits.c \
proclist.c sysdeps.c procstate.c procuid.c \
proctime.c procmem.c procsignal.c prockernel.c \
- procsegment.c
-
+ procsegment.c fsusage.c
diff --git a/sysdeps/names/fsusage.c b/sysdeps/names/fsusage.c
new file mode 100644
index 00000000..e48d417c
--- /dev/null
+++ b/sysdeps/names/fsusage.c
@@ -0,0 +1,51 @@
+/* $Id$ */
+
+/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ This file is part of the Gnome Top Library.
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ The Gnome Top Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Top Library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <glibtop/fsusage.h>
+
+const char *glibtop_names_fsusage [GLIBTOP_MAX_FSUSAGE] =
+{
+ "blocks", "bfree", "bavail", "files", "ffree"
+};
+
+const unsigned glibtop_types_fsusage [GLIBTOP_MAX_FSUSAGE] =
+{
+ GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
+ GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
+};
+
+const char *glibtop_labels_fsusage [GLIBTOP_MAX_FSUSAGE] =
+{
+ N_("Total blocks"),
+ N_("Free blocks"),
+ N_("Available blocks"),
+ N_("Total file nodes"),
+ N_("Free file nodes")
+};
+
+const char *glibtop_descriptions_fsusage [GLIBTOP_MAX_FSUSAGE] =
+{
+ N_("Total blocks"),
+ N_("Free blocks available to the superuser"),
+ N_("Free blocks available to non-superusers"),
+ N_("Total file nodes"),
+ N_("Free file nodes")
+};
diff --git a/sysdeps/names/sysdeps.c b/sysdeps/names/sysdeps.c
index 29c55c7a..367681a8 100644
--- a/sysdeps/names/sysdeps.c
+++ b/sysdeps/names/sysdeps.c
@@ -26,7 +26,8 @@ const char *glibtop_names_sysdeps [GLIBTOP_MAX_SYSDEPS] =
"features", "cpu", "mem", "swap", "uptime", "loadavg",
"shm_limits", "msg_limits", "sem_limits", "proclist",
"proc_state", "proc_uid", "proc_mem", "proc_time",
- "proc_signal", "proc_kernel", "proc_segment", "mountlist"
+ "proc_signal", "proc_kernel", "proc_segment", "mountlist",
+ "fsusage"
};
const unsigned glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] =
@@ -36,7 +37,8 @@ const unsigned glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] =
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
- GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
+ GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
+ GLIBTOP_TYPE_ULONG
};
const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] =
@@ -58,7 +60,8 @@ const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] =
N_("Process Signal information"),
N_("Process Kernel Data information"),
N_("Process Segment information"),
- N_("Mount List")
+ N_("Mount List"),
+ N_("File System Usage"),
};
const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] =
@@ -81,4 +84,5 @@ const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] =
N_("Process Kernel Data information"),
N_("Process Segment information"),
N_("List of currently mounted filesystems"),
+ N_("File System Usage"),
};