diff --git a/sysdeps/common/ChangeLog b/sysdeps/common/ChangeLog index 24329790..d6133c8a 100644 --- a/sysdeps/common/ChangeLog +++ b/sysdeps/common/ChangeLog @@ -1,3 +1,11 @@ +2001-04-21 Martin Baulig + + * Makefile.am: Install this as a backend. + + * libgtop-common.backend, backend.c: New files. + + * inodedb.c: Removed; moved to ~/lib. + 2000-11-22 Martin Baulig * error_suid.c: New file, formerly known as error.c. diff --git a/sysdeps/common/Makefile.am b/sysdeps/common/Makefile.am index 377479b0..4ed7e218 100644 --- a/sysdeps/common/Makefile.am +++ b/sysdeps/common/Makefile.am @@ -1,26 +1,21 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -INCLUDES = @INCLUDES@ +INCLUDES = @INCLUDES@ -dynamic_ldflags = @libgtop_dynamic_ldflags@ +backenddir = @LIBGTOP_BACKEND_DIR@ -if INODEDB -inodedb_SRCLIST = inodedb.c -inodedb_DEFS = -DSYSTEM_INODEDB=\"$(prefix)/var/libgtop/inodedb.db\" -else -inodedb_SRCLIST = -inodedb_DEFS = -endif +backend_DATA = libgtop-common.backend -CFLAGS = @CFLAGS@ $(inodedb_DEFS) +backend_LTLIBRARIES = libgtop_backend_common.la -noinst_LTLIBRARIES = libgtop_common.la libgtop_suid_common.la +EXTRA_DIST = $(backend_DATA) -libgtop_common_la_SOURCES = fsusage.c fsusage.h mountlist.c mountlist.h \ - $(inodedb_SRCLIST) +libgtop_backend_common_la_SOURCES = \ + backend.c fsusage.c mountlist.c -libgtop_common_la_LIBADD = $(LIBGTOP_EXTRA_LIBS) +libgtop_backend_common_la_LIBADD = \ + @GLIB_LIBS@ -libgtop_suid_common_la_SOURCES = xmalloc_suid.c error_suid.c sysdeps_suid.c +libgtop_backend_common_la_LDFLAGS = \ + $(LT_VERSION_INFO) -EXTRA_DIST = inodedb.c diff --git a/sysdeps/common/backend.c b/sysdeps/common/backend.c new file mode 100644 index 00000000..ce193fa0 --- /dev/null +++ b/sysdeps/common/backend.c @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ + +/* $Id$ */ + +/* Copyright (C) 1998-99 Martin Baulig + This file is part of LibGTop 1.0. + + Contributed by Martin Baulig , 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include + +#include +#include +#include + +static int +_open_common (glibtop_server *server, glibtop_backend *backend, + u_int64_t features, const char **backend_args) +{ + return 0; +} + +static int +_close_common (glibtop_server *server, glibtop_backend *backend, + glibtop_closure *closure) +{ + return 0; +} + +static glibtop_call_vector _glibtop_call_vector = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + glibtop_get_mountlist_s, + glibtop_get_fsusage_s, + NULL, + NULL, + NULL, + NULL +}; + +glibtop_backend_info LibGTopBackendInfo = { + "glibtop-backend-common", _open_common, _close_common, + &_glibtop_call_vector +}; + diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c index 3ffdc177..e7634490 100644 --- a/sysdeps/common/fsusage.c +++ b/sysdeps/common/fsusage.c @@ -291,8 +291,8 @@ statfs (path, fsb) #endif /* _AIX && _I386 */ int -glibtop_get_fsusage_s (glibtop_server *server, glibtop_fsusage *buf, - const char *disk) +glibtop_get_fsusage_s (glibtop_server *server, glibtop_closure *machine, + glibtop_fsusage *buf, const char *disk) { struct fs_usage fsp; diff --git a/sysdeps/common/inodedb.c b/sysdeps/common/inodedb.c deleted file mode 100644 index 2b0a4bf3..00000000 --- a/sysdeps/common/inodedb.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* $Id$ */ - -/* Copyright (C) 1998-99 Martin Baulig - This file is part of LibGTop 1.0. - - Contributed by Martin Baulig , 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., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#include -#include -#include -#include - -#include -#include - -#ifndef SYSTEM_INODEDB -#define SYSTEM_INODEDB "/usr/var/libgtop/inodedb.db" -#endif - -glibtop_inodedb * -glibtop_inodedb_open_s (glibtop *server, unsigned databases, - unsigned long cachesize) -{ - glibtop_inodedb *inodedb; - char filename [BUFSIZ]; - struct passwd *pwd; - struct stat statb; - - if (!databases) - databases = GLIBTOP_INODEDB_ALL; - - inodedb = glibtop_calloc_r (server, 1, sizeof (glibtop_inodedb)); - - if (stat (SYSTEM_INODEDB, &statb)) - databases &= ~GLIBTOP_INODEDB_SYSTEM; - - if (databases & GLIBTOP_INODEDB_SYSTEM) { - inodedb->system_dbf = gdbm_open - (SYSTEM_INODEDB, 0, GDBM_READER, 0, 0); - if (!inodedb->system_dbf) - glibtop_error_io_r - (server, "gdbm_open (%s)", SYSTEM_INODEDB); - } - - pwd = getpwuid (getuid ()); - if (!pwd) glibtop_error_io_r (server, "getpwuid"); - - sprintf (filename, "%s/var/libgtop/inodedb.db", pwd->pw_dir); - - if (stat (filename, &statb)) - databases &= ~GLIBTOP_INODEDB_USER; - - if (databases & GLIBTOP_INODEDB_USER) { - inodedb->user_dbf = gdbm_open - (filename, 0, GDBM_READER, 0, 0); - if (!inodedb->user_dbf) - glibtop_error_io_r - (server, "gdbm_open (%s)", filename); - } - - return inodedb; -} - -const char * -glibtop_inodedb_lookup_s (glibtop *server, - glibtop_inodedb *inodedb, - u_int64_t device, u_int64_t inode) -{ - glibtop_inodedb_key key; - datum d_key, d_content; - - d_key.dptr = (void *) &key; - d_key.dsize = sizeof (key); - - key.device = device; - key.inode = inode; - - if (inodedb->system_dbf) { - d_content = gdbm_fetch (inodedb->system_dbf, d_key); - if (d_content.dptr) return d_content.dptr; - } - - if (inodedb->user_dbf) { - d_content = gdbm_fetch (inodedb->user_dbf, d_key); - if (d_content.dptr) return d_content.dptr; - } - - return NULL; -} - -void -glibtop_inodedb_close_s (glibtop *server, glibtop_inodedb *inodedb) -{ - if (inodedb->system_dbf) - gdbm_close (inodedb->system_dbf); - - if (inodedb->user_dbf) - gdbm_close (inodedb->user_dbf); - - glibtop_free_r (server, inodedb); -} diff --git a/sysdeps/common/libgtop-common.backend b/sysdeps/common/libgtop-common.backend new file mode 100644 index 00000000..b4910d34 --- /dev/null +++ b/sysdeps/common/libgtop-common.backend @@ -0,0 +1,13 @@ + + + + + + glibtop-backend-common + + libgtop_backend_common.la + libgtop_backend_common.so + + + + diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index f09bd7f0..b7d9318e 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -588,8 +588,8 @@ read_filesystem_list (need_fs_type, all_fs) } glibtop_mountentry * -glibtop_get_mountlist_s (glibtop_server *server, glibtop_mountlist *buf, - int all_fs) +glibtop_get_mountlist_s (glibtop_server *server, glibtop_closure *machine, + glibtop_mountlist *buf, int all_fs) { struct mount_entry *me, *tmp, *next; glibtop_mountentry *mount_list;