[netfilter-cvslog] r3515 - in trunk/nfsim: core kernelenv

rusty at netfilter.org rusty at netfilter.org
Thu Dec 30 03:39:31 CET 2004


Author: rusty at netfilter.org
Date: 2004-12-30 03:39:31 +0100 (Thu, 30 Dec 2004)
New Revision: 3515

Added:
   trunk/nfsim/kernelenv/Makefile
   trunk/nfsim/kernelenv/proc.c
Removed:
   trunk/nfsim/core/proc.c
Modified:
   trunk/nfsim/core/Makefile
Log:
Move core/proc.c into kernelenv.c in anticipation of more work

Modified: trunk/nfsim/core/Makefile
===================================================================
--- trunk/nfsim/core/Makefile	2004-12-29 13:25:16 UTC (rev 3514)
+++ trunk/nfsim/core/Makefile	2004-12-30 02:39:31 UTC (rev 3515)
@@ -1,2 +1,2 @@
 OBJS += core/utils.o core/core.o core/message.o core/$(TYPE)/$(TYPE).o core/seq_file.o core/talloc.o core/failtest.o core/field.o
-HELP_OBJS += core/tui.o core/expect.o core/log.o core/proc.o
+HELP_OBJS += core/tui.o core/expect.o core/log.o

Deleted: trunk/nfsim/core/proc.c
===================================================================
--- trunk/nfsim/core/proc.c	2004-12-29 13:25:16 UTC (rev 3514)
+++ trunk/nfsim/core/proc.c	2004-12-30 02:39:31 UTC (rev 3515)
@@ -1,162 +0,0 @@
-/*
-
-Copyright (c) 2003,2004 Jeremy Kerr & Rusty Russell
-
-This file is part of nfsim.
-
-nfsim 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.
-
-nfsim 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 nfsim; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include "proc.h"
-#include <kernelenv.h>
-
-struct proc_dir_entry proc_root, *proc_net, *proc_net_stat;
-
-
-int proc_match(int len, const char *name, struct proc_dir_entry *de)
-{
-	if (de->namelen != len)
-		return 0;
-	return !memcmp(name, de->name, len);
-}
-
-static int xlate_proc_name(const char *name,
-			   struct proc_dir_entry **ret, const char **residual)
-{
-	const char     		*cp = name, *next;
-	struct proc_dir_entry	*de;
-	int			len;
-
-	de = &proc_root;
-	while (1) {
-		next = strchr(cp, '/');
-		if (!next)
-			break;
-
-		len = next - cp;
-		for (de = de->subdir; de ; de = de->next) {
-			if (proc_match(len, cp, de))
-				break;
-		}
-		if (!de)
-			return -ENOENT;
-		cp += len + 1;
-	}
-	*residual = cp;
-	*ret = de;
-	return 0;
-}
-
-
-static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent,
-					  const char *name,
-					  mode_t mode,
-					  nlink_t nlink)
-{
-	struct proc_dir_entry *ent = NULL;
-	const char *fn = name;
-	int len;
-
-	/* make sure name is valid */
-	if (!name || !strlen(name)) goto out;
-
-	if (!(*parent) && xlate_proc_name(name, parent, &fn) != 0)
-		goto out;
-	len = strlen(fn);
-
-	if (should_i_fail(__func__))
-		goto out;
-
-	ent = talloc_size(NULL, sizeof(struct proc_dir_entry) + len + 1);
-	if (!ent) goto out;
-
-	memset(ent, 0, sizeof(struct proc_dir_entry));
-	memcpy(((char *) ent) + sizeof(struct proc_dir_entry), fn, len + 1);
-	ent->name = ((char *) ent) + sizeof(*ent);
-	ent->namelen = len;
-	ent->mode = mode;
-out:
-	return ent;
-}
-
-static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
-{
-	dp->next = dir->subdir;
-	dp->parent = dir;
-	dir->subdir = dp;
-	return 0;
-}
-
-struct proc_dir_entry *proc_mkdir(const char *name, struct proc_dir_entry *parent)
-{
-	struct proc_dir_entry *ent;
-
-	ent = proc_create(&parent,name,
-			  (S_IFDIR | S_IRUGO | S_IXUGO),2);
-
-	if (ent && proc_register(parent, ent) < 0) {
-		talloc_free(ent);
-		ent = NULL;
-	}
-	return ent;
-}
-
-struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
-					 struct proc_dir_entry *parent)
-{
-	struct proc_dir_entry *ent;
-
-	ent = proc_create(&parent,name,mode, 0);
-	if (ent && proc_register(parent, ent) < 0) {
-		talloc_free(ent);
-		ent = NULL;
-	}
-	return ent;
-}
-
-void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
-{
-	struct proc_dir_entry **p;
-	struct proc_dir_entry *de;
-	const char *fn = name;
-	int len;
-
-	if (!parent && xlate_proc_name(name, &parent, &fn) != 0)
-		goto out;
-	len = strlen(fn);
-	for (p = &parent->subdir; *p; p=&(*p)->next ) {
-		if (!proc_match(len, fn, *p))
-			continue;
-		de = *p;
-		*p = de->next;
-		de->next = NULL;
-		break;
-	}
-out:
-	return;
-}
-
-static void proc_init(void)
-{
-	proc_root.namelen = 5;
-	proc_root.name = "/proc";
-	proc_root.owner = THIS_MODULE;
-
-	proc_net = proc_mkdir("net", 0);
-	proc_net_stat = proc_mkdir("stat", proc_net);
-}
-
-init_call(proc_init);
-

Added: trunk/nfsim/kernelenv/Makefile
===================================================================
--- trunk/nfsim/kernelenv/Makefile	2004-12-29 13:25:16 UTC (rev 3514)
+++ trunk/nfsim/kernelenv/Makefile	2004-12-30 02:39:31 UTC (rev 3515)
@@ -0,0 +1 @@
+OBJS+=kernelenv/kernelenv.o kernelenv/proc.o

Copied: trunk/nfsim/kernelenv/proc.c (from rev 3504, trunk/nfsim/core/proc.c)




More information about the netfilter-cvslog mailing list