Install this as a backend.

2001-04-21  Martin Baulig  <baulig@suse.de>

	* Makefile.am: Install this as a backend.

	* libgtop-common.backend, backend.c: New files.

	* inodedb.c: Removed; moved to ~/lib.
This commit is contained in:
Martin Baulig
2001-04-20 22:31:26 +00:00
committed by Martin Baulig
parent 08956770d2
commit 236d2b18e7
7 changed files with 117 additions and 140 deletions

View File

@@ -1,3 +1,11 @@
2001-04-21 Martin Baulig <baulig@suse.de>
* 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 <martin@home-of-linux.org> 2000-11-22 Martin Baulig <martin@home-of-linux.org>
* error_suid.c: New file, formerly known as error.c. * error_suid.c: New file, formerly known as error.c.

View File

@@ -2,25 +2,20 @@ LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = @INCLUDES@ INCLUDES = @INCLUDES@
dynamic_ldflags = @libgtop_dynamic_ldflags@ backenddir = @LIBGTOP_BACKEND_DIR@
if INODEDB backend_DATA = libgtop-common.backend
inodedb_SRCLIST = inodedb.c
inodedb_DEFS = -DSYSTEM_INODEDB=\"$(prefix)/var/libgtop/inodedb.db\"
else
inodedb_SRCLIST =
inodedb_DEFS =
endif
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 \ libgtop_backend_common_la_SOURCES = \
$(inodedb_SRCLIST) 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

80
sysdeps/common/backend.c Normal file
View File

@@ -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 <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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop.h>
#include <glibtop/fsusage.h>
#include <glibtop/mountlist.h>
#include <glibtop/glibtop-server.h>
#include <glibtop/glibtop-backend.h>
#include <glibtop/call-vector.h>
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
};

View File

@@ -291,8 +291,8 @@ statfs (path, fsb)
#endif /* _AIX && _I386 */ #endif /* _AIX && _I386 */
int int
glibtop_get_fsusage_s (glibtop_server *server, glibtop_fsusage *buf, glibtop_get_fsusage_s (glibtop_server *server, glibtop_closure *machine,
const char *disk) glibtop_fsusage *buf, const char *disk)
{ {
struct fs_usage fsp; struct fs_usage fsp;

View File

@@ -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 <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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/xmalloc.h>
#include <glibtop/inodedb.h>
#include <pwd.h>
#include <gdbm.h>
#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);
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0"?> <!-- -*-xml-*- -->
<!DOCTYPE libgtop:backends SYSTEM 'libgtop-backends.dtd'>
<libgtop:Backends xmlns:libgtop="http://www.home-of-linux.org/libgtop/1.1">
<libgtop:Backend>
<libgtop:Name>glibtop-backend-common</libgtop:Name>
<libgtop:Location>
<libgtop:LibtoolName>libgtop_backend_common.la</libgtop:LibtoolName>
<libgtop:ShlibName>libgtop_backend_common.so</libgtop:ShlibName>
</libgtop:Location>
</libgtop:Backend>
</libgtop:Backends>

View File

@@ -588,8 +588,8 @@ read_filesystem_list (need_fs_type, all_fs)
} }
glibtop_mountentry * glibtop_mountentry *
glibtop_get_mountlist_s (glibtop_server *server, glibtop_mountlist *buf, glibtop_get_mountlist_s (glibtop_server *server, glibtop_closure *machine,
int all_fs) glibtop_mountlist *buf, int all_fs)
{ {
struct mount_entry *me, *tmp, *next; struct mount_entry *me, *tmp, *next;
glibtop_mountentry *mount_list; glibtop_mountentry *mount_list;