Got rid of InodeDB. This feature was optionnal and i have never heard of

2007-04-27  Benoît Dejean  <benoit@placenet.org>

	Got rid of InodeDB.
	This feature was optionnal and i have never heard of anyone using
	it. I have never touched it so it may be broken since 2.6.

svn path=/trunk/; revision=2573
This commit is contained in:
Benoît Dejean
2007-04-27 17:37:47 +00:00
committed by Benoît Dejean
parent 7ee8dae9c5
commit cd389851b9
18 changed files with 15 additions and 825 deletions
+2 -8
View File
@@ -1,16 +1,10 @@
if INODEDB
inodedb_SUBDIRS = inodedb
else
inodedb_SUBDIRS =
endif
if NEED_LIBGTOP
daemon_SUBDIRS = daemon
else
daemon_SUBDIRS =
endif
SUBDIRS = $(daemon_SUBDIRS) $(inodedb_SUBDIRS)
SUBDIRS = $(daemon_SUBDIRS)
DIST_SUBDIRS = daemon inodedb
DIST_SUBDIRS = daemon
-14
View File
@@ -1,14 +0,0 @@
bin_PROGRAMS = mkinodedb2 file_by_inode2
INCLUDES = @INCLUDES@
mkinodedb2_LDADD = $(top_builddir)/sysdeps/common/libgtop_common-2.0.la \
$(top_builddir)/lib/libgtop-2.0.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps-2.0.la
file_by_inode2_LDADD = $(top_builddir)/lib/libgtop-2.0.la \
$(top_builddir)/sysdeps/common/libgtop_common-2.0.la \
$(top_builddir)/sysdeps/@sysdeps_dir@/libgtop_sysdeps-2.0.la \
$(top_builddir)/sysdeps/common/libgtop_suid_common-2.0.la
EXTRA_DIST = README.inodedb
-73
View File
@@ -1,73 +0,0 @@
Not all UNIXes provide an easy way to get the filename if you have
the device it is mounted on and its inode.
Well, under Linux we can simply read /proc/<pid>/maps to get the filenames
but I don't see any way to get this under FreeBSD.
In this case you can give configure the optional `--with-libgtop-inodedb'
parameter to build this stuff here.
It uses the GNU database library `gdbm' to find the inode in a database
which is created when libgtop is installed. This should be reasonable
fast since the entire filesystem only needs to be traversed once when
libgtop is installed (and each time you install new software, of cause).
We have two databases:
* First the system administrator may place a system-wide database
in `$(prefix)/var/libgtop/inodedb.db' when installing libgtop.
* Every user can have his/her own one in `~/var/libgtop/inodedb.db'.
This one has precedence over the system wide one.
The `mkinodedb' program which is build in this directory takes two
command line arguments: the full pathname of the database to be created
and the name of a configuration file consisting of directory and file names
each on a line by itself - see `/etc/ld.so.conf' for an example.
Putting a directory name in this file means all regular files found in this
directory are included in the database, but it will not recursively descend
into subdirectories (for instance, we want everythink in `/usr/lib' but not
every single file in `/usr/lib/sgml'). You can also use filenames to include
a single file.
To use this interface in your program, you first have to call
`glibtop_inodedb_open ()':
glibtop_inodedb *
glibtop_inodedb_open (unsigned databases, unsigned long cachesize)
glibtop_inodedb *
glibtop_inodedb_open_s (glibtop *server, unsigned databases,
unsigned long cachesize)
There are some constants defined in <glibtop/inodedb.h> for the `databases'
parameter - you can use zero as default:
#define GLIBTOP_INODEDB_SYSTEM 1
#define GLIBTOP_INODEDB_USER 2
#define GLIBTOP_INODEDB_CACHE 4
The `cachesize' gives the size of a not yet implemented in-memory cache for
looked up entries.
This function will return a pointer of type `glibtop_inodedb *' which you need
to lookup an entry in the database.
To look up an entry, use the `glibtop_inodedb_lookup ()' function:
const char *
glibtop_inodedb_lookup (glibtop_inodedb *inodedb,
guint64 device, guint64 inode)
const char *
glibtop_inodedb_lookup_s (glibtop *server, glibtop_inodedb *inodedb,
guint64 device, guint64 inode)
It will either return a pointer to the filename - which you have to
`g_free ()' once done with it - or NULL on error.
You can use the `file_by_inode' program in this directory to test the
interface - just call it with two command line arguments: the device number
and the inode number.
Martin <martin@home-of-linux.org>
-64
View File
@@ -1,64 +0,0 @@
/* 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 <config.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/inodedb.h>
#include <pwd.h>
#include <dirent.h>
#include <sys/stat.h>
int
main (int argc, const char *argv [])
{
glibtop_inodedb *inodedb;
const char *filename;
unsigned device, inode;
if (argc != 3) {
fprintf (stderr, "Usage: %s device inode\n", argv [0]);
exit (1);
}
if (sscanf (argv [1], "%d", &device) != 1) {
fprintf (stderr, "Usage: %s device inode\n", argv [0]);
exit (1);
}
if (sscanf (argv [2], "%d", &inode) != 1) {
fprintf (stderr, "Usage: %s device inode\n", argv [0]);
exit (1);
}
inodedb = glibtop_inodedb_open (0, 0);
if (!inodedb) exit (1);
filename = glibtop_inodedb_lookup (inodedb, device, inode);
if (!filename) exit (2);
fprintf (stderr, "FILENAME: %d - %d - '%s'\n",
(int) device, (int) inode, filename);
exit (0);
}
-134
View File
@@ -1,134 +0,0 @@
/* 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 <config.h>
#include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/inodedb.h>
#include <pwd.h>
#include <dirent.h>
#include <sys/stat.h>
int
main (int argc, char *argv [])
{
GDBM_FILE dbf;
char dirname [BUFSIZ];
FILE *f;
if (argc != 3) {
fprintf (stderr, "Usage: %s database filename\n", argv [0]);
exit (1);
}
f = fopen (argv [2], "rt");
if (!f)
glibtop_error_io ("fopen (%s)", argv [2]);
dbf = gdbm_open (argv [1], 512, GDBM_WRCREAT, 0600, 0);
if (!dbf)
glibtop_error_io ("gdbm_open (%s)", argv [1]);
while (fgets (dirname, BUFSIZ-1, f)) {
struct dirent *entry;
struct stat statb;
DIR *directory;
size_t len;
len = strlen (dirname);
if (!len) continue;
if (dirname [len-1] == '\n')
dirname [len-1] = 0;
if (stat (dirname, &statb))
continue;
if (S_ISREG (statb.st_mode)) {
glibtop_inodedb_key key;
datum d_key, d_content;
d_key.dptr = (void *) &key;
d_key.dsize = sizeof (key);
d_content.dptr = dirname;
d_content.dsize = strlen (dirname) + 1;
key.device = (guint64) statb.st_dev;
key.inode = (guint64) statb.st_ino;
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
glibtop_error_io ("gdbm_store (%s)", dirname);
printf ("%-52s - %8lu - %8lu\n",
dirname, (unsigned long) statb.st_dev,
(unsigned long) statb.st_ino);
continue;
}
if (!S_ISDIR (statb.st_mode))
continue;
directory = opendir (dirname);
if (!directory) continue;
while ((entry = readdir (directory))) {
glibtop_inodedb_key key;
char filename [BUFSIZ];
datum d_key, d_content;
sprintf (filename, "%s/%s", dirname, entry->d_name);
if (stat (filename, &statb))
continue;
if (!S_ISREG (statb.st_mode))
continue;
d_key.dptr = (void *) &key;
d_key.dsize = sizeof (key);
d_content.dptr = filename;
d_content.dsize = strlen (filename) + 1;
key.device = (guint64) statb.st_dev;
key.inode = (guint64) statb.st_ino;
if (gdbm_store (dbf, d_key, d_content, GDBM_REPLACE))
glibtop_error_io ("gdbm_store (%s)", filename);
printf ("%-52s - %8lu - %8lu\n",
filename, (unsigned long) statb.st_dev,
(unsigned long) statb.st_ino);
}
closedir (directory);
}
gdbm_close (dbf);
fclose (f);
exit (0);
}