From a7dcd633a125fc7fe7dcb5709da8ab26684ca73f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 24 Jun 2004 14:20:54 +0000 Subject: [PATCH] inode.c should also not be here, not part of NetworkManager git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@7 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- inode.c | 124 -------------------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 inode.c diff --git a/inode.c b/inode.c deleted file mode 100644 index 52b4faf17a..0000000000 --- a/inode.c +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- mode: C; c-file-style: "linux" -*- */ - -/* MemProf -- memory profiler and leak detector - * Copyright 1999, 2000, 2001, Red Hat, Inc. - * Copyright 2002, Kristian Rietveld - * - * This program 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. - * - * This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -/*====*/ - -#include -#include -#include -#include "memprof.h" - -/************************************************************ - * Inode finding code - not needed for kernel 2.2 or greater - ************************************************************/ - -GHashTable *inode_table = NULL; - -typedef struct { - dev_t device; - ino_t inode; - gchar *name; -} Inode; - -static guint -inode_hash (gconstpointer data) -{ - return (((Inode *)data)->device + (((Inode *)data)->inode << 11)); -} - -static gint -inode_compare (gconstpointer a, gconstpointer b) -{ - return ((((Inode *)a)->device == ((Inode *)b)->device) && - (((Inode *)a)->inode == ((Inode *)b)->inode)); -} - -void -read_inode (const gchar *path) -{ - struct stat stbuf; - - g_return_if_fail (path != NULL); - - if (!inode_table) - inode_table = g_hash_table_new (inode_hash, inode_compare); - - if (!stat (path, &stbuf)) { - Inode *inode = g_new (Inode, 1); - inode->device = stbuf.st_dev; - inode->inode = stbuf.st_ino; - if (!g_hash_table_lookup (inode_table, inode)) { - inode->name = g_strdup (path); - g_hash_table_insert (inode_table, inode, inode); - } else - g_free (inode); - } -} - -static void -read_inodes () -{ - static const char *directories[] = { - "/lib", - "/usr/lib", - "/usr/X11R6/lib", - "/usr/local/lib", - "/opt/gnome/lib", - NULL - }; - - const char **dirname; - - for (dirname = directories; *dirname; dirname++) - { - DIR *dir = opendir (*dirname); - - if (dir) { - struct dirent *ent; - while ((ent = readdir (dir))) { - gchar buf[1024]; - snprintf(buf, 1024-1, "%s/%s", *dirname, ent->d_name); - read_inode (buf); - } - - closedir (dir); - } - } -} - -gchar * -locate_inode (dev_t device, ino_t inode) -{ - Inode lookup; - Inode *result; - - lookup.device = device; - lookup.inode = inode; - - if (!inode_table) - read_inodes (); - - result = g_hash_table_lookup (inode_table, &lookup); - if (result) - return result->name; - else - return NULL; -} -