diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2004-09-24 12:59:29 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2004-09-24 12:59:29 +0000 |
commit | 9aae957919df6397ab8db9bbc1dd6cdc7565f589 (patch) | |
tree | 61a82f2902bb1ab4f70cba771948a796b5d0a172 /examples | |
parent | 6d24f84fd6b0d2c9d53244f4380770f8a4a37e27 (diff) | |
download | libgtop-9aae957919df6397ab8db9bbc1dd6cdc7565f589.tar.gz |
../configure.in Added new example, just like 'df'.
* .cvsignore:
* Makefile.am:
* ../configure.in
* df.c: (print_fsusage), (main): Added new example, just like 'df'.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/.cvsignore | 3 | ||||
-rw-r--r-- | examples/ChangeLog | 7 | ||||
-rw-r--r-- | examples/Makefile.am | 13 | ||||
-rw-r--r-- | examples/df.c | 45 |
4 files changed, 66 insertions, 2 deletions
diff --git a/examples/.cvsignore b/examples/.cvsignore index 8dcb874c..eb80d17f 100644 --- a/examples/.cvsignore +++ b/examples/.cvsignore @@ -18,3 +18,6 @@ pprint pprint_static procargs procargs_static +df +df_static + diff --git a/examples/ChangeLog b/examples/ChangeLog index e62ffaa7..6bbaeb2f 100644 --- a/examples/ChangeLog +++ b/examples/ChangeLog @@ -1,3 +1,10 @@ +2004-09-24 Benoît Dejean <tazforever@dlfp.org> + + * .cvsignore: + * Makefile.am: + * ../configure.in + * df.c: (print_fsusage), (main): Added new example, just like 'df'. + 2004-09-22 Benoît Dejean <tazforever@dlfp.org> * pprint.c: (main): Disable pprint_get_msg_limits() because it can fail. diff --git a/examples/Makefile.am b/examples/Makefile.am index 49133396..b68175c0 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = @INCLUDES@ DEFS = @DEFS@ -noinst_PROGRAMS = first second pprint procargs \ +noinst_PROGRAMS = first second pprint procargs df \ mountlist procmap netload sysdeps timings \ @static_targets@ @smp_examples@ @@ -14,7 +14,8 @@ EXTRA_PROGRAMS = first_static second_static \ mountlist_static procmap_static \ third third_static smp smp_static \ netload_static sysdeps_static \ - timings_static pprint_static procargs_static + timings_static pprint_static procargs_static \ + df_static first_SOURCES = first.c first_LDADD = $(top_builddir)/lib/libgtop-2.0.la @@ -100,3 +101,11 @@ procargs_static_SOURCES = $(procargs_SOURCES) procargs_static_LDADD = $(procargs_LDADD) procargs_static_LDFLAGS = -static + +df_SOURCES = df.c +df_LDADD = $(top_builddir)/lib/libgtop-2.0.la + +df_static_SOURCES = $(df_SOURCES) +df_static_LDADD = $(df_LDADD) +df_static_LDFLAGS = -static + diff --git a/examples/df.c b/examples/df.c new file mode 100644 index 00000000..a590ace2 --- /dev/null +++ b/examples/df.c @@ -0,0 +1,45 @@ +#include <glibtop.h> + +#include <glibtop/fsusage.h> +#include <glibtop/mountlist.h> + +#include <stdio.h> + + +static void print_fsusage(const char *mountpoint) +{ + glibtop_fsusage buf; + + glibtop_get_fsusage(&buf, mountpoint); + + printf("%-20s %-10llu %-10llu %-10llu %.1f\n", + mountpoint, + buf.blocks * buf.block_size >> 20, + (buf.blocks - buf.bavail) * buf.block_size >> 20, + buf.bavail * buf.block_size >> 20, + (buf.blocks - buf.bavail) * 100.0 / buf.blocks + ); +} + + +int main() +{ + glibtop_mountlist buf; + glibtop_mountentry *entries; + size_t i; + + + printf("%-20s %-10s %-10s %-10s %-10s\n", + "Filesystem", "Size", "Used", "Avail", "Use%"); + + entries = glibtop_get_mountlist(&buf, FALSE); + + for(i = 0; i < buf.number; ++i) + { + print_fsusage(entries[i].mountdir); + } + + g_free(entries); + + return 0; +} |