From 118d85d597ffa77ca2d53b01c1dc5295f11c5f2c Mon Sep 17 00:00:00 2001 From: reinelt Date: Sun, 3 Apr 2005 07:07:51 +0000 Subject: [lcd4linux @ 2005-04-03 07:07:43 by reinelt] added statfs plugin git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@524 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- Makefile.am | 1 + Makefile.in | 12 +++---- config.h.in | 6 ++++ configure | 15 +++++++- configure.in | 2 +- plugin.c | 13 ++++++- plugin_statfs.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins.m4 | 8 +++++ 8 files changed, 152 insertions(+), 9 deletions(-) create mode 100644 plugin_statfs.c diff --git a/Makefile.am b/Makefile.am index f4c1497..477e4ac 100644 --- a/Makefile.am +++ b/Makefile.am @@ -96,6 +96,7 @@ plugin_pop3.c \ plugin_ppp.c \ plugin_proc_stat.c \ plugin_seti.c \ +plugin_statfs.c \ plugin_uname.c \ plugin_uptime.c \ plugin_wireless.c \ diff --git a/Makefile.in b/Makefile.in index ad3e2ad..9259628 100644 --- a/Makefile.in +++ b/Makefile.in @@ -100,7 +100,7 @@ lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h deb #liblcd4linux_la_SOURCES = -EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_NULL.c drv_RouterBoard.c drv_SimpleLCD.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c +EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_HD44780.c drv_Image.c drv_LCDLinux.c drv_LCDTerm.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_NULL.c drv_RouterBoard.c drv_SimpleLCD.c drv_T6963.c drv_USBLCD.c drv_X11.c font_6x8.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c @@ -154,11 +154,11 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \ .deps/plugin_imon.P .deps/plugin_isdn.P .deps/plugin_loadavg.P \ .deps/plugin_math.P .deps/plugin_meminfo.P .deps/plugin_mysql.P \ .deps/plugin_netdev.P .deps/plugin_pop3.P .deps/plugin_ppp.P \ -.deps/plugin_proc_stat.P .deps/plugin_seti.P .deps/plugin_string.P \ -.deps/plugin_test.P .deps/plugin_time.P .deps/plugin_uname.P \ -.deps/plugin_uptime.P .deps/plugin_wireless.P .deps/plugin_xmms.P \ -.deps/qprintf.P .deps/thread.P .deps/timer.P .deps/udelay.P \ -.deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \ +.deps/plugin_proc_stat.P .deps/plugin_seti.P .deps/plugin_statfs.P \ +.deps/plugin_string.P .deps/plugin_test.P .deps/plugin_time.P \ +.deps/plugin_uname.P .deps/plugin_uptime.P .deps/plugin_wireless.P \ +.deps/plugin_xmms.P .deps/qprintf.P .deps/thread.P .deps/timer.P \ +.deps/udelay.P .deps/widget.P .deps/widget_bar.P .deps/widget_icon.P \ .deps/widget_text.P SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES) OBJECTS = $(lcd4linux_OBJECTS) diff --git a/config.h.in b/config.h.in index 7a01663..3fcaba1 100644 --- a/config.h.in +++ b/config.h.in @@ -175,6 +175,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STATFS_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H @@ -284,6 +287,9 @@ /* seti plugin */ #undef PLUGIN_SETI +/* statfs plugin */ +#undef PLUGIN_STATFS + /* uname plugin */ #undef PLUGIN_UNAME diff --git a/configure b/configure index c4c8b90..aab90ad 100755 --- a/configure +++ b/configure @@ -6366,6 +6366,7 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;} PLUGIN_PPP="yes" PLUGIN_PROC_STAT="yes" PLUGIN_SETI="yes" + PLUGIN_STATFS="yes" PLUGIN_UNAME="yes" PLUGIN_UPTIME="yes" PLUGIN_WIRELESS="yes" @@ -6419,6 +6420,9 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;} seti) PLUGIN_SETI=$val ;; + statfs) + PLUGIN_STATFS=$val + ;; uname) PLUGIN_UNAME=$val ;; @@ -7266,6 +7270,14 @@ cat >>confdefs.h <<\_ACEOF #define PLUGIN_SETI 1 _ACEOF +fi +if test "$PLUGIN_STATFS" = "yes"; then + PLUGINS="$PLUGINS plugin_statfs.o" + +cat >>confdefs.h <<\_ACEOF +#define PLUGIN_STATFS 1 +_ACEOF + fi if test "$PLUGIN_UNAME" = "yes"; then PLUGINS="$PLUGINS plugin_uname.o" @@ -7820,7 +7832,8 @@ fi -for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h termios.h unistd.h + +for ac_header in arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/statfs.h sys/time.h syslog.h termios.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then diff --git a/configure.in b/configure.in index 3240e65..651f9b9 100644 --- a/configure.in +++ b/configure.in @@ -73,7 +73,7 @@ sinclude(plugins.m4) # Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h termios.h unistd.h]) +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/statfs.h sys/time.h syslog.h termios.h unistd.h]) AC_CHECK_HEADERS(sys/io.h asm/io.h) AC_CHECK_HEADERS(linux/parport.h linux/ppdev.h) AC_CHECK_HEADERS(asm/msr.h) diff --git a/plugin.c b/plugin.c index 9075f56..29a63e3 100644 --- a/plugin.c +++ b/plugin.c @@ -1,4 +1,4 @@ -/* $Id: plugin.c,v 1.35 2005/01/18 06:30:23 reinelt Exp $ +/* $Id: plugin.c,v 1.36 2005/04/03 07:07:51 reinelt Exp $ * * plugin handler for the Evaluator * @@ -23,6 +23,9 @@ * * * $Log: plugin.c,v $ + * Revision 1.36 2005/04/03 07:07:51 reinelt + * added statfs plugin + * * Revision 1.35 2005/01/18 06:30:23 reinelt * added (C) to all copyright statements * @@ -237,6 +240,8 @@ int plugin_init_proc_stat (void); void plugin_exit_proc_stat (void); int plugin_init_seti(void); void plugin_exit_seti(void); +int plugin_init_statfs(void); +void plugin_exit_statfs(void); int plugin_init_uname (void); void plugin_exit_uname (void); int plugin_init_uptime (void); @@ -303,6 +308,9 @@ int plugin_init (void) #ifdef PLUGIN_SETI plugin_init_seti(); #endif +#ifdef PLUGIN_STATFS + plugin_init_statfs(); +#endif #ifdef PLUGIN_UNAME plugin_init_uname(); #endif @@ -369,6 +377,9 @@ void plugin_exit(void) { #ifdef PLUGIN_SETI plugin_exit_seti(); #endif +#ifdef PLUGIN_STATFS + plugin_exit_statfs(); +#endif #ifdef PLUGIN_UNAME plugin_exit_uname(); #endif diff --git a/plugin_statfs.c b/plugin_statfs.c new file mode 100644 index 0000000..9bf9510 --- /dev/null +++ b/plugin_statfs.c @@ -0,0 +1,104 @@ +/* $Id: plugin_statfs.c,v 1.1 2005/04/03 07:07:51 reinelt Exp $ + * + * plugin for statfs() syscall + * + * Copyright (C) 2005 Michael Reinelt + * Copyright (C) 2005 The LCD4Linux Team + * + * This file is part of LCD4Linux. + * + * LCD4Linux 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, or (at your option) + * any later version. + * + * LCD4Linux 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * $Log: plugin_statfs.c,v $ + * Revision 1.1 2005/04/03 07:07:51 reinelt + * added statfs plugin + * + */ + +/* + * exported functions: + * + * int plugin_init_statfs (void) + * adds statfs() functions + * + */ + + +#include "config.h" + +#include +#include +#include +#include + +#include "debug.h" +#include "plugin.h" + + + +static void my_statfs (RESULT *result, RESULT *arg1, RESULT *arg2) +{ + struct statfs buf; + char *path, *key; + double value; + + path = R2S(arg1); + key = R2S(arg2); + + if (statfs(path, &buf)!=0) { + error("statfs(%s) failed: %s", path, strerror(errno)); + SetResult(&result, R_STRING, ""); + return; + } + + if (strcasecmp(key, "type")==0) { + value = buf.f_type; + } else if (strcasecmp(key, "bsize")==0) { + value = buf.f_bsize; + } else if (strcasecmp(key, "blocks")==0) { + value = buf.f_blocks; + } else if (strcasecmp(key, "bfree")==0) { + value = buf.f_bfree; + } else if (strcasecmp(key, "bavail")==0) { + value = buf.f_bavail; + } else if (strcasecmp(key, "files")==0) { + value = buf.f_files; + } else if (strcasecmp(key, "ffree")==0) { + value = buf.f_ffree; +#if 0 + } else if (strcasecmp(key, "fsid")==0) { + value = buf.f_fsid; +#endif + } else if (strcasecmp(key, "namelen")==0) { + value = buf.f_namelen; + } else { + error("statfs: unknown field '%s'", key); + value = -1; + } + + SetResult(&result, R_NUMBER, &value); +} + + +int plugin_init_statfs (void) +{ + AddFunction ("statfs", 2, my_statfs); + return 0; +} + +void plugin_exit_statfs(void) +{ +} diff --git a/plugins.m4 b/plugins.m4 index 90fc339..cf122f5 100644 --- a/plugins.m4 +++ b/plugins.m4 @@ -65,6 +65,7 @@ for plugin in $plugins; do PLUGIN_PPP="yes" PLUGIN_PROC_STAT="yes" PLUGIN_SETI="yes" + PLUGIN_STATFS="yes" PLUGIN_UNAME="yes" PLUGIN_UPTIME="yes" PLUGIN_WIRELESS="yes" @@ -118,6 +119,9 @@ for plugin in $plugins; do seti) PLUGIN_SETI=$val ;; + statfs) + PLUGIN_STATFS=$val + ;; uname) PLUGIN_UNAME=$val ;; @@ -226,6 +230,10 @@ if test "$PLUGIN_SETI" = "yes"; then PLUGINS="$PLUGINS plugin_seti.o" AC_DEFINE(PLUGIN_SETI,1,[seti plugin]) fi +if test "$PLUGIN_STATFS" = "yes"; then + PLUGINS="$PLUGINS plugin_statfs.o" + AC_DEFINE(PLUGIN_STATFS,1,[statfs plugin]) +fi if test "$PLUGIN_UNAME" = "yes"; then PLUGINS="$PLUGINS plugin_uname.o" AC_DEFINE(PLUGIN_UNAME,1,[uname plugin]) -- cgit v1.2.3