This patch removes Rule-Based Classification Engine from CKRM as a prelude to
implementing the same functionality in userspace.

Most of this patch is removing whole CKRM files:
 fs/exec.c                         |    2
 fs/rcfs/rootdir.c                 |   30
 fs/rcfs/super.c                   |   50 -
 include/linux/ckrm.h              |   47 +
 include/linux/ckrm_ce.h           |   95 --
 include/linux/ckrm_events.h       |  202 -----
 include/linux/ckrm_rc.h           |   45 -
 include/linux/ckrm_tc.h           |   20
 include/linux/crbce.h             |  165 ----
 include/linux/rbce.h              |   78 --
 include/linux/rcfs.h              |    3
 include/linux/sched.h             |   23
 init/Kconfig                      |   40 -
 init/main.c                       |    2
 kernel/ckrm/Makefile              |    3
 kernel/ckrm/ckrm.c                |   99 --
 kernel/ckrm/ckrm_events.c         |   86 --
 kernel/ckrm/ckrm_sockc.c          |   49 -
 kernel/ckrm/ckrm_tc.c             |  307 --------
 kernel/ckrm/ckrmutils.c           |   39 -
 kernel/ckrm/rbce/Makefile         |   12
 kernel/ckrm/rbce/crbce_ext.c      |  580 ----------------
 kernel/ckrm/rbce/crbce_main.c     |    2
 kernel/ckrm/rbce/rbce_bitvector.h |  146 ----
 kernel/ckrm/rbce/rbce_core.c      |  928 --------------------------
 kernel/ckrm/rbce/rbce_fs.c        |  365 ----------
 kernel/ckrm/rbce/rbce_internal.h  |  265 -------
 kernel/ckrm/rbce/rbce_main.c      | 1279 ------------------------------------
 kernel/ckrm/rbce/rbce_token.c     |  241 ------
 kernel/exit.c                     |    3
 kernel/fork.c                     |   11
 kernel/sys.c                      |   13
 net/ipv4/tcp.c                    |    5
 33 files changed, 125 insertions(+), 5110 deletions(-)

Signed-off-by: Matt Helsley <matthltc@us.ibm.com>

Index: linux-2.6.13-rc6/include/linux/ckrm_ce.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/ckrm_ce.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *  ckrm_ce.h - Header file to be used by Classification Engine of CKRM
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Shailabh Nagar,  IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *
- * Provides data structures, macros and kernel API of CKRM for
- * classification engine.
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#ifndef _LINUX_CKRM_CE_H
-#define _LINUX_CKRM_CE_H
-
-#ifdef CONFIG_CKRM
-
-#include <linux/ckrm_events.h>
-
-/*
- * Action parameters identifying the cause of a task<->class notify callback
- * these can perculate up to user daemon consuming records send by the
- * classification engine
- */
-
-typedef void *(*ce_classify_fct) (enum ckrm_event event, void *obj, ...);
-typedef void (*ce_notify_fct) (enum ckrm_event event, void *classobj,
-				 void *obj);
-
-struct ckrm_eng_callback {
-	/* general state information */
-	int always_callback;	/* set if CE should always be called back
-				   regardless of numclasses */
-
-	/* callbacks which are called without holding locks */
-
-	unsigned long c_interest;	/* set of classification events of
-					 * interest to CE
-					 */
-
-	/* generic classify */
-	ce_classify_fct classify;
-
-	/* class added */
-	void (*class_add) (const char *name, void *core, int classtype);
-
-	/* class deleted */
-	void (*class_delete) (const char *name, void *core, int classtype);
-
-	/* callbacks which are called while holding task_lock(tsk) */
-	unsigned long n_interest;	/* set of notification events of
-					 *  interest to CE
-					 */
-	/* notify on class switch */
-	ce_notify_fct notify;
-};
-
-struct inode;
-struct dentry;
-
-struct rbce_eng_callback {
-	int (*mkdir) (struct inode *, struct dentry *, int);	/* mkdir */
-	int (*rmdir) (struct inode *, struct dentry *);		/* rmdir */
-	int (*mnt) (void);
-	int (*umnt) (void);
-};
-
-extern int ckrm_register_engine(const char *name, struct ckrm_eng_callback *);
-extern int ckrm_unregister_engine(const char *name);
-
-extern void *ckrm_classobj(const char * classname, int *classtype);
-
-extern int rcfs_register_engine(struct rbce_eng_callback *);
-extern int rcfs_unregister_engine(struct rbce_eng_callback *);
-
-extern int ckrm_reclassify(int pid);
-
-#ifndef _LINUX_CKRM_RC_H
-
-extern void ckrm_core_grab(struct ckrm_core_class *core);
-extern void ckrm_core_drop(struct ckrm_core_class *core);
-#endif
-
-#endif /* CONFIG_CKRM */
-#endif /* _LINUX_CKRM_CE_H */
Index: linux-2.6.13-rc6/include/linux/ckrm_events.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/ckrm_events.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * ckrm_events.h - Class-based Kernel Resource Management (CKRM)
- *                 event handling
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003,2004
- *           (C) Shailabh Nagar,  IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *
- *
- * Provides a base header file including macros and basic data structures.
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#ifndef _LINUX_CKRM_EVENTS_H
-#define _LINUX_CKRM_EVENTS_H
-
-#ifdef CONFIG_CKRM
-
-/*
- * Data structure and function to get the list of registered
- * resource controllers.
- */
-
-/*
- * CKRM defines a set of events at particular points in the kernel
- * at which callbacks registered by various class types are called
- */
-
-enum ckrm_event {
-	/*
-	 * we distinguish these events types:
-	 *
-	 * (a) CKRM_LATCHABLE_EVENTS
-	 *      events can be latched for event callbacks by classtypes
-	 *
-	 * (b) CKRM_NONLATACHBLE_EVENTS
-	 *     events can not be latched but can be used to call classification
-	 *
-	 * (c) event that are used for notification purposes
-	 *     range: [ CKRM_EVENT_CANNOT_CLASSIFY .. )
-	 */
-
-	/* events (a) */
-
-	CKRM_LATCHABLE_EVENTS,
-
-	CKRM_EVENT_NEWTASK = CKRM_LATCHABLE_EVENTS,
-	CKRM_EVENT_FORK,
-	CKRM_EVENT_EXIT,
-	CKRM_EVENT_EXEC,
-	CKRM_EVENT_UID,
-	CKRM_EVENT_GID,
-	CKRM_EVENT_LOGIN,
-	CKRM_EVENT_USERADD,
-	CKRM_EVENT_USERDEL,
-	CKRM_EVENT_LISTEN_START,
-	CKRM_EVENT_LISTEN_STOP,
-	CKRM_EVENT_APPTAG,
-
-	/* events (b) */
-
-	CKRM_NONLATCHABLE_EVENTS,
-
-	CKRM_EVENT_RECLASSIFY = CKRM_NONLATCHABLE_EVENTS,
-
-	/* events (c) */
-
-	CKRM_NOTCLASSIFY_EVENTS,
-
-	CKRM_EVENT_MANUAL = CKRM_NOTCLASSIFY_EVENTS,
-
-	CKRM_NUM_EVENTS
-};
-
-/*
- * CKRM event callback specification for the classtypes or resource controllers
- *   typically an array is specified using CKRM_EVENT_SPEC terminated with
- *   CKRM_EVENT_SPEC_LAST and then that array is registered using
- *   ckrm_register_event_set.
- *   Individual registration of event_cb is also possible
- */
-
-struct ckrm_hook_cb {
-	void (*fct)(void *arg);
-	struct ckrm_hook_cb *next;
-};
-
-struct ckrm_event_spec {
-	enum ckrm_event ev;
-	struct ckrm_hook_cb cb;
-};
-
-int ckrm_register_event_set(struct ckrm_event_spec especs[]);
-int ckrm_unregister_event_set(struct ckrm_event_spec especs[]);
-int ckrm_register_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
-int ckrm_unregister_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb);
-
-extern void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg);
-
-/* forward declarations for function arguments */
-
-#include <linux/sched.h>		/* for task_struct */
-
-struct sock;
-struct user_struct;
-
-static inline void ckrm_cb_fork(struct task_struct *p)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_FORK, p);
-}
-
-static inline void ckrm_cb_newtask(struct task_struct *p)
-{
-
-	p->ce_data = NULL;
-	spin_lock_init(&p->ckrm_tsklock);
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_NEWTASK, p);
-}
-
-static inline void ckrm_cb_exit(struct task_struct *p)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_EXIT, p);
-	p->ce_data = NULL;
-}
-
-static inline void ckrm_cb_exec(char *c)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_EXEC, c);
- }
-
-static inline void ckrm_cb_uid(void)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_UID, NULL);
-}
-
-static inline void ckrm_cb_gid(void)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_GID, NULL);
-}
-
-static inline void ckrm_cb_apptag(void)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_APPTAG, NULL);
-}
-
-static inline void ckrm_cb_login(void)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_LOGIN, NULL);
-}
-
-static inline void ckrm_cb_useradd(struct user_struct *u)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_USERADD, u);
-}
-
-static inline void ckrm_cb_userdel(struct user_struct *u)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_USERDEL, u);
-}
-
-static inline void ckrm_cb_listen_start(struct sock *s)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_LISTEN_START, s);
-}
-
-static inline void ckrm_cb_listen_stop(struct sock *s)
-{
-	ckrm_invoke_event_cb_chain(CKRM_EVENT_LISTEN_STOP, s);
-}
-
-extern void ckrm_init(void);
-
-#else /* !CONFIG_CKRM */
-
-static inline void ckrm_cb_fork(struct task_struct *p) { }
-static inline void ckrm_cb_newtask(struct task_struct *p) { }
-static inline void ckrm_cb_exit(struct task_struct *p) { }
-static inline void ckrm_cb_exec(const char *c) { }
-static inline void ckrm_cb_uid(void) { }
-static inline void ckrm_cb_gid(void) { }
-static inline void ckrm_cb_apptag(void) { }
-static inline void ckrm_cb_login(void) { }
-static inline void ckrm_cb_useradd(struct user_struct *u) { }
-static inline void ckrm_cb_userdel(struct user_struct *u) { }
-static inline void ckrm_cb_listen_start(struct sock *s) { }
-static inline void ckrm_cb_listen_stop(struct sock *s) { }
-
-#define ckrm_init()	do { } while (0)
-
-#endif /* CONFIG_CKRM */
-
-#endif /* _LINUX_CKRM_EVENTS_H */
Index: linux-2.6.13-rc6/include/linux/ckrm_rc.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/ckrm_rc.h
+++ linux-2.6.13-rc6/include/linux/ckrm_rc.h
@@ -22,12 +22,10 @@
 #define _LINUX_CKRM_RC_H
 
 #ifdef CONFIG_CKRM
 
 #include <linux/list.h>
-#include <linux/ckrm_events.h>
-#include <linux/ckrm_ce.h>
 #include <linux/seq_file.h>
 
 #define CKRM_MAX_CLASSTYPES         32	/* maximum number of class types */
 #define CKRM_MAX_CLASSTYPE_NAME     32 	/* maximum classtype name length */
 
@@ -117,16 +115,10 @@ struct ckrm_classtype {
 
 	struct ckrm_core_class *default_class;
 	struct list_head classes;  /* link all classes of this classtype */
 	int num_classes;
 
-	/* state about my ce interaction */
-	atomic_t ce_regd;		/* if CE registered */
-	int ce_cb_active;		/* if Callbacks active */
-	atomic_t ce_nr_users;		/* number of active transient calls */
-	struct ckrm_eng_callback ce_callbacks;	/* callback engine */
-
 	/* Begin classtype-rcfs private data. No rcfs/fs specific types used.  */
 
 	int mfidx;		/* Index into genmfdesc array used to initialize */
 	void *mfdesc;		/* Array of descriptors of root and magic files */
 	int mfcount;		/* length of above array */
@@ -185,11 +177,11 @@ struct ckrm_core_class {
 	void *res_class[CKRM_MAX_RES_CTLRS];	/* resource classes */
 	spinlock_t class_lock;	                /* protects list,array above */
 
 	struct list_head objlist;		/* generic object list */
 	struct list_head clslist;		/* peer classtype classes */
-	struct dentry *dentry;			/* dentry of inode in the RCFS */
+	struct dentry *dentry;			/* dentry of inode in RCFS */
 	int magic;
 
 	struct ckrm_hnode hnode;		/* hierarchy */
 	rwlock_t hnode_rwlock;			/* protects hnode above. */
 	atomic_t refcnt;
@@ -293,48 +285,13 @@ static inline unsigned int ckrm_is_core_
            )
 
 extern struct ckrm_classtype *ckrm_classtypes[];
 
 /*
- * CE Invocation interface
- */
-
-#define ce_protect(ctype)      (atomic_inc(&((ctype)->ce_nr_users)))
-#define ce_release(ctype)      (atomic_dec(&((ctype)->ce_nr_users)))
-
-/* CE Classification callbacks with */
-
-#define CE_CLASSIFY_NORET(ctype, event, objs_to_classify...)		\
-do {									\
-	if ((ctype)->ce_cb_active					\
-	    && (test_bit(event,&(ctype)->ce_callbacks.c_interest)))	\
-		(*(ctype)->ce_callbacks.classify)(event,		\
-						  objs_to_classify);	\
-} while (0)
-
-#define CE_CLASSIFY_RET(ret, ctype, event, objs_to_classify...)		\
-do {									\
-	if ((ctype)->ce_cb_active					\
-	    && (test_bit(event,&(ctype)->ce_callbacks.c_interest)))	\
-		ret = (*(ctype)->ce_callbacks.classify)(event,		\
-							objs_to_classify);\
-} while (0)
-
-#define CE_NOTIFY(ctype, event, cls, objs_to_classify)			\
-do {									\
-	if ((ctype)->ce_cb_active					\
-	    && (test_bit(event,&(ctype)->ce_callbacks.n_interest)))	\
-		(*(ctype)->ce_callbacks.notify)(event,			\
-						cls,objs_to_classify);	\
-} while (0)
-
-/*
  * RCFS related
  */
 
 /* vars needed by other modules/core */
-
 extern int rcfs_mounted;
-extern int rcfs_engine_regd;
 
 #endif /* CONFIG_CKRM */
 #endif /* _LINUX_CKRM_RC_H */
Index: linux-2.6.13-rc6/fs/rcfs/super.c
===================================================================
--- linux-2.6.13-rc6.orig/fs/rcfs/super.c
+++ linux-2.6.13-rc6/fs/rcfs/super.c
@@ -27,11 +27,10 @@
 #include <linux/smp_lock.h>
 #include <linux/backing-dev.h>
 #include <linux/parser.h>
 #include <linux/rcfs.h>
 #include <linux/ckrm_rc.h>
-#include <linux/ckrm_ce.h>
 #include <asm/uaccess.h>
 
 static kmem_cache_t *rcfs_inode_cachep;
 
 inline struct rcfs_inode_info *rcfs_get_inode_info(struct inode *inode)
@@ -154,30 +153,10 @@ static int rcfs_fill_super(struct super_
 		printk("A non null classtype\n");
 
 		if ((rc = rcfs_register_classtype(clstype)))
 			continue;	/* could return with an error too */
 	}
-
-	/*
-	 * do post-mount initializations needed by CE
-	 * this is distinct from CE registration done on rcfs module load
-	 */
-	if (rcfs_engine_regd) {
-		if (rcfs_eng_callbacks.mnt)
-			if ((rc = (*rcfs_eng_callbacks.mnt) ())) {
-				printk(KERN_ERR "Error in CE mnt %d\n", rc);
-			}
-	}
-	/*
-	 * Following comment handled by code above; keep nonetheless if it
-	 * can be done better
-	 *
-	 * register CE's with rcfs
-	 * check if CE loaded
-	 * call rcfs_register_engine for each classtype
-	 * AND rcfs_mkroot (preferably subsume latter in former)
-	 */
 	return 0;
 }
 
 static struct super_block *rcfs_get_sb(struct file_system_type *fs_type,
 				       int flags, const char *dev_name,
@@ -206,39 +185,10 @@ void rcfs_kill_sb(struct super_block *sb
 			printk(KERN_ERR "Error removing classtype %s\n",
 			       clstype->name);
 		}
 	}
 
-	/*
-	 * do pre-umount shutdown needed by CE
-	 * this is distinct from CE deregistration done on rcfs module unload
-	 */
-	if (rcfs_engine_regd) {
-		if (rcfs_eng_callbacks.umnt)
-			if ((rc = (*rcfs_eng_callbacks.umnt) ())) {
-				printk(KERN_ERR "Error in CE umnt %d\n", rc);
-				/* TODO: return ; until error handling improves */
-			}
-	}
-	/*
-	 * Following comment handled by code above; keep nonetheless if it
-	 * can be done better
-	 *
-	 * deregister CE with rcfs
-	 * Check if loaded
-	 * if ce is in  one directory /rcfs/ce,
-	 *       rcfs_deregister_engine for all classtypes within above
-	 *             codebase
-	 *       followed by
-	 *       rcfs_rmroot here
-	 * if ce in multiple (per-classtype) directories
-	 *       call rbce_deregister_engine within ckrm_deregister_classtype
-	 *
-	 * following will automatically clear rcfs root entry including its
-	 *  rcfs_inode_info
-	 */
-
 	generic_shutdown_super(sb);
 }
 
 static struct file_system_type rcfs_fs_type = {
 	.name = "rcfs",
Index: linux-2.6.13-rc6/include/linux/crbce.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/crbce.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * crbce.h
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- * Copyright (C) Chandra Seetharaman, IBM Corp. 2004
- *
- * This files contains the type definition of the record
- * created by the CRBCE CKRM classification engine
- *
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *
- */
-
-#ifndef _LINUX_CRBCE_H
-#define _LINUX_CRBCE_H
-
-#ifdef __KERNEL__
-#include <linux/autoconf.h>
-#else
-#define  CONFIG_CKRM
-#define  CONFIG_CRBCE
-#define  CONFIG_DELAY_ACCT
-#endif
-
-#include <linux/types.h>
-#include <linux/ckrm_events.h>
-#include <linux/ckrm_ce.h>
-#include <linux/taskdelays.h>
-
-#define CRBCE_MAX_CLASS_NAME_LEN  256
-
-/****************************************************************
- *
- *  CRBCE EVENT SET is an extension to the standard CKRM_EVENTS
- *
- ****************************************************************/
-
-typedef int __bitwise crbce_event_t;
-enum crbce_event {
-
-	/* we use the standard CKRM_EVENT_<..>
-	 * to identify reclassification cause actions
-	 * and extend by additional ones we need
-	 */
-
-	/* up event flow */
-
-	CRBCE_REC_EXIT = (__force crbce_event_t) (CKRM_NUM_EVENTS+1),
-	CRBCE_REC_DATA_DELIMITER = (__force crbce_event_t) (CRBCE_REC_EXIT+2),
-	CRBCE_REC_SAMPLE = (__force crbce_event_t) (CRBCE_REC_EXIT+3),
-	CRBCE_REC_TASKINFO = (__force crbce_event_t) (CRBCE_REC_EXIT+4),
-	CRBCE_REC_SYS_INFO = (__force crbce_event_t) (CRBCE_REC_EXIT+5),
-	CRBCE_REC_CLASS_INFO = (__force crbce_event_t) (CRBCE_REC_EXIT+6),
-	CRBCE_REC_KERNEL_CMD_DONE = (__force crbce_event_t) (CRBCE_REC_EXIT+7),
-	CRBCE_REC_UKCC_FULL = (__force crbce_event_t) (CRBCE_REC_EXIT+8),
-
-	/* down command issueance */
-	CRBCE_REC_KERNEL_CMD = (__force crbce_event_t) (CRBCE_REC_EXIT+9),
-
-	CRBCE_NUM_EVENTS = (__force crbce_event_t) (CRBCE_REC_EXIT+10)
-};
-
-struct task_sample_info {
-	uint32_t cpu_running;
-	uint32_t cpu_waiting;
-	uint32_t io_delayed;
-	uint32_t memio_delayed;
-};
-
-/*********************************************
- *          KERNEL -> USER  records          *
- *********************************************/
-
-/* we have records with either a time stamp or not */
-struct crbce_hdr {
-	int type;
-	pid_t pid;
-};
-
-struct crbce_hdr_ts {
-	int type;
-	pid_t pid;
-	uint32_t timestamp;  /* in msecs */
-	uint64_t cls;
-};
-
-/* individual records */
-
-struct crbce_rec_fork {
-	struct crbce_hdr_ts hdr;
-	pid_t ppid;
-};
-
-struct crbce_rec_data_delim {
-	struct crbce_hdr_ts hdr;
-	int is_stop;		/* 0 start, 1 stop */
-};
-
-struct crbce_rec_task_data {
-	struct crbce_hdr_ts hdr;
-	struct task_sample_info sample;
-	struct task_delay_info delay;
-};
-
-struct crbce_ukcc_full {
-	struct crbce_hdr_ts hdr;
-};
-
-struct crbce_class_info {
-	struct crbce_hdr_ts hdr;
-	int action;
-	int namelen;
-	char name[CRBCE_MAX_CLASS_NAME_LEN];
-};
-
-/*********************************************
- *           USER -> KERNEL records          *
- *********************************************/
-
-typedef int __bitwise crbce_kernel_cmd_t;
-enum crbce_kernel_cmd {
-	CRBCE_CMD_START = (__force crbce_kernel_cmd_t) 1,
-	CRBCE_CMD_STOP = (__force crbce_kernel_cmd_t) 2,
-	CRBCE_CMD_SET_TIMER = (__force crbce_kernel_cmd_t) 3,
-	CRBCE_CMD_SEND_DATA = (__force crbce_kernel_cmd_t) 4,
-};
-
-struct crbce_command {
-	int type;		/* we need this for the K->U reflection */
-	int cmd;
-	uint32_t len;	/* added in the kernel for reflection */
-};
-
-#define set_cmd_hdr(rec,tok) \
-	((rec).hdr.type=CRBCE_REC_KERNEL_CMD,(rec).hdr.cmd=(tok))
-
-struct crbce_cmd_done {
-	struct crbce_command hdr;
-	int rc;
-};
-
-struct crbce_cmd {
-	struct crbce_command hdr;
-};
-
-struct crbce_cmd_send_data {
-	struct crbce_command hdr;
-	int delta_mode;
-};
-
-struct crbce_cmd_settimer {
-	struct crbce_command hdr;
-	uint32_t interval;	/* in msec .. 0 means stop */
-};
-#endif
Index: linux-2.6.13-rc6/include/linux/rbce.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/rbce.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Rule-based Classification Engine (RBCE) module
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *
- * Module for loading of classification policies and providing
- * a user API for Class-based Kernel Resource Management (CKRM)
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2.1 of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *
- */
-
-#ifndef _LINUX_RBCE_H
-#define _LINUX_RBCE_H
-
-struct rbce_class;
-#ifndef CRBCE_EXTENSION
-
-/****************************************************************************
- *
- *   RBCE STANDALONE VERSION, NO CHOICE FOR DATA COLLECTION
- *
- ****************************************************************************/
-
-#define RBCE_MOD_DESCR "Rule Based Classification Engine Module for CKRM"
-#define RBCE_MOD_NAME  "rbce"
-
-struct rbce_ext_private_data {
-	/* no data */
-};
-static inline void send_exit_notification(struct task_struct *tsk)
-{
-}
-static inline void notify_class_action(struct rbce_class *cls, int action)
-{
-}
-/* extension initialization and destruction at module init and exit */
-static inline int init_rbce_ext_pre(void)
-{
-	return 0;
-}
-static inline int init_rbce_ext_post(void)
-{
-	return 0;
-}
-static inline void exit_rbce_ext(void)
-{
-}
-#else /* CRBCE_EXTENSION */
-
-/***************************************************************************
- *
- *   RBCE with User Level Notification
- *
- ***************************************************************************/
-
-#define RBCE_MOD_DESCR 	"Rule Based Classification Engine Module" \
-			"with Data Sampling/Delivery for CKRM"
-#define RBCE_MOD_NAME 	"crbce"
-
-#include <linux/crbce.h>
-
-struct rbce_ext_private_data {
-	struct task_sample_info sample;
-};
-
-#endif	/* CRBCE_EXTENSION */
-
-#endif	/* _LINUX_RBCE_H */
Index: linux-2.6.13-rc6/include/linux/rcfs.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/rcfs.h
+++ linux-2.6.13-rc6/include/linux/rcfs.h
@@ -1,13 +1,11 @@
 #ifndef _LINUX_RCFS_H
 #define _LINUX_RCFS_H
 
 #include <linux/kernel.h>
 #include <linux/fs.h>
-#include <linux/ckrm_events.h>
 #include <linux/ckrm_rc.h>
-#include <linux/ckrm_ce.h>
 
 /*
  * The following declarations cannot be included in any of ckrm*.h files
  * without jumping hoops. Remove later when rearrangements done
  */
@@ -94,8 +92,7 @@ int rcfs_deregister_classtype(struct ckr
 int rcfs_mkroot(struct rcfs_magf *, int, struct dentry **);
 int rcfs_rmroot(struct dentry *);
 
 #define RCFS_ROOT "/rcfs"  	/* TODO:  Should use the mount point */
 extern struct dentry *rcfs_rootde;
-extern struct rbce_eng_callback rcfs_eng_callbacks;
 
 #endif	/* _LINUX_RCFS_H */
Index: linux-2.6.13-rc6/fs/rcfs/rootdir.c
===================================================================
--- linux-2.6.13-rc6.orig/fs/rcfs/rootdir.c
+++ linux-2.6.13-rc6/fs/rcfs/rootdir.c
@@ -28,40 +28,10 @@
 #include <linux/backing-dev.h>
 #include <linux/parser.h>
 #include <linux/rcfs.h>
 #include <asm/uaccess.h>
 
-struct rbce_eng_callback rcfs_eng_callbacks = {
-	NULL, NULL
-};
-
-int rcfs_register_engine(struct rbce_eng_callback * rcbs)
-{
-	if (!rcbs->mkdir || rcfs_eng_callbacks.mkdir) {
-		return -EINVAL;
-	}
-	rcfs_eng_callbacks = *rcbs;
-	rcfs_engine_regd++;
-	return 0;
-}
-
-EXPORT_SYMBOL_GPL(rcfs_register_engine);
-
-int rcfs_unregister_engine(struct rbce_eng_callback * rcbs)
-{
-	if (!rcbs->mkdir || !rcfs_eng_callbacks.mkdir ||
-	    (rcbs->mkdir != rcfs_eng_callbacks.mkdir)) {
-		return -EINVAL;
-	}
-	rcfs_eng_callbacks.mkdir = NULL;
-	rcfs_eng_callbacks.rmdir = NULL;
-	rcfs_engine_regd--;
-	return 0;
-}
-
-EXPORT_SYMBOL_GPL(rcfs_unregister_engine);
-
 /*
  * rcfs_mkroot
  * Create and return a "root" dentry under /rcfs.
  * Also create associated magic files
  *
Index: linux-2.6.13-rc6/kernel/ckrm/Makefile
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/Makefile
+++ linux-2.6.13-rc6/kernel/ckrm/Makefile
@@ -1,9 +1,8 @@
 #
 # Makefile for CKRM
 #
 
-obj-y += ckrm_events.o ckrm.o ckrmutils.o
+obj-y += ckrm.o ckrmutils.o
 obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o ckrm_numtasks_stub.o
 obj-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += ckrm_sockc.o
 obj-$(CONFIG_CKRM_RES_NUMTASKS) += ckrm_numtasks.o
-obj-$(CONFIG_CKRM_RBCE) += rbce/
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/Makefile
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for RBCE
-#
-
-obj-$(CONFIG_CKRM_RBCE)	+= rbce.o
-rbce-objs := rbce_fs.o rbce_main.o rbce_token.o rbce_core.o
-
-obj-$(CONFIG_CKRM_CRBCE)	+= crbce.o
-crbce-objs := rbce_fs.o crbce_main.o rbce_token.o rbce_core.o crbce_ext.o
-
-CFLAGS_crbce_main.o += -DCRBCE_EXTENSION
-CFLAGS_crbce_ext.o += -DCRBCE_EXTENSION
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/crbce_ext.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/crbce_ext.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/* Data Collection Extension to Rule-based Classification Engine (RBCE) module
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *
- * Extension to be included into RBCE to collect delay and sample information
- * Requires user daemon e.g. crbcedmn to activate.
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-/*
- *   User-Kernel Communication Channel (UKCC)
- *   Protocol and communication handling based on netlink
- */
-
-#include <net/sock.h>
-#include <linux/netlink.h>
-#include <linux/jiffies.h>
-#include "rbce_internal.h"
-
-#define PSAMPLE(pdata)    (&((pdata)->ext_data.sample))
-#define NETLINK_GFP_MASK	GFP_ATOMIC
-
-typedef int __bitwise ukcc_state_t;
-enum ukcc_state {
-	UKCC_OK = (__force ukcc_state_t) 0,
-	UKCC_STANDBY = (__force ukcc_state_t) 1,
-	UKCC_FULL =  (__force ukcc_state_t) 2
-};
-
-int ukcc_channel = -1;
-static enum ukcc_state chan_state = UKCC_STANDBY;
-static void ukcc_cmd_deliver(int rchan_id, char *from, u32 len);
-static struct sock *ukcc_sock = NULL;
-
-static inline int ukcc_ok(void)
-{
-	return (chan_state == UKCC_OK);
-}
-
-static inline int ukcc_send(void *data, int len)
-{
-	int rc;
-	char *saddr;
-	struct sk_buff *skb;
-	struct nlmsghdr *nlh = NULL;
-	int nlmessage_len = NLMSG_LENGTH(sizeof(struct nlmsghdr) + len);
-
-	skb = alloc_skb(nlmessage_len, NETLINK_GFP_MASK);
-	if (!skb)
-		return -ENOMEM;
-	nlh = NLMSG_PUT(skb, 0, 0, NETLINK_CKRM, len); /* pid, type, event */
-	saddr = NLMSG_DATA(nlh);
-	memcpy(saddr, data, len);
-
-	rc = netlink_broadcast(ukcc_sock, skb, 0, 1, NETLINK_GFP_MASK);
-	return (rc < 0) ? rc : 1;
-
-nlmsg_failure:
-	return -1;
-}
-
-static void ukcc_netlink_recv(struct sock *sk, int len)
-{
-	int skblen;
-	struct sk_buff *skb;
-	struct nlmsghdr *nlh;
-
-	while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
-		skblen = skb->len;
-		nlh = (struct nlmsghdr *)skb->data;
-		if (!NLMSG_OK(nlh, skblen))
-			return;
-		if (nlh->nlmsg_type == NLMSG_NOOP)
-			return;
-		if (nlh->nlmsg_flags & MSG_TRUNC) {
-			netlink_ack(skb, nlh, -ECOMM);
-			return;
-		}
-		if (nlh->nlmsg_flags & NLM_F_ACK)
-			netlink_ack(skb, nlh, 0);
-
-		/* write the command back to the sender
-		 * this can be probably done better through setup in
-		 * userspace, but we have no guarantee of ordering then..
-		 */
-		(void) ukcc_send(NLMSG_DATA(nlh), skblen - NLMSG_LENGTH(0));
-		ukcc_cmd_deliver(0, NLMSG_DATA(nlh), skblen - NLMSG_LENGTH(0));
-		kfree_skb(skb);
-	}
-}
-
-static int create_ukcc_channel(void)
-{
-	ukcc_sock = netlink_kernel_create(NETLINK_CKRM, ukcc_netlink_recv);
-
-	if (!ukcc_sock) {
-		printk(KERN_ERR "kevent: "
-			"unable to create netlink socket; aborting\n");
-		return -ENODEV;
-	}
-	ukcc_channel = 0;
-	return ukcc_channel;
-}
-
-static inline void close_ukcc_channel(void)
-{
-	if (ukcc_channel >= 0) {
-		sock_release(ukcc_sock->sk_socket);
-		ukcc_channel = -1;
-		chan_state = UKCC_STANDBY;
-	}
-}
-
-#define rec_set_hdr(r,t,p)      ((r)->hdr.type = (t), (r)->hdr.pid = (p))
-#define rec_set_timehdr(r,t,p,c)  (rec_set_hdr(r,t,p), \
-	(r)->hdr.timestamp = jiffies_to_msecs(jiffies), \
-	(r)->hdr.cls=(unsigned long)(c) )
-
-#if CHANNEL_AUTO_CONT
-
-/* we only provide this for debugging.. it allows us to send records
- * based on availability in the channel when the UKCC stalles rather
- * going through the UKCC recovery protocol
- */
-static inline void rec_send_len(void *r, size_t l)
-{
-	int chan_wasok = (chan_state == UKCC_OK);
-	int chan_isok = (ukcc_send(r, l) > 0);
-
-	chan_state = chan_isok ? UKCC_OK : UKCC_STANDBY;
-	if (chan_wasok && !chan_isok)
-		printk(KERN_WARN "Channel stalled\n");
-	else if (!chan_wasok && chan_isok)
-		printk(KERN_INFO "Channel continues\n");
-}
-
-#else
-
-/* Default UKCC channel protocol.
- * Though a UKCC buffer overflow should not happen ever, it is possible iff
- * the user daemon stops reading for some reason. Hence we provide a simple
- * protocol based on 3 states
- *     UKCC_OK      :=	channel is active and properly working. When a
- *			channel write fails we move to state CHAN_FULL.
- *     UKCC_FULL    :=	channel is active, but the last send_rec has failed.
- *			As a result we will try to send an indication to
- *			the daemon that this has happened. When that
- *			succeeds, we move to state UKCC_STANDBY.
- *     UKCC_STANDBY := 	we are waiting to be restarted by the user daemon
- *
- */
-
-static void ukcc_full(void)
-{
-	static spinlock_t ukcc_state_lock = SPIN_LOCK_UNLOCKED;
-	/*
-	 * protect transition from OK -> FULL to ensure only one record
-	 * is sent, rest we do not need to protect, protocol implies
-	 * that.
-	*/
-	int send = 0;
-	spin_lock(&ukcc_state_lock);
-	if ((send = (chan_state != UKCC_STANDBY)))
-		chan_state = UKCC_STANDBY;	/* assume we can send */
-	spin_unlock(&ukcc_state_lock);
-
-	if (send) {
-		struct crbce_ukcc_full rec;
-		rec_set_timehdr(&rec, CRBCE_REC_UKCC_FULL, 0, 0);
-		if (ukcc_send(&rec, sizeof(rec)) < 0)
-			/* channel is remains full .. try with next one */
-			chan_state = UKCC_FULL;
-	}
-}
-
-static inline void rec_send_len(void *r, size_t l)
-{
-	switch (chan_state) {
-	case UKCC_OK:
-		if (ukcc_send(r, l) > 0)
-			break;
-		/*FALLTHRU*/
-	case UKCC_FULL:
-		ukcc_full();
-		break;
-	default:
-		break;
-	}
-}
-
-#endif
-
-#define rec_send(r)	rec_send_len(r, sizeof(*(r)))
-
-/****************************************************************************
- *
- *  Callbacks for the CKRM engine.
- *    In each we do the necessary classification and event record generation
- *    We generate 3 kind of records in the callback
- *    (a) FORK              	send the pid, the class and the ppid
- *    (b) RECLASSIFICATION  	send the pid, the class and < sample data +
- *				delay data >
- *    (b) EXIT              	send the pid
- *
-*****************************************************************************/
-
-int delta_mode = 0;
-
-static inline void copy_delay(struct task_delay_info *delay,
-			      struct task_struct *tsk)
-{
-	*delay = tsk->delays;
-}
-
-static inline void zero_delay(struct task_delay_info *delay)
-{
-	memset(delay, 0, sizeof(struct task_delay_info));
-	/* we need to think about doing this 64-bit atomic */
-}
-
-static inline void zero_sample(struct task_sample_info *sample)
-{
-	memset(sample, 0, sizeof(struct task_sample_info));
-	/* we need to think about doing this 64-bit atomic */
-}
-
-static inline int check_zero(void *ptr, int len)
-{
-	int iszero = 1;
-	int i;
-	unsigned long *uptr = (unsigned long *)ptr;
-
-	for (i = len / sizeof(unsigned long); i-- && iszero; uptr++)
-		/* assume its rounded */
-		iszero &= (*uptr == 0);
-	return iszero;
-}
-
-static inline int check_not_zero(void *ptr, int len)
-{
-	int i;
-	unsigned long *uptr = (unsigned long *)ptr;
-
-	for (i = len / sizeof(unsigned long); i--; uptr++)
-		/* assume its rounded */
-		if (*uptr)
-			return 1;
-	return 0;
-}
-
-static inline int sample_changed(struct task_sample_info *s)
-{
-	return check_not_zero(s, sizeof(*s));
-}
-static inline int delay_changed(struct task_delay_info *d)
-{
-	return check_not_zero(d, sizeof(*d));
-}
-
-static inline int
-send_task_record(struct task_struct *tsk, int event,
-		 struct ckrm_core_class *core, int send_forced)
-{
-	struct crbce_rec_task_data rec;
-	struct rbce_private_data *pdata;
-	int send = 0;
-
-	if (!ukcc_ok())
-		return 0;
-	pdata = RBCE_DATA(tsk);
-	if (pdata == NULL)
-		return 0;
-	if (send_forced || (delta_mode == 0)
-	    || sample_changed(PSAMPLE(RBCE_DATA(tsk)))
-	    || delay_changed(&tsk->delays)) {
-		rec_set_timehdr(&rec, event, tsk->pid,
-				core ? core : (struct ckrm_core_class *)tsk->
-				taskclass);
-		rec.sample = *PSAMPLE(RBCE_DATA(tsk));
-		copy_delay(&rec.delay, tsk);
-		rec_send(&rec);
-		if (delta_mode || send_forced) {
-			/* on reclassify or delta mode reset the counters */
-			zero_sample(PSAMPLE(RBCE_DATA(tsk)));
-			zero_delay(&tsk->delays);
-		}
-		send = 1;
-	}
-	return send;
-}
-
-void send_exit_notification(struct task_struct *tsk)
-{
-	send_task_record(tsk, CRBCE_REC_EXIT, NULL, 1);
-}
-
-void
-rbce_tc_ext_notify(int event, void *core, struct task_struct *tsk)
-{
-	struct crbce_rec_fork rec;
-
-	switch (event) {
-	case CKRM_EVENT_FORK:
-		if (ukcc_ok()) {
-			rec.ppid = tsk->parent->pid;
-			rec_set_timehdr(&rec, CKRM_EVENT_FORK, tsk->pid, core);
-			rec_send(&rec);
-		}
-		break;
-	case CKRM_EVENT_MANUAL:
-		rbce_tc_manual(tsk);
-
-	default:
-		send_task_record(tsk, event, (struct ckrm_core_class *)core, 1);
-		break;
-	}
-}
-
-/*====================== end classification engine =======================*/
-
-static void sample_task_data(unsigned long unused);
-
-struct timer_list sample_timer = {.expires = 0,.function = sample_task_data };
-unsigned long timer_interval_length = (250 * HZ) / 1000;
-
-inline void stop_sample_timer(void)
-{
-	if (sample_timer.expires > 0) {
-		del_timer_sync(&sample_timer);
-		sample_timer.expires = 0;
-	}
-}
-
-inline void start_sample_timer(void)
-{
-	if (timer_interval_length > 0) {
-		sample_timer.expires =
-		    jiffies + (timer_interval_length * HZ) / 1000;
-		add_timer(&sample_timer);
-	}
-}
-
-static void send_task_data(void)
-{
-	struct crbce_rec_data_delim limrec;
-	struct task_struct *proc, *thread;
-	int sendcnt = 0;
-	int taskcnt = 0;
-	limrec.is_stop = 0;
-	rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
-	rec_send(&limrec);
-
-	read_lock(&tasklist_lock);
-	do_each_thread(proc, thread) {
-		taskcnt++;
-		task_lock(thread);
-		sendcnt += send_task_record(thread, CRBCE_REC_SAMPLE, NULL, 0);
-		task_unlock(thread);
-	} while_each_thread(proc, thread);
-	read_unlock(&tasklist_lock);
-
-	limrec.is_stop = 1;
-	rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
-	rec_send(&limrec);
-
-}
-
-void notify_class_action(struct rbce_class *cls, int action)
-{
-	struct crbce_class_info cinfo;
-	int len;
-
-	rec_set_timehdr(&cinfo, CRBCE_REC_CLASS_INFO, 0, cls->classobj);
-	cinfo.action = action;
-	len = strnlen(cls->obj.name, CRBCE_MAX_CLASS_NAME_LEN - 1);
-	memcpy(&cinfo.name, cls->obj.name, len);
-	cinfo.name[len] = '\0';
-	len++;
-	cinfo.namelen = len;
-
-	len += sizeof(cinfo) - CRBCE_MAX_CLASS_NAME_LEN;
-	rec_send_len(&cinfo, len);
-}
-
-static void send_classlist(void)
-{
-	struct rbce_class *cls;
-
-	read_lock(&rbce_rwlock);
-	list_for_each_entry(cls, &class_list, obj.link)
-		notify_class_action(cls, 1);
-	read_unlock(&rbce_rwlock);
-}
-
-/*
- *  resend_task_info
- *
- *  This function resends all essential task information to the client.
- */
-static void resend_task_info(void)
-{
-	struct crbce_rec_data_delim limrec;
-	struct crbce_rec_fork rec;
-	struct task_struct *proc, *thread;
-
-	send_classlist();	/* first send available class information */
-
-	limrec.is_stop = 2;
-	rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
-	rec_send(&limrec);
-
-	write_lock(&tasklist_lock);	/* avoid any mods during this phase */
-	do_each_thread(proc, thread)
-		if (ukcc_ok()) {
-			rec.ppid = thread->parent->pid;
-			rec_set_timehdr(&rec, CRBCE_REC_TASKINFO, thread->pid,
-					thread->taskclass);
-			rec_send(&rec);
-		}
-	while_each_thread(proc, thread);
-	write_unlock(&tasklist_lock);
-
-	limrec.is_stop = 3;
-	rec_set_timehdr(&limrec, CRBCE_REC_DATA_DELIMITER, 0, 0);
-	rec_send(&limrec);
-}
-
-static void add_all_private_data(void)
-{
-	struct task_struct *proc, *thread;
-
-	write_lock(&tasklist_lock);
-	do_each_thread(proc, thread)
-		if (RBCE_DATA(thread) == NULL)
-			RBCE_DATAP(thread) = create_private_data(NULL, 0);
-	while_each_thread(proc, thread);
-	write_unlock(&tasklist_lock);
-}
-
-static void sample_task_data(unsigned long unused)
-{
-	struct task_struct *proc, *thread;
-
-	int run = 0;
-	int wait = 0;
-	read_lock(&tasklist_lock);
-	do_each_thread(proc, thread) {
-		struct rbce_private_data *pdata = RBCE_DATA(thread);
-
-		if (pdata == NULL)
-			/* some wierdo race condition .. simply ignore */
-			continue;
-		if (thread->state == TASK_RUNNING) {
-			if (task_curr(thread)) {
-				atomic_inc((atomic_t *) &
-					   (PSAMPLE(pdata)->cpu_running));
-				run++;
-			} else {
-				atomic_inc((atomic_t *) &
-					   (PSAMPLE(pdata)->cpu_waiting));
-				wait++;
-			}
-		}
-		/* update IO state */
-		if (thread->flags & PF_IOWAIT) {
-			if (thread->flags & PF_MEMIO)
-				atomic_inc((atomic_t *) &
-					   (PSAMPLE(pdata)->memio_delayed));
-			else
-				atomic_inc((atomic_t *) &
-					   (PSAMPLE(pdata)->io_delayed));
-		}
-	}
-	while_each_thread(proc, thread);
-	read_unlock(&tasklist_lock);
-	start_sample_timer();
-}
-
-static void ukcc_cmd_deliver(int rchan_id, char *from, u32 len)
-{
-	struct crbce_command *cmdrec = (struct crbce_command *)from;
-	struct crbce_cmd_done cmdret;
-	int rc = 0;
-
-	cmdrec->len = len;	/*
-				 * add this to reflection so the user doesn't
-				 * accidently write the wrong length and the
-				 * protocol is getting screwed up
-				 */
-
-	if (cmdrec->type != CRBCE_REC_KERNEL_CMD) {
-		rc = EINVAL;
-		goto out;
-	}
-
-	switch (cmdrec->cmd) {
-	case CRBCE_CMD_SET_TIMER:
-		{
-			struct crbce_cmd_settimer *cptr =
-			    (struct crbce_cmd_settimer *)cmdrec;
-			if (len != sizeof(*cptr)) {
-				rc = EINVAL;
-				break;
-			}
-			stop_sample_timer();
-			timer_interval_length = cptr->interval;
-			if ((timer_interval_length > 0)
-			    && (timer_interval_length < 10))
-				timer_interval_length = 10;
-				/* anything finer can create problems */
-			printk(KERN_INFO "CRBCE set sample collect timer %lu\n",
-			       timer_interval_length);
-			start_sample_timer();
-			break;
-		}
-	case CRBCE_CMD_SEND_DATA:
-		{
-			struct crbce_cmd_send_data *cptr =
-			    (struct crbce_cmd_send_data *)cmdrec;
-			if (len != sizeof(*cptr)) {
-				rc = EINVAL;
-				break;
-			}
-			delta_mode = cptr->delta_mode;
-			send_task_data();
-			break;
-		}
-	case CRBCE_CMD_START:
-		add_all_private_data();
-		chan_state = UKCC_OK;
-		resend_task_info();
-		break;
-
-	case CRBCE_CMD_STOP:
-		chan_state = UKCC_STANDBY;
-		free_all_private_data();
-		break;
-
-	default:
-		rc = EINVAL;
-		break;
-	}
-
-out:
-	cmdret.hdr.type = CRBCE_REC_KERNEL_CMD_DONE;
-	cmdret.hdr.cmd = cmdrec->cmd;
-	cmdret.rc = rc;
-	rec_send(&cmdret);
-}
-
-int init_rbce_ext_pre(void)
-{
-	int rc;
-
-	rc = create_ukcc_channel();
-	return ((rc < 0) ? rc : 0);
-}
-
-int init_rbce_ext_post(void)
-{
-	init_timer(&sample_timer);
-	return 0;
-}
-
-void exit_rbce_ext(void)
-{
-	stop_sample_timer();
-	close_ukcc_channel();
-}
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/crbce_main.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/crbce_main.c
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Easiest way to transmit a symbolic link as a patch */
-#include "rbce_main.c"
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_bitvector.h
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_bitvector.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *
- * Bitvector package
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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.
- *
- */
-
-#ifndef _RBCE_BITVECTOR_H
-#define _RBCE_BITVECTOR_H
-
-typedef struct {
-	int size;		/* maxsize in longs */
-	unsigned long bits[0];	/* bit vector */
-} bitvector_t;
-
-#define BITS_2_LONGS(sz)  (((sz)+BITS_PER_LONG-1)/BITS_PER_LONG)
-#define BITS_2_BYTES(sz)  (((sz)+7)/8)
-
-#if 0
-#define CHECK_VEC(vec) (vec)	/* check against NULL */
-#else
-#define CHECK_VEC(vec) (1)	/* assume no problem */
-#endif
-
-#define CHECK_VEC_VOID(vec)   do { if (!CHECK_VEC(vec)) return; } while(0)
-#define CHECK_VEC_RC(vec, val) \
-do { if (!CHECK_VEC(vec)) return (val); } while(0)
-
-inline static void bitvector_zero(bitvector_t * bitvec)
-{
-	int sz;
-
-	CHECK_VEC_VOID(bitvec);
-	sz = BITS_2_BYTES(bitvec->size);
-	memset(bitvec->bits, 0, sz);
-	return;
-}
-
-inline static unsigned long bitvector_bytes(unsigned long size)
-{
-	return sizeof(bitvector_t) + BITS_2_BYTES(size);
-}
-
-inline static void bitvector_init(bitvector_t * bitvec, unsigned long size)
-{
-	bitvec->size = size;
-	bitvector_zero(bitvec);
-	return;
-}
-
-inline static bitvector_t *bitvector_alloc(unsigned long size)
-{
-	bitvector_t *vec =
-	    (bitvector_t *) kmalloc(bitvector_bytes(size), GFP_KERNEL);
-	if (vec) {
-		vec->size = size;
-		bitvector_zero(vec);
-	}
-	return vec;
-}
-
-inline static void bitvector_free(bitvector_t * bitvec)
-{
-	CHECK_VEC_VOID(bitvec);
-	kfree(bitvec);
-	return;
-}
-
-#define def_bitvec_op(name,mod1,op,mod2) 			\
-inline static int name(bitvector_t *res, bitvector_t *op1,	\
-		       bitvector_t *op2)			\
-{								\
-	unsigned int i, size; 					\
-								\
-	CHECK_VEC_RC(res, 0); 					\
-	CHECK_VEC_RC(op1, 0); 					\
-	CHECK_VEC_RC(op2, 0); 					\
-	size = res->size; 					\
-	if (((size != (op1)->size) || (size != (op2)->size))) { \
-		return 0;					\
-	}							\
-	size = BITS_2_LONGS(size);				\
-	for (i = 0; i < size; i++) {				\
-		(res)->bits[i] = (mod1 (op1)->bits[i]) op 	\
-					(mod2 (op2)->bits[i]);	\
-	}							\
-	return 1;						\
-}
-
-def_bitvec_op(bitvector_or,, |,);
-def_bitvec_op(bitvector_and,, &,);
-def_bitvec_op(bitvector_xor,, ^,);
-def_bitvec_op(bitvector_or_not,, |, ~);
-def_bitvec_op(bitvector_not_or, ~, |,);
-def_bitvec_op(bitvector_and_not,, &, ~);
-def_bitvec_op(bitvector_not_and, ~, &,);
-
-inline static void bitvector_set(int idx, bitvector_t * vec)
-{
-	set_bit(idx, vec->bits);
-	return;
-}
-
-inline static void bitvector_clear(int idx, bitvector_t * vec)
-{
-	clear_bit(idx, vec->bits);
-	return;
-}
-
-inline static int bitvector_test(int idx, bitvector_t * vec)
-{
-	return test_bit(idx, vec->bits);
-}
-
-#ifdef DEBUG
-inline static void bitvector_print(int flag, bitvector_t * vec)
-{
-	unsigned int i;
-	int sz;
-	extern int rbcedebug;
-
-	if ((rbcedebug & flag) == 0) {
-		return;
-	}
-	if (vec == NULL) {
-		printk("v<0>-NULL\n");
-		return;
-	}
-	printk("v<%d>-", sz = vec->size);
-	for (i = 0; i < sz; i++) {
-		printk("%c", test_bit(i, vec->bits) ? '1' : '0');
-	}
-	return;
-}
-#else
-#define bitvector_print(x, y)
-#endif
-
-#endif				/* _RBCE_BITVECTOR_H */
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_core.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_core.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/* Rule-based Classification Engine (RBCE) and
- * Consolidated RBCE module code (combined)
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *           (C) Vivek Kashyap, IBM Corp. 2004
- *
- * Module for loading of classification policies and providing
- * a user API for Class-based Kernel Resource Management (CKRM)
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#include "rbce_internal.h"
-
-/* Callback from core when a class is created */
-static void rbce_class_addcb(const char *classname, void *clsobj, int classtype)
-{
-	struct rbce_class *cls;
-
-	write_lock(&rbce_rwlock);
- 	cls = get_class(classname, &classtype);
-	if (cls) {
-		cls->classobj = clsobj;
-		notify_class_action(cls, 1);
-	}
-	write_unlock(&rbce_rwlock);
-	return;
-}
-
-/*
- * Callback from core when a class is deleted.
- */
-static void
-rbce_class_deletecb(const char *classname, void *classobj, int classtype)
-{
-	static struct rbce_class *cls;
-	struct named_obj_hdr *pos;
-	struct rbce_rule *rule;
-
-	write_lock(&rbce_rwlock);
-	cls = find_class_name(classname);
-	if (cls) {
-		if (cls->classobj != classobj) {
-			printk(KERN_ERR "rbce: class %s changed identity\n",
-			       classname);
-		}
-#ifdef CRBCE_EXTENSION
-		put_class(cls);
-#endif
-		notify_class_action(cls, 0);
-		cls->classobj = NULL;
-		list_for_each_entry(pos, &rules_list[classtype], link) {
-			rule = (struct rbce_rule *)pos;
-			if (rule->target_class) {
-				if (!strcmp
-				    (rule->target_class->obj.name, classname)) {
-					put_class(cls);
-					rule->target_class = NULL;
-					rule->classtype = -1;
-				}
-			}
-		}
-		if ((cls = find_class_name(classname)) != NULL) {
-			put_class(cls); /* propably created thru addcb */
-		}
-	}
-	write_unlock(&rbce_rwlock);
-	return;
-}
-
-/*====================== Classification Functions =======================*/
-
-/*
- * Match the given full path name with the command expression.
- * This function treats the folowing 2 charaters as special if seen in
- * cmd_exp, all other chanracters are compared as is:
- *		? - compares to any one single character
- *		* - compares to one or more single characters
- *
- * If fullpath is 1, tsk_comm is compared in full. otherwise only the command
- * name (basename(tsk_comm)) is compared.
- */
-static inline int
-match_cmd(const char *tsk_comm, const char *cmd_exp, int fullpath)
-{
-	const char *c, *t, *last_ast, *cmd = tsk_comm;
-	char next_c;
-
-	/* get the command name if we don't have to match the fullpath */
-	if (!fullpath && ((c = strrchr(tsk_comm, '/')) != NULL)) {
-		cmd = c + 1;
-	}
-
-	/* now faithfully assume the entire pathname is in cmd */
-
-	/* we now have to effectively implement a regular expression
-	 * for now assume
-	 *    '?'   any single character
-	 *    '*'   one or more '?'
-	 *    rest  must match
-	 */
-
-	c = cmd_exp;
-	t = cmd;
-	if (t == NULL || c == NULL) {
-		return 0;
-	}
-
-	last_ast = NULL;
-	next_c = '\0';
-
-	while (*c && *t) {
-		switch (*c) {
-		case '?':
-			if (*t == '/') {
-				return 0;
-			}
-			c++;
-			t++;
-			continue;
-		case '*':
-			if (*t == '/') {
-				return 0;
-			}
-			/* eat up all '*' in c */
-			while (*(c + 1) == '*')
-				c++;
-			next_c = '\0';
-			last_ast = c;
-			/*t++; 	Add this for matching '*' with "one"
-				or more chars. */
-			while (*t && (*t != *(c + 1)) && *t != '/')
-				t++;
-			if (*t == *(c + 1)) {
-				c++;
-				if (*c != '/') {
-					if (*c == '?') {
-						if (*t == '/') {
-							return 0;
-						}
-						t++;
-						c++;
-					}
-					next_c = *c;
-					if (*c) {
-						if (*t == '/') {
-							return 0;
-						}
-						t++;
-						c++;
-						if (!*c && *t)
-							c = last_ast;
-					}
-				} else {
-					last_ast = NULL;
-				}
-				continue;
-			}
-			return 0;
-		case '/':
-			next_c = '\0';
-		 /*FALLTHRU*/ default:
-			if (*t == *c && next_c != *t) {
-				c++, t++;
-				continue;
-			} else {
-				/* reset to last asterix and
-				   continue from there */
-				if (last_ast) {
-					c = last_ast;
-				} else {
-					return 0;
-				}
-			}
-		}
-	}
-
-	/* check for trailing "*" */
-	while (*c == '*')
-		c++;
-
-	return (!*c && !*t);
-}
-
-static inline void reverse(char *str, int n)
-{
-	char s;
-	int i, j = n - 1;
-
-	for (i = 0; i < j; i++, j--) {
-		s = str[i];
-		str[i] = str[j];
-		str[j] = s;
-	}
-}
-
-static inline int itoa(int n, char *str)
-{
-	int i = 0, sz = 0;
-
-	do {
-		str[i++] = n % 10 + '0';
-		sz++;
-		n = n / 10;
-	} while (n > 0);
-
-	(void)reverse(str, sz);
-	return sz;
-}
-
-static inline int v4toa(__u32 y, char *a)
-{
-	int i;
-	int size = 0;
-
-	for (i = 0; i < 4; i++) {
-		size += itoa(y & 0xff, &a[size]);
-		a[size++] = '.';
-		y >>= 8;
-	}
-	return --size;
-}
-
-static inline int match_ipv4(struct ckrm_net_struct *ns, char **string)
-{
-	char *ptr = *string;
-	int size;
-	char a4[16];
-
-	size = v4toa(ns->ns_daddrv4, a4);
-
-	*string += size;
-	return !strncmp(a4, ptr, size);
-}
-
-static inline int match_port(struct ckrm_net_struct *ns, char *ptr)
-{
-	char a[5];
-	int size = itoa(ns->ns_dport, a);
-
-	return !strncmp(a, ptr, size);
-}
-
-static int __evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
-			   struct rbce_rule *rule, bitvector_t * vec_eval,
-			   bitvector_t * vec_true, char **filename);
-/*
- * evaluate the given task against the given rule with the vec_eval and
- * vec_true in context. Return 1 if the task satisfies the given rule, 0
- * otherwise.
- *
- * If the bit corresponding to the rule is set in the vec_eval, then the
- * corresponding bit in vec_true is the result. If it is not set, evaluate
- * the rule and set the bits in both the vectors accordingly.
- *
- * On return, filename will have the pointer to the pathname of the task's
- * executable, if the rule had any command related terms.
- *
- * Caller must hold the rbce_rwlock atleast in read mode.
- */
-static inline int
-evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
-	      struct rbce_rule *rule, bitvector_t * vec_eval,
-	      bitvector_t * vec_true, char **filename)
-{
-	int tidx = rule->index;
-
-	if (!bitvector_test(tidx, vec_eval)) {
-		if (__evaluate_rule
-		    (tsk, ns, rule, vec_eval, vec_true, filename)) {
-			bitvector_set(tidx, vec_true);
-		}
-		bitvector_set(tidx, vec_eval);
-	}
-	return bitvector_test(tidx, vec_true);
-}
-
-/*
- * evaluate the given task against every term in the given rule with
- * vec_eval and vec_true in context.
- *
- * If the bit corresponding to a rule term is set in the vec_eval, then the
- * corresponding bit in vec_true is the result for taht particular. If it is
- * not set, evaluate the rule term and set the bits in both the vectors
- * accordingly.
- *
- * This fucntions returns true only if all terms in the rule evaluate true.
- *
- * On return, filename will have the pointer to the pathname of the task's
- * executable, if the rule had any command related terms.
- *
- * Caller must hold the rbce_rwlock atleast in read mode.
- */
-static int
-__evaluate_rule(struct task_struct *tsk, struct ckrm_net_struct *ns,
-		struct rbce_rule *rule, bitvector_t * vec_eval,
-		bitvector_t * vec_true, char **filename)
-{
-	int i;
-	int no_ip = 1;
-
-	for (i = rule->num_terms; --i >= 0;) {
-		int rc = 1, tidx = rule->terms[i];
-
-		if (!bitvector_test(tidx, vec_eval)) {
-			struct rbce_rule_term *term = &gl_terms[tidx];
-
-			switch (term->op) {
-
-			case RBCE_RULE_CMD_PATH:
-			case RBCE_RULE_CMD:
-#if __NOT_YET__
-				if (!*filename) {	/* get this once */
-					if (((*filename =
-					      kmalloc(NAME_MAX,
-						      GFP_ATOMIC)) == NULL)
-					    ||
-					    (get_exe_path_name
-					     (tsk, *filename, NAME_MAX) < 0)) {
-						rc = 0;
-						break;
-					}
-				}
-				rc = match_cmd(*filename, term->u.string,
-					       (term->op ==
-						RBCE_RULE_CMD_PATH));
-#else
-				rc = match_cmd(tsk->comm, term->u.string,
-					       (term->op ==
-						RBCE_RULE_CMD_PATH));
-#endif
-				break;
-			case RBCE_RULE_REAL_UID:
-				if (term->operator == RBCE_LESS_THAN) {
-					rc = (tsk->uid < term->u.id);
-				} else if (term->operator == RBCE_GREATER_THAN){
-					rc = (tsk->uid > term->u.id);
-				} else if (term->operator == RBCE_NOT) {
-					rc = (tsk->uid != term->u.id);
-				} else {
-					rc = (tsk->uid == term->u.id);
-				}
-				break;
-			case RBCE_RULE_REAL_GID:
-				if (term->operator == RBCE_LESS_THAN) {
-					rc = (tsk->gid < term->u.id);
-				} else if (term->operator == RBCE_GREATER_THAN){
-					rc = (tsk->gid > term->u.id);
-				} else if (term->operator == RBCE_NOT) {
-					rc = (tsk->gid != term->u.id);
-				} else {
-					rc = (tsk->gid == term->u.id);
-				}
-				break;
-			case RBCE_RULE_EFFECTIVE_UID:
-				if (term->operator == RBCE_LESS_THAN) {
-					rc = (tsk->euid < term->u.id);
-				} else if (term->operator == RBCE_GREATER_THAN){
-					rc = (tsk->euid > term->u.id);
-				} else if (term->operator == RBCE_NOT) {
-					rc = (tsk->euid != term->u.id);
-				} else {
-					rc = (tsk->euid == term->u.id);
-				}
-				break;
-			case RBCE_RULE_EFFECTIVE_GID:
-				if (term->operator == RBCE_LESS_THAN) {
-					rc = (tsk->egid < term->u.id);
-				} else if (term->operator == RBCE_GREATER_THAN){
-					rc = (tsk->egid > term->u.id);
-				} else if (term->operator == RBCE_NOT) {
-					rc = (tsk->egid != term->u.id);
-				} else {
-					rc = (tsk->egid == term->u.id);
-				}
-				break;
-			case RBCE_RULE_APP_TAG:
-				rc = (RBCE_DATA(tsk)
-				      && RBCE_DATA(tsk)->
-				      app_tag) ? !strcmp(RBCE_DATA(tsk)->
-							 app_tag,
-							 term->u.string) : 0;
-				break;
-			case RBCE_RULE_DEP_RULE:
-				rc = evaluate_rule(tsk, NULL, term->u.deprule,
-						   vec_eval, vec_true,
-						   filename);
-				break;
-
-			case RBCE_RULE_IPV4:
-				/* TBD: add NOT_EQUAL match. At present */
-				/* rbce recognises EQUAL matches only.  */
-				if (ns && term->operator == RBCE_EQUAL) {
-					int ma = 0;
-					int mp = 0;
-					char *ptr = term->u.string;
-
-					if (term->u.string[0] == '*')
-						ma = 1;
-					else
-						ma = match_ipv4(ns, &ptr);
-
-					if (*ptr != '\\') {
-						rc = 0;
-						break;
-					} else {
-						++ptr;
-						if (*ptr == '*')
-							mp = 1;
-						else
-							mp = match_port(ns,
-									ptr);
-					}
-					rc = mp && ma;
-				} else
-					rc = 0;
-				no_ip = 0;
-				break;
-
-			case RBCE_RULE_IPV6:	/* no support yet */
-				rc = 0;
-				no_ip = 0;
-				break;
-
-			default:
-				rc = 0;
-				printk(KERN_ERR "Error evaluate term op=%d\n",
-				       term->op);
-				break;
-			}
-			if (!rc && no_ip) {
-				bitvector_clear(tidx, vec_true);
-			} else {
-				bitvector_set(tidx, vec_true);
-			}
-			bitvector_set(tidx, vec_eval);
-		} else {
-			rc = bitvector_test(tidx, vec_true);
-		}
-		if (!rc) {
-			return 0;
-		}
-	}
-	return 1;
-}
-
-/*
- * This is some old debug code which needs to be trimmed.
- */
-
-#define valid_pdata(pdata) (1)
-#define store_pdata(pdata)
-#define unstore_pdata(pdata)
-
-static inline void
-copy_ext_private_data(struct rbce_private_data *src,
-		      struct rbce_private_data *dst)
-{
-	if (src)
-		dst->ext_data = src->ext_data;
-	else
-		memset(&dst->ext_data, 0, sizeof(dst->ext_data));
-}
-
-struct rbce_private_data *create_private_data(struct rbce_private_data
-						     *src, int copy_sample)
-{
-	int vsize = 0, psize, bsize = 0;
-	struct rbce_private_data *pdata;
-
-	if (use_persistent_state) {
-		vsize = gl_allocated;
-		bsize = vsize / 8 + sizeof(bitvector_t);
-		psize = sizeof(struct rbce_private_data) + 2 * bsize;
-	} else {
-		psize = sizeof(struct rbce_private_data);
-	}
-
-	pdata = kmalloc(psize, GFP_ATOMIC);
-	if (pdata != NULL) {
-		if (use_persistent_state) {
-			pdata->bitmap_version = gl_bitmap_version;
-			pdata->eval = (bitvector_t *) & pdata->data[0];
-			pdata->true = (bitvector_t *) & pdata->data[bsize];
-			if (src && (src->bitmap_version == gl_bitmap_version)) {
-				memcpy(pdata->data, src->data, 2 * bsize);
-			} else {
-				bitvector_init(pdata->eval, vsize);
-				bitvector_init(pdata->true, vsize);
-			}
-		}
-		copy_ext_private_data(src, pdata);
-		pdata->evaluate = 1;
-		pdata->rules_version = src ? src->rules_version : 0;
-		pdata->app_tag = NULL;
-	}
-	store_pdata(pdata);
-	return pdata;
-}
-
-static inline void free_private_data(struct rbce_private_data *pdata)
-{
-	if (valid_pdata(pdata)) {
-		unstore_pdata(pdata);
-		kfree(pdata);
-	}
-}
-
-void free_all_private_data(void)
-{
-	struct task_struct *proc, *thread;
-
-	read_lock(&tasklist_lock);
-	do_each_thread(proc, thread) {
-		struct rbce_private_data *pdata;
-
-		pdata = RBCE_DATA(thread);
-		RBCE_DATAP(thread) = NULL;
-		free_private_data(pdata);
-	} while_each_thread(proc, thread);
-	read_unlock(&tasklist_lock);
-	return;
-}
-
-/*
- * reclassify function, which is called by all the callback functions.
- *
- * Takes that task to be reclassified and ruleflags that indicates the
- * attributes that caused this reclassification request.
- *
- * On success, returns the core class pointer to which the given task should
- * belong to.
- */
-static struct ckrm_core_class *rbce_classify(struct task_struct *tsk,
-					     struct ckrm_net_struct *ns,
-					     unsigned long termflag,
-					     int classtype)
-{
-	int i;
-	struct rbce_rule *rule;
-	bitvector_t *vec_true = NULL, *vec_eval = NULL;
-	struct rbce_class *tgt = NULL;
-	struct ckrm_core_class *cls = NULL;
-	char *filename = NULL;
-
-	if (!valid_pdata(RBCE_DATA(tsk))) {
-		return NULL;
-	}
-	if (classtype >= CKRM_MAX_CLASSTYPES) {
-		/* can't handle more than CKRM_MAX_CLASSTYPES */
-		return NULL;
-	}
-	/* fast path to avoid locking in case CE is not enabled or */
-	/* if no rules are defined or if no evaluation is needed.  */
-	if (!rbce_enabled || !gl_num_rules ||
-	    (RBCE_DATA(tsk) && !RBCE_DATA(tsk)->evaluate)) {
-		return NULL;
-	}
-	/* FIXME: optimize_policy should be called from here if      */
-	/* gl_action is non-zero. Also, it has to be called with the */
-	/* rbce_rwlock held in write mode.                           */
-
-	read_lock(&rbce_rwlock);
-
-	vec_eval = vec_true = NULL;
-	if (use_persistent_state) {
-		struct rbce_private_data *pdata = RBCE_DATA(tsk);
-
-		if (!pdata
-		    || (pdata
-			&& (gl_bitmap_version != pdata->bitmap_version))) {
-			struct rbce_private_data *new_pdata =
-			    create_private_data(pdata, 1);
-
-			if (new_pdata) {
-				if (pdata) {
-					new_pdata->rules_version =
-					    pdata->rules_version;
-					new_pdata->evaluate = pdata->evaluate;
-					new_pdata->app_tag = pdata->app_tag;
-					free_private_data(pdata);
-				}
-				pdata = RBCE_DATAP(tsk) = new_pdata;
-				termflag = RBCE_TERMFLAG_ALL;
-				/* need to evaluate them all */
-			} else {
-				/*
-				 * we shouldn't free the pdata as it has more
-				 * details than the vectors. But, this
-				 * reclassification should go thru
-				 */
-				pdata = NULL;
-			}
-		}
-		if (!pdata) {
-			goto cls_determined;
-		}
-		vec_eval = pdata->eval;
-		vec_true = pdata->true;
-	} else {
-		int bsize = gl_allocated;
-
-		vec_eval = bitvector_alloc(bsize);
-		vec_true = bitvector_alloc(bsize);
-
-		if (vec_eval == NULL || vec_true == NULL) {
-			goto cls_determined;
-		}
-		termflag = RBCE_TERMFLAG_ALL;
-		/* need to evaluate all of them now */
-	}
-
-	/*
-	 * using bit ops invalidate all terms related to this termflag
-	 * context (only in per task vec)
-	 */
-
-	if (termflag == RBCE_TERMFLAG_ALL) {
-		bitvector_zero(vec_eval);
-	} else {
-		for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
-			if (test_bit(i, &termflag)) {
-				bitvector_t *maskvec = get_gl_mask_vecs(i);
-
-				bitvector_and_not(vec_eval, vec_eval, maskvec);
-			}
-		}
-	}
-	bitvector_and(vec_true, vec_true, vec_eval);
-
-	/* run through the rules in order and see what needs evaluation */
-	list_for_each_entry(rule, &rules_list[classtype], obj.link) {
-		if (rule->state == RBCE_RULE_ENABLED &&
-		    rule->target_class &&
-		    rule->target_class->classobj &&
-		    evaluate_rule(tsk, ns, rule, vec_eval, vec_true,
-				  &filename)) {
-			tgt = rule->target_class;
-			cls = rule->target_class->classobj;
-			break;
-		}
-	}
-
-      cls_determined:
-	if (!use_persistent_state) {
-		if (vec_eval) {
-			bitvector_free(vec_eval);
-		}
-		if (vec_true) {
-			bitvector_free(vec_true);
-		}
-	}
-	ckrm_core_grab(cls);
-	read_unlock(&rbce_rwlock);
-	if (filename) {
-		kfree(filename);
-	}
-	if (RBCE_DATA(tsk)) {
-		RBCE_DATA(tsk)->rules_version = gl_rules_version;
-	}
-	return cls;
-}
-
-/*****************************************************************************
- *
- * Module specific utilization of core RBCE functionality
- *
- * Includes support for the various classtypes
- * New classtypes will require extensions here
- *
- *****************************************************************************/
-
-/* helper functions that are required in the extended version */
-
-void rbce_tc_manual(struct task_struct *tsk)
-{
-	read_lock(&rbce_rwlock);
-
-	if (!RBCE_DATA(tsk)) {
-		RBCE_DATAP(tsk) =
-		    (void *)create_private_data(RBCE_DATA(tsk->parent), 0);
-	}
-	if (RBCE_DATA(tsk)) {
-		RBCE_DATA(tsk)->evaluate = 0;
-	}
-	read_unlock(&rbce_rwlock);
-	return;
-}
-
-/*****************************************************************************
- *    VARIOUS CLASSTYPES
- *****************************************************************************/
-
-/* to enable type coercion of the function pointers */
-
-/*============================================================================
- *    TASKCLASS CLASSTYPE
- *============================================================================*/
-
-int tc_classtype = -1;
-
-/*
- * fork callback to be registered with core module.
- */
-static inline void *rbce_tc_forkcb(struct task_struct *tsk)
-{
-	int rule_version_changed = 1;
-	struct ckrm_core_class *cls;
-	read_lock(&rbce_rwlock);
-	/* dup ce_data */
-	RBCE_DATAP(tsk) =
-	    (void *)create_private_data(RBCE_DATA(tsk->parent), 0);
-	read_unlock(&rbce_rwlock);
-
-	if (RBCE_DATA(tsk->parent)) {
-		rule_version_changed =
-		    (RBCE_DATA(tsk->parent)->rules_version != gl_rules_version);
-	}
-	cls = rule_version_changed ?
-	    rbce_classify(tsk, NULL, RBCE_TERMFLAG_ALL, tc_classtype) : NULL;
-
-	/*
-	 * note the fork notification to any user client will be sent through
-	 * the guaranteed fork-reclassification
-	 */
-	return cls;
-}
-
-/*
- * exit callback to be registered with core module.
- */
-static void rbce_tc_exitcb(struct task_struct *tsk)
-{
-	struct rbce_private_data *pdata;
-
-	send_exit_notification(tsk);
-	pdata = RBCE_DATA(tsk);
-	RBCE_DATAP(tsk) = NULL;
-	if (pdata) {
-		if (pdata->app_tag) {
-			kfree(pdata->app_tag);
-		}
-		free_private_data(pdata);
-	}
-	return;
-}
-
-static void *rbce_tc_classify(enum ckrm_event event, ...)
-{
-	va_list args;
-	void *cls = NULL;
-	struct task_struct *tsk;
-	struct rbce_private_data *pdata;
-
-	va_start(args, event);
-	tsk = va_arg(args, struct task_struct *);
-	va_end(args);
-
-	/* we only have to deal with events between
-	 * [ CKRM_LATCHABLE_EVENTS .. CKRM_NONLATCHABLE_EVENTS )
-	 */
-	switch (event) {
-
-	case CKRM_EVENT_FORK:
-		cls = rbce_tc_forkcb(tsk);
-		break;
-
-	case CKRM_EVENT_EXIT:
-		rbce_tc_exitcb(tsk);
-		break;
-
-	case CKRM_EVENT_EXEC:
-		cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_CMD |
-				    RBCE_TERMFLAG_UID | RBCE_TERMFLAG_GID,
-				    tc_classtype);
-		break;
-
-	case CKRM_EVENT_UID:
-		cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_UID, tc_classtype);
-		break;
-
-	case CKRM_EVENT_GID:
-		cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_GID, tc_classtype);
-		break;
-
-	case CKRM_EVENT_LOGIN:
-	case CKRM_EVENT_USERADD:
-	case CKRM_EVENT_USERDEL:
-	case CKRM_EVENT_LISTEN_START:
-	case CKRM_EVENT_LISTEN_STOP:
-	case CKRM_EVENT_APPTAG:
-		/* no interest in this events .. */
-		break;
-
-	default:
-		/* catch all */
-		break;
-
-	case CKRM_EVENT_RECLASSIFY:
-		if ((pdata = (RBCE_DATA(tsk)))) {
-			pdata->evaluate = 1;
-		}
-		cls = rbce_classify(tsk, NULL, RBCE_TERMFLAG_ALL, tc_classtype);
-		break;
-
-	}
-
-	return cls;
-}
-
-#ifndef CRBCE_EXTENSION
-static void rbce_tc_notify(int event, void *core, struct task_struct *tsk)
-{
-	if (event != CKRM_EVENT_MANUAL)
-		return;
-	rbce_tc_manual(tsk);
-}
-#endif
-
-static struct ckrm_eng_callback rbce_taskclass_ecbs = {
-	.c_interest = (unsigned long)(-1),	/* set whole bitmap */
-	.classify = (ce_classify_fct) rbce_tc_classify,
-	.class_delete = rbce_class_deletecb,
-	.class_add = rbce_class_addcb,
-#ifndef CRBCE_EXTENSION
-	.n_interest = (1 << CKRM_EVENT_MANUAL),
-	.notify = (ce_notify_fct) rbce_tc_notify,
-	.always_callback = 0,
-#else
-	.n_interest = (unsigned long)(-1),      /* set whole bitmap */
-	.notify = (ce_notify_fct) rbce_tc_ext_notify,
-	.always_callback = 1,
-#endif
-};
-
-/*============================================================================
- *    ACCEPTQ CLASSTYPE
- *============================================================================*/
-
-int sc_classtype = -1;
-
-static void *rbce_sc_classify(enum ckrm_event event, ...)
-{
-	/* no special consideratation */
-	void *result;
-	va_list args;
-	struct task_struct *tsk;
-	struct ckrm_net_struct *ns;
-
-	va_start(args, event);
-	ns = va_arg(args, struct ckrm_net_struct *);
-	tsk = va_arg(args, struct task_struct *);
-	va_end(args);
-
-	result = rbce_classify(tsk, ns, RBCE_TERMFLAG_ALL, sc_classtype);
-
-	return result;
-}
-
-static struct ckrm_eng_callback rbce_acceptQclass_ecbs = {
-	.c_interest = (unsigned long)(-1),
-	.always_callback = 0,	/* enable during debugging only */
-	.classify = (ce_classify_fct) & rbce_sc_classify,
-	.class_delete = rbce_class_deletecb,
-};
-
-/*============================================================================
- *    Module Initialization ...
- *============================================================================*/
-
-#define TASKCLASS_NAME  "taskclass"
-#define SOCKCLASS_NAME  "socket_class"
-
-struct ce_regtable_struct {
-	const char *name;
-	struct ckrm_eng_callback *cbs;
-	int *clsvar;
-};
-
-struct ce_regtable_struct ce_regtable[] = {
-	{TASKCLASS_NAME, &rbce_taskclass_ecbs, &tc_classtype},
-	{SOCKCLASS_NAME, &rbce_acceptQclass_ecbs, &sc_classtype},
-	{NULL}
-};
-
-void unregister_classtype_engines(void)
-{
-	int rc;
-	struct ce_regtable_struct *ceptr = ce_regtable;
-
-	while (ceptr->name) {
-		if (*ceptr->clsvar >= 0) {
-			while ((rc = ckrm_unregister_engine(ceptr->name)) == -EAGAIN)
-				;
-			*ceptr->clsvar = -1;
-		}
-		ceptr++;
-	}
-}
-
-int register_classtype_engines(void)
-{
-	int rc;
-	struct ce_regtable_struct *ceptr = ce_regtable;
-
-	while (ceptr->name) {
-		rc = ckrm_register_engine(ceptr->name, ceptr->cbs);
-		if ((rc < 0) && (rc != -ENOENT)) {
-			unregister_classtype_engines();
-			return (rc);
-		}
-		if (rc != -ENOENT)
-			*ceptr->clsvar = rc;
-		ceptr++;
-	}
-	return 0;
-}
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_fs.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_fs.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * RCFS API for Rule-based Classification Engine (RBCE)
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *           (C) Vivek Kashyap, IBM Corp. 2004
- *
- * Module for loading of classification policies and providing
- * a user API for Class-based Kernel Resource Management (CKRM)
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#include <linux/pagemap.h>
-#include <linux/rcfs.h>
-#include "rbce_internal.h"
-
-#define CONFIG_CE_DIR		"ce"
-#define CONFIG_RULES_DIR	"rules"
-#define CONFIG_RBCE_STATE	"rbce_state"
-#define CONFIG_RBCE_TAG		"rbce_tag"
-
-static int rbce_unlink(struct inode *, struct dentry *);
-
-static ssize_t
-rbce_write(struct file *file, const char __user * buf,
-	   size_t len, loff_t * ppos)
-{
-	char *line, *ptr;
-	int rc = 0, pid;
-
-	line = kmalloc(len + 1, GFP_KERNEL);
-	if (!line) {
-		return -ENOMEM;
-	}
-	if (copy_from_user(line, buf, len)) {
-		kfree(line);
-		return -EFAULT;
-	}
-	line[len] = '\0';
-	ptr = line;
-	while (*ptr) {
-		if (*ptr == '\n') {
-			*ptr = '\0';
-			break;
-		}
-		ptr++;
-	}
-	if (!strcmp(file->f_dentry->d_name.name, CONFIG_RBCE_TAG)) {
-		pid = simple_strtol(line, &ptr, 0);
-		rc = rbce_set_tasktag(pid, ptr + 1); /* syntax "pid tag" */
-	} else if (!strcmp(file->f_dentry->d_name.name, CONFIG_RBCE_STATE))
-		rbce_enabled = line[0] - '0';
-	else
-		rc = rbce_change_rule(file->f_dentry->d_name.name, line);
-	if (rc)
-		len = rc;
-	kfree(line);
-	return len;
-}
-
-static int rbce_show(struct seq_file *seq, void *offset)
-{
-	struct file *file = (struct file *)seq->private;
-	char result[256];
-
-	memset(result, 0, 256);
-	if (!strcmp(file->f_dentry->d_name.name, CONFIG_RBCE_TAG))
-		return -EPERM;
-	if (!strcmp(file->f_dentry->d_name.name, CONFIG_RBCE_STATE))
-		seq_printf(seq, "%d\n", rbce_enabled);
-	else {
-		rbce_get_rule(file->f_dentry->d_name.name, result);
-		seq_printf(seq, "%s\n", result);
-	}
-	return 0;
-}
-
-static int rbce_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, rbce_show, file);
-}
-
-static int rbce_close(struct inode *ino, struct file *file)
-{
-	const char *name = file->f_dentry->d_name.name;
-
-	if (strcmp(name, CONFIG_RBCE_STATE) &&
-			strcmp(name, CONFIG_RBCE_TAG) &&
-			!rbce_rule_exists(name))
-		rbce_unlink(file->f_dentry->d_parent->d_inode, file->f_dentry);
-	return single_release(ino, file);
-}
-
-static struct file_operations rbce_file_operations;
-static struct inode_operations rbce_file_inode_operations;
-static struct inode_operations rbce_dir_inode_operations;
-
-static struct inode *rbce_get_inode(struct inode *dir, int mode, dev_t dev)
-{
-	struct inode *inode = new_inode(dir->i_sb);
-
-	if (inode) {
-		inode->i_mode = mode;
-		inode->i_uid = current->fsuid;
-		inode->i_gid = current->fsgid;
-		inode->i_blksize = PAGE_CACHE_SIZE;
-		inode->i_blocks = 0;
-		inode->i_mapping->a_ops = dir->i_mapping->a_ops;
-		inode->i_mapping->backing_dev_info =
-		    dir->i_mapping->backing_dev_info;
-		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-		switch (mode & S_IFMT) {
-		default:
-			init_special_inode(inode, mode, dev);
-			break;
-		case S_IFREG:
-			/* Treat as default assignment */
-			inode->i_op = &rbce_file_inode_operations;
-			inode->i_fop = &rbce_file_operations;
-			break;
-		case S_IFDIR:
-			inode->i_op = &rbce_dir_inode_operations;
-			inode->i_fop = &simple_dir_operations;
-
-			/* directory inodes start off with i_nlink == 2
-			   (for "." entry) */
-			inode->i_nlink++;
-			break;
-		}
-	}
-	return inode;
-}
-
-/*
- * File creation. Allocate an inode, and we're done..
- */
-static int
-rbce_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
-{
-	struct inode *inode = rbce_get_inode(dir, mode, dev);
-	int error = -ENOSPC;
-
-	if (inode) {
-		if (dir->i_mode & S_ISGID) {
-			inode->i_gid = dir->i_gid;
-			if (S_ISDIR(mode))
-				inode->i_mode |= S_ISGID;
-		}
-		d_instantiate(dentry, inode);
-		dget(dentry);	/* Extra count - pin the dentry in core */
-		error = 0;
-
-	}
-	return error;
-}
-
-static int rbce_unlink(struct inode *dir, struct dentry *dentry)
-{
-	struct inode *inode = dentry->d_inode;
-	int rc;
-
-	rc = rbce_delete_rule(dentry->d_name.name);
-	if (rc == 0) {
-		if (dir)
-			dir->i_ctime = dir->i_mtime = CURRENT_TIME;
-		inode->i_ctime = CURRENT_TIME;
-		inode->i_nlink--;
-		dput(dentry);
-	}
-	return rc;
-}
-
-static int
-rbce_rename(struct inode *old_dir, struct dentry *old_dentry,
-	    struct inode *new_dir, struct dentry *new_dentry)
-{
-	int rc;
-	struct inode *inode = old_dentry->d_inode;
-	struct dentry *old_d = list_entry(old_dir->i_dentry.next,
-					  struct dentry, d_alias);
-	struct dentry *new_d = list_entry(new_dir->i_dentry.next,
-					  struct dentry, d_alias);
-
-	/* Do not allow renaming any directory */
-	if (S_ISDIR(old_dentry->d_inode->i_mode))
-		return -EINVAL;
-
-	/* Do not allow renaming files just under under /ce */
-	if (!strcmp(old_d->d_name.name, CONFIG_CE_DIR))
-		return -EINVAL;
-
-	/* cannot move anything to /ce */
-	if (!strcmp(new_d->d_name.name, CONFIG_CE_DIR))
-		return -EINVAL;
-
-	rc = rbce_rename_rule(old_dentry->d_name.name, new_dentry->d_name.name);
-
-	if (!rc)
-		old_dir->i_ctime = old_dir->i_mtime = new_dir->i_ctime =
-		    new_dir->i_mtime = inode->i_ctime = CURRENT_TIME;
-	return rc;
-}
-
-/* CE allows only the rules directory to be created */
-int rbce_mkdir(struct inode *dir, struct dentry *dentry, int mode)
-{
-	int retval = -EINVAL;
-
-	struct dentry *pd =
-	    list_entry(dir->i_dentry.next, struct dentry, d_alias);
-
-	/* Allow only /rcfs/ce and ce/rules */
-	if ((!strcmp(pd->d_name.name, CONFIG_CE_DIR) &&
-			!strcmp(dentry->d_name.name, CONFIG_RULES_DIR)) ||
-			(!strcmp(pd->d_name.name, "/") &&
-			!strcmp(dentry->d_name.name, CONFIG_CE_DIR))) {
-		if (!strcmp(dentry->d_name.name, CONFIG_CE_DIR))
-			try_module_get(THIS_MODULE);
-		retval = rbce_mknod(dir, dentry, mode | S_IFDIR, 0);
-		if (!retval)
-			dir->i_nlink++;
-	}
-
-	return retval;
-}
-
-/* CE doesn't allow deletion of directory */
-int rbce_rmdir(struct inode *dir, struct dentry *dentry)
-{
-	int rc;
-	rc = simple_rmdir(dir, dentry);
-
-	if (!rc && !strcmp(dentry->d_name.name, CONFIG_CE_DIR))
-		module_put(THIS_MODULE);
-	return rc;
-}
-
-static int
-rbce_create(struct inode *dir, struct dentry *dentry,
-	    int mode, struct nameidata *nd)
-{
-	struct dentry *pd =
-	    list_entry(dir->i_dentry.next, struct dentry, d_alias);
-
-	/* No creation allowed under ce */
-	if (!strcmp(pd->d_name.name, CONFIG_CE_DIR))
-		return -EINVAL;
-
-	return rbce_mknod(dir, dentry, mode | S_IFREG, 0);
-}
-
-static int rbce_link(struct dentry *old_d, struct inode *dir, struct dentry *d)
-{
-	return -EINVAL;
-}
-
-static int
-rbce_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
-{
-	return -EINVAL;
-}
-
-/******************************* Config files  ********************/
-
-struct rcfs_magf rbce_config_files[] = {
-	{
-	 .name = CONFIG_CE_DIR,
-	 .mode = RCFS_DEFAULT_DIR_MODE,
-	 .i_op = &rbce_dir_inode_operations,
-	 },
-	{
-	 .name = CONFIG_RBCE_TAG,
-	 .mode = RCFS_DEFAULT_FILE_MODE,
-	 .i_fop = &rbce_file_operations,
-	 },
-	{
-	 .name = CONFIG_RBCE_STATE,
-	 .mode = RCFS_DEFAULT_FILE_MODE,
-	 .i_fop = &rbce_file_operations,
-	 },
-	{
-	 .name = CONFIG_RULES_DIR,
-	 .mode = (RCFS_DEFAULT_DIR_MODE | S_IWUSR),
-	 .i_fop = &simple_dir_operations,
-	 .i_op = &rbce_dir_inode_operations,
-	 }
-};
-
-static struct dentry *ce_root_dentry;
-
-int rbce_create_config(void)
-{
-	int rc, nr;
-
-	nr = sizeof(rbce_config_files) / sizeof(struct rcfs_magf);
-	/* Make root dentry */
-	rc = rcfs_mkroot(rbce_config_files, nr, &ce_root_dentry);
-	if ((!ce_root_dentry) || rc)
-		return rc;
-
-	/* Create config files */
-	if ((rc = rcfs_create_magic(ce_root_dentry, &rbce_config_files[1],
-				    nr - 1))) {
-		printk(KERN_ERR "Failed to create c/rbce config files."
-		       " Deleting c/rbce root\n");
-		rcfs_rmroot(ce_root_dentry);
-		return rc;
-	}
-
-	return rc;
-}
-
-int rbce_clear_config(void)
-{
-	int rc = 0;
-	if (ce_root_dentry)
-		rc = rcfs_rmroot(ce_root_dentry);
-	return rc;
-}
-
-/******************************* File ops ********************/
-
-static struct file_operations rbce_file_operations = {
-	.owner = THIS_MODULE,
-	.open = rbce_open,
-	.llseek = seq_lseek,
-	.read = seq_read,
-	.write = rbce_write,
-	.release = rbce_close,
-};
-
-static struct inode_operations rbce_file_inode_operations = {
-	.getattr = simple_getattr,
-};
-
-static struct inode_operations rbce_dir_inode_operations = {
-	.create = rbce_create,
-	.lookup = simple_lookup,
-	.link = rbce_link,
-	.unlink = rbce_unlink,
-	.symlink = rbce_symlink,
-	.mkdir = rbce_mkdir,
-	.rmdir = rbce_rmdir,
-	.mknod = rbce_mknod,
-	.rename = rbce_rename,
-	.getattr = simple_getattr,
-};
-
-struct rbce_eng_callback rbce_rcfs_ecbs = {
-	rbce_mkdir,
-	rbce_rmdir,
-	rbce_create_config,
-	rbce_clear_config
-};
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_internal.h
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_internal.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * rbce internal header file.
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *           (C) Vivek Kashyap, IBM Corp. 2004
- *
- * Module for loading of classification policies and providing
- * a user API for Class-based Kernel Resource Management (CKRM)
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-#ifndef _RBCE_INTERNAL_H
-#define _RBCE_INTERNAL_H
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/mount.h>
-#include <linux/proc_fs.h>
-#include <linux/limits.h>
-#include <linux/pid.h>
-#include <linux/sysctl.h>
-
-#include <linux/ckrm_rc.h>
-#include <linux/ckrm_ce.h>
-#include <linux/ckrm_net.h>
-#include <linux/rbce.h>
-
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-#include "rbce_bitvector.h"
-
-/*
- * comman data structure used for identification of class and rules
- * in the RBCE namespace
- */
-struct named_obj_hdr {
-	struct list_head link;
-	int referenced;
-	char *name;
-};
-
-#include "rbce_bitvector.h"
-
-#define GET_REF(x) ((x)->obj.referenced)
-#define INC_REF(x) (GET_REF(x)++)
-#define DEC_REF(x) (--GET_REF(x))
-
-struct rbce_class {
-	struct named_obj_hdr obj;
-	int classtype;
-	void *classobj;
-};
-
-typedef int __bitwise rbce_rule_op_t;
-enum rbce_rule_op {
-	RBCE_RULE_CMD_PATH = (__force rbce_rule_op_t) 1,
-	RBCE_RULE_CMD = (__force rbce_rule_op_t) 2,
-	RBCE_RULE_ARGS = (__force rbce_rule_op_t) 3,
-	RBCE_RULE_REAL_UID = (__force rbce_rule_op_t) 4,
-	RBCE_RULE_REAL_GID = (__force rbce_rule_op_t) 5,
-	RBCE_RULE_EFFECTIVE_UID = (__force rbce_rule_op_t) 6,
-	RBCE_RULE_EFFECTIVE_GID = (__force rbce_rule_op_t) 7,
-	RBCE_RULE_APP_TAG = (__force rbce_rule_op_t) 8,
-	RBCE_RULE_IPV4 = (__force rbce_rule_op_t) 9,
-	RBCE_RULE_IPV6 = (__force rbce_rule_op_t) 10,
-	RBCE_RULE_DEP_RULE = (__force rbce_rule_op_t) 11,
-	RBCE_RULE_INVALID = (__force rbce_rule_op_t) 12,
-	RBCE_RULE_INVALID2 = (__force rbce_rule_op_t) 13,
-};
-
-typedef int __bitwise rbce_operator_t;
-enum rbce_operator {
-	RBCE_EQUAL = (__force rbce_operator_t) 1,
-	RBCE_NOT = (__force rbce_operator_t) 2,
-	RBCE_LESS_THAN = (__force rbce_operator_t) 3,
-	RBCE_GREATER_THAN = (__force rbce_operator_t) 4,
-};
-
-struct rbce_rule_term {
-	rbce_rule_op_t op;
-	rbce_operator_t operator;
-	union {
-		char *string;	/* path, cmd, arg, tag, ipv4 and ipv6 */
-		long id;	/* uid, gid, euid, egid */
-		struct rbce_rule *deprule;
-	} u;
-};
-
-struct rbce_rule {
-	struct named_obj_hdr obj;
-	struct rbce_class *target_class;
-	int classtype;
-	int num_terms;
-	int *terms;	/* vector of indices into the global term vector */
-	int index;	/* index of this rule into the global term vector */
-	int termflag;	/* which term ids would require a recalculation */
-	int do_opt;	/* do we have to consider this rule during optimize */
-	char *strtab;	/* string table to store the strings of all terms */
-	int order;	/* order of execution of this rule */
-	int state;	/* RBCE_RULE_ENABLED/RBCE_RULE_DISABLED */
-};
-
-/* rules states */
-#define RBCE_RULE_DISABLED 0
-#define RBCE_RULE_ENABLED  1
-
-/*
- * Data structures and macros used for optimization
- */
-#define RBCE_TERM_CMD   (0)
-#define RBCE_TERM_UID   (1)
-#define RBCE_TERM_GID   (2)
-#define RBCE_TERM_TAG   (3)
-#define RBCE_TERM_IPV4  (4)
-#define RBCE_TERM_IPV6  (5)
-
-#define NUM_TERM_MASK_VECTOR  (6)
-
-/* Rule flags. 1 bit for each type of rule term */
-#define RBCE_TERMFLAG_CMD   (1 << RBCE_TERM_CMD)
-#define RBCE_TERMFLAG_UID   (1 << RBCE_TERM_UID)
-#define RBCE_TERMFLAG_GID   (1 << RBCE_TERM_GID)
-#define RBCE_TERMFLAG_TAG   (1 << RBCE_TERM_TAG)
-#define RBCE_TERMFLAG_IPV4  (1 << RBCE_TERM_IPV4)
-#define RBCE_TERMFLAG_IPV6  (1 << RBCE_TERM_IPV6)
-#define RBCE_TERMFLAG_ALL      (RBCE_TERMFLAG_CMD | RBCE_TERMFLAG_UID |	\
-				RBCE_TERMFLAG_GID | RBCE_TERMFLAG_TAG |	\
-				RBCE_TERMFLAG_IPV4 | RBCE_TERMFLAG_IPV6)
-
-/* Token operation related data structures, functions etc., */
-typedef int __bitwise rule_token_t;
-enum rule_token {
-	TOKEN_PATH = (__force rule_token_t) 1,
-	TOKEN_CMD = (__force rule_token_t) 2,
-	TOKEN_ARGS = (__force rule_token_t) 3,
-	TOKEN_RUID_EQ = (__force rule_token_t) 4,
-	TOKEN_RUID_LT = (__force rule_token_t) 5,
-	TOKEN_RUID_GT = (__force rule_token_t) 6,
-	TOKEN_RUID_NOT = (__force rule_token_t) 7,
-	TOKEN_RGID_EQ = (__force rule_token_t) 8,
-	TOKEN_RGID_LT = (__force rule_token_t) 9,
-	TOKEN_RGID_GT = (__force rule_token_t) 10,
-	TOKEN_RGID_NOT = (__force rule_token_t) 11,
-	TOKEN_EUID_EQ = (__force rule_token_t) 12,
-	TOKEN_EUID_LT = (__force rule_token_t) 13,
-	TOKEN_EUID_GT = (__force rule_token_t) 14,
-	TOKEN_EUID_NOT = (__force rule_token_t) 15,
-	TOKEN_EGID_EQ = (__force rule_token_t) 16,
-	TOKEN_EGID_LT = (__force rule_token_t) 17,
-	TOKEN_EGID_GT = (__force rule_token_t) 18,
-	TOKEN_EGID_NOT = (__force rule_token_t) 19,
-	TOKEN_TAG = (__force rule_token_t) 20,
-	TOKEN_IPV4 = (__force rule_token_t) 21,
-	TOKEN_IPV6 = (__force rule_token_t) 22,
-	TOKEN_DEP = (__force rule_token_t) 23,
-	TOKEN_DEP_ADD = (__force rule_token_t) 24,
-	TOKEN_DEP_DEL = (__force rule_token_t) 25,
-	TOKEN_ORDER = (__force rule_token_t) 26,
-	TOKEN_CLASS = (__force rule_token_t) 27,
-	TOKEN_STATE = (__force rule_token_t) 28,
-	TOKEN_INVALID = (__force rule_token_t) 29
-};
-
-typedef int __bitwise op_token_t;
-enum op_token {
-	TOKEN_OP_EQUAL = (__force op_token_t) RBCE_EQUAL,
-	TOKEN_OP_NOT = (__force op_token_t) RBCE_NOT,
-	TOKEN_OP_LESS_THAN = (__force op_token_t) RBCE_LESS_THAN,
-	TOKEN_OP_GREATER_THAN = (__force op_token_t) RBCE_GREATER_THAN,
-	TOKEN_OP_DEP = (__force op_token_t) (TOKEN_OP_GREATER_THAN+1),
-	TOKEN_OP_DEP_ADD = (__force op_token_t) (TOKEN_OP_GREATER_THAN+2),
-	TOKEN_OP_DEP_DEL = (__force op_token_t) (TOKEN_OP_GREATER_THAN+3),
-	TOKEN_OP_ORDER = (__force op_token_t) (TOKEN_OP_GREATER_THAN+4),
-	TOKEN_OP_CLASS = (__force op_token_t) (TOKEN_OP_GREATER_THAN+5),
-	TOKEN_OP_STATE = (__force op_token_t) (TOKEN_OP_GREATER_THAN+6),
-};
-
-/*
- * data structure rbce_private_data holds the bit vector 'eval' which
- * specifies if rules and terms of rules are evaluated against the task
- * and if they were evaluated, bit vector 'true' holds the result of that
- * evaluation.
- *
- * This data structure is maintained in a task, and the bitvectors are
- * updated only when needed.
- *
- * Each rule and each term of a rule has a corresponding bit in the vector.
- *
- */
-struct rbce_private_data {
-	struct rbce_ext_private_data ext_data;
-  	int evaluate;		/* whether to evaluate rules or not ? */
-  	int rules_version;	/* rules_version at last evaluation */
-	bitvector_t *eval;
-	bitvector_t *true;
-	char *app_tag;
-	unsigned long bitmap_version;
-  	char data[0];		/* bitvectors eval and true */
-};
-
-#define RBCE_DATA(tsk) ((struct rbce_private_data*)((tsk)->ce_data))
-#define RBCE_DATAP(tsk) ((tsk)->ce_data)
-
-/* Other rbce global stuff. */
-
-extern struct rbce_eng_callback rbce_rcfs_ecbs;
-extern int rbce_enabled;
-extern struct list_head rules_list[];
-extern struct list_head class_list;
-extern const int use_persistent_state;
-extern int gl_num_rules;
-extern int gl_bitmap_version;
-extern int gl_allocated;
-extern struct rbce_rule_term *gl_terms;
-extern int gl_rules_version;
-extern rwlock_t rbce_rwlock;
-
-extern int rbce_mkdir(struct inode *, struct dentry *, int);
-extern int rbce_rmdir(struct inode *, struct dentry *);
-extern int rbce_create_config(void);
-extern int rbce_clear_config(void);
-
-extern void rbce_get_rule(const char *, char *);
-extern int rbce_rule_exists(const char *);
-extern int rbce_change_rule(const char *, char *);
-extern int rbce_delete_rule(const char *);
-extern int rbce_set_tasktag(int, char *);
-extern int rbce_rename_rule(const char *, const char *);
-
-extern int rules_parse(char *, struct rbce_rule_term **, int *);
-
-extern struct rbce_private_data *create_private_data(struct rbce_private_data
-						     *, int);
-extern bitvector_t *get_gl_mask_vecs(int);
-extern struct rbce_class *find_class_name(const char *);
-extern struct rbce_class *get_class(const char *classname, int *classtype);
-extern void put_class(struct rbce_class *);
-extern void free_all_private_data(void);
-
-extern void unregister_classtype_engines(void);
-extern int register_classtype_engines(void);
-
-extern struct rbce_class *create_rbce_class(const char *, int, void *);
-extern void rbce_tc_manual(struct task_struct *);
-extern void notify_class_action(struct rbce_class *, int);
-extern void send_exit_notification(struct task_struct *);
-extern void rbce_tc_ext_notify(int, void *, struct task_struct *);
-extern int init_rbce_ext_pre(void);
-extern int init_rbce_ext_post(void);
-extern void exit_rbce_ext(void);
-#endif /* _RBCE_INTERNAL_H */
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_main.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_main.c
+++ /dev/null
@@ -1,1279 +0,0 @@
-/*
- * Rule Functionality and module initialization and destrution
- * for Rule-based Classification Engine (RBCE)
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *           (C) Vivek Kashyap, IBM Corp. 2004
- *
- * Module for loading of classification policies and providing
- * a user API for Class-based Kernel Resource Management (CKRM)
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-
-#include "rbce_internal.h"
-
-MODULE_DESCRIPTION(RBCE_MOD_DESCR);
-MODULE_AUTHOR("Hubertus Franke, Chandra Seetharaman (IBM)");
-MODULE_LICENSE("GPL");
-
-static char modname[] = RBCE_MOD_NAME;
-
-/* ==================== global variables etc., ==================== */
-
-int termop_2_vecidx[RBCE_RULE_INVALID] = {
-	[RBCE_RULE_CMD_PATH] = RBCE_TERM_CMD,
-	[RBCE_RULE_CMD] = RBCE_TERM_CMD,
-	[RBCE_RULE_ARGS] = RBCE_TERM_CMD,
-	[RBCE_RULE_REAL_UID] = RBCE_TERM_UID,
-	[RBCE_RULE_REAL_GID] = RBCE_TERM_GID,
-	[RBCE_RULE_EFFECTIVE_UID] = RBCE_TERM_UID,
-	[RBCE_RULE_EFFECTIVE_GID] = RBCE_TERM_GID,
-	[RBCE_RULE_APP_TAG] = RBCE_TERM_TAG,
-	[RBCE_RULE_IPV4] = RBCE_TERM_IPV4,
-	[RBCE_RULE_IPV6] = RBCE_TERM_IPV6,
-	[RBCE_RULE_DEP_RULE] = -1
-};
-
-#define TERMOP_2_TERMFLAG(x)	(1 << termop_2_vecidx[x])
-#define TERM_2_TERMFLAG(x)		(1 << x)
-
-#define POLICY_INC_NUMTERMS	(BITS_PER_LONG)	/* No. of terms alloc'd once */
-#define POLICY_ACTION_NEW_VERSION	0x01	/* Force reallocation */
-#define POLICY_ACTION_REDO_ALL		0x02	/* Recompute all rule flags */
-#define POLICY_ACTION_PACK_TERMS	0x04	/* Time to pack the terms */
-
-extern int errno;
-
-LIST_HEAD(class_list);
-struct list_head rules_list[CKRM_MAX_CLASSTYPES];
-static int gl_action, gl_num_terms;
-static int gl_released;
-static bitvector_t *gl_mask_vecs[NUM_TERM_MASK_VECTOR];
-
-int rbce_enabled = 1;
-const int use_persistent_state = 1;
-int gl_num_rules;
-int gl_bitmap_version;
-int gl_allocated;
-struct rbce_rule_term *gl_terms;
-int gl_rules_version;
-rwlock_t rbce_rwlock = RW_LOCK_UNLOCKED;
-	/*
-	 * One lock to protect them all !!!
-	 * Additions, deletions to rules must
-	 * happen with this lock being held in write mode.
-	 * Access(read/write) to any of the data structures must happen
-	 * with this lock held in read mode.
-	 * Since, rule related changes do not happen very often it is ok to
-	 * have single rwlock.
-	 */
-
-/* ======================= Helper Functions ========================= */
-
-static void optimize_policy(void);
-
-bitvector_t *
-get_gl_mask_vecs(int index)
-{
-	return gl_mask_vecs[index];
-}
-
-static inline struct rbce_rule *find_rule_name(const char *name)
-{
-	struct named_obj_hdr *pos;
-	int i;
-
-	for (i = 0; i < CKRM_MAX_CLASSTYPES; i++)
-		list_for_each_entry(pos, &rules_list[i], link)
-			if (!strcmp(pos->name, name))
-				return ((struct rbce_rule *)pos);
-	return NULL;
-}
-
-struct rbce_class *find_class_name(const char *name)
-{
-	struct named_obj_hdr *pos;
-
-	list_for_each_entry(pos, &class_list, link)
-		if (!strcmp(pos->name, name))
-			return (struct rbce_class *)pos;
-	return NULL;
-}
-
-/* Type of Rule insertion */
-#define INSERT		0	/* new rule */
-#define REINSERT	1	/* existing rule */
-
-/*
- * Insert the given rule at the specified order
- * 		order = -1 ==> insert at the tail.
- *		type == INSERT - insert the rule
- *		type == REINSERT - remove the rule from its current
- *				 position and reinsert accoring to order.
- *
- * Caller must hold rbce_rwlock in write mode.
- */
-static int insert_rule(struct rbce_rule *rule, int order, int type)
-{
-#define ORDER_COUNTER_INCR 10
-	static int order_counter;
-	int old_counter;
-	struct list_head *head = &rules_list[rule->classtype];
-	struct list_head *insert = head;
-	struct rbce_rule *tmp;
-
-	if (gl_num_rules == 0)
-		order_counter = 0;
-
-	switch (order) {
-	case -1:
-		rule->order = order_counter;
-		/* FIXME: order_counter overflow/wraparound!! */
-		order_counter += ORDER_COUNTER_INCR;
-		break;
-	default:
-		old_counter = order_counter;
-		if (order_counter < order)
-			order_counter = order;
-		rule->order = order;
-		order_counter += ORDER_COUNTER_INCR;
-		list_for_each_entry(tmp, head, obj.link) {
-			if (rule == tmp)
-				continue;
-			if (rule->order == tmp->order) {
-				order_counter = old_counter;
-				return -EEXIST;
-			}
-			if (rule->order < tmp->order) {
-				insert = &tmp->obj.link;
-				break;
-			}
-		}
-	}
-	if ((type == REINSERT) && !list_empty(&rule->obj.link))
-		list_del_init(&rule->obj.link);
-	else {
-		/*  protect the module from removed if a rule exists */
-		try_module_get(THIS_MODULE);
-		gl_num_rules++;
-	}
-	gl_rules_version++;
-	list_add_tail(&rule->obj.link, insert);
-	if (rbce_enabled)
-		optimize_policy();
-	return 0;
-}
-
-/*
- * Get a refernece to the class, create one if it doesn't exist
- *
- * Caller need to hold rbce_rwlock in write mode.
- */
-
-struct rbce_class *create_rbce_class(const char *classname,
-					    int classtype, void *classobj)
-{
-	struct rbce_class *cls;
-
-	if (classtype >= CKRM_MAX_CLASSTYPES) {
-		printk(KERN_ERR
-		       "ckrm_classobj returned %d as classtype which cannot "
-		       " be handled by RBCE\n", classtype);
-		return NULL;
-	}
-
-	cls = kmalloc(sizeof(struct rbce_class), GFP_ATOMIC);
-	if (!cls)
-		return NULL;
-	cls->obj.name = kmalloc(strlen(classname) + 1, GFP_ATOMIC);
-	if (cls->obj.name) {
-		GET_REF(cls) = 1;
-		cls->classobj = classobj;
-		strcpy(cls->obj.name, classname);
-		list_add_tail(&cls->obj.link, &class_list);
-		cls->classtype = classtype;
-	} else {
-		kfree(cls);
-		cls = NULL;
-	}
-	return cls;
-}
-
-struct rbce_class *get_class(const char *classname, int *classtype)
-{
-	struct rbce_class *cls;
-	void *classobj;
-
-	if (!classname)
-		return NULL;
-	cls = find_class_name(classname);
-	if (cls) {
-		if (cls->classobj) {
-			INC_REF(cls);
-			*classtype = cls->classtype;
-			return cls;
-		}
-		return NULL;
-	}
-	classobj = ckrm_classobj(classname, classtype);
-	if (!classobj)
-		return NULL;
-	return create_rbce_class(classname, *classtype, classobj);
-}
-
-/*
- * Drop a refernece to the class, create one if it doesn't exist
- *
- * Caller need to hold rbce_rwlock in write mode.
- */
-void put_class(struct rbce_class *cls)
-{
-	if (cls && (DEC_REF(cls) <= 0)) {
-		list_del(&cls->obj.link);
-		kfree(cls->obj.name);
-		kfree(cls);
-	}
-	return;
-}
-
-/*
- * Allocate an index in the global term vector
- * On success, returns the index. On failure returns -errno.
- * Caller must hold the rbce_rwlock in write mode as global data is
- * written onto.
- */
-static int alloc_term_index(void)
-{
-	int size = gl_allocated;
-
-	if (gl_num_terms >= size) {
-		int i;
-		struct rbce_rule_term *oldv, *newv;
-		int newsize = size + POLICY_INC_NUMTERMS;
-
-		oldv = gl_terms;
-		newv =
-		    kmalloc(newsize * sizeof(struct rbce_rule_term),
-			    GFP_ATOMIC);
-		if (!newv)
-			return -ENOMEM;
-		memcpy(newv, oldv, size * sizeof(struct rbce_rule_term));
-		for (i = size; i < newsize; i++)
-			newv[i].op = -1;
-		gl_terms = newv;
-		gl_allocated = newsize;
-		kfree(oldv);
-
-		gl_action |= POLICY_ACTION_NEW_VERSION;
-	}
-	return gl_num_terms++;
-}
-
-/*
- * Release an index in the global term vector
- *
- * Caller must hold the rbce_rwlock in write mode as the global data
- * is written onto.
- */
-static void release_term_index(int idx)
-{
-	if ((idx < 0) || (idx > gl_num_terms))
-		return;
-
-	gl_terms[idx].op = -1;
-	gl_released++;
-	if ((gl_released > POLICY_INC_NUMTERMS) &&
-	    (gl_allocated >
-	     (gl_num_terms - gl_released + POLICY_INC_NUMTERMS))) {
-		gl_action |= POLICY_ACTION_PACK_TERMS;
-	}
-	return;
-}
-
-/*
- * Release the indices, string memory, and terms associated with the given
- * rule.
- *
- * Caller should be holding rbce_rwlock
- */
-static void __release_rule(struct rbce_rule *rule)
-{
-	int i, *terms = rule->terms;
-
-	/* remove memory and references from other rules */
-	for (i = rule->num_terms; --i >= 0;) {
-		struct rbce_rule_term *term = &gl_terms[terms[i]];
-
-		if (term->op == RBCE_RULE_DEP_RULE)
-			DEC_REF(term->u.deprule);
-		release_term_index(terms[i]);
-	}
-	rule->num_terms = 0;
-	if (rule->strtab) {
-		kfree(rule->strtab);
-		rule->strtab = NULL;
-	}
-	if (rule->terms) {
-		kfree(rule->terms);
-		rule->terms = NULL;
-	}
-	return;
-}
-
-/*
- * delete the given rule and all memory associated with it.
- *
- * Caller is responsible for protecting the global data
- */
-static inline int __delete_rule(struct rbce_rule *rule)
-{
-	/* make sure we are not referenced by other rules */
-	if (list_empty(&rule->obj.link))
-		return 0;
-	if (GET_REF(rule))
-		return -EBUSY;
-	__release_rule(rule);
-	put_class(rule->target_class);
-	release_term_index(rule->index);
-	list_del_init(&rule->obj.link);
-	gl_num_rules--;
-	gl_rules_version++;
-	module_put(THIS_MODULE);
-	kfree(rule->obj.name);
-	kfree(rule);
-	if (rbce_enabled && (gl_action & POLICY_ACTION_PACK_TERMS))
-		optimize_policy();
-	return 0;
-}
-
-/*
- * Optimize the rule evaluation logic
- *
- * Caller must hold rbce_rwlock in write mode.
- */
-static void optimize_policy(void)
-{
-	int i, ii;
-	struct rbce_rule *rule;
-	struct rbce_rule_term *terms;
-	int num_terms;
-	int bsize;
-	bitvector_t **mask_vecs;
-	int pack_terms = 0;
-	int redoall;
-
-	/*
-	 * Due to dynamic rule addition/deletion of rules the term
-	 * vector can get sparse. As a result the bitvectors grow as we don't
-	 * reuse returned indices. If it becomes sparse enough we pack them
-	 * closer.
-	 */
-
-	pack_terms = (gl_action & POLICY_ACTION_PACK_TERMS);
-
-	if (pack_terms) {
-		int nsz = ALIGN((gl_num_terms - gl_released),
-				POLICY_INC_NUMTERMS);
-		int newidx = 0;
-		struct rbce_rule_term *newterms;
-
-		terms = gl_terms;
-		newterms =
-		    kmalloc(nsz * sizeof(struct rbce_rule_term), GFP_ATOMIC);
-		if (newterms) {
-			for (ii = 0; ii < CKRM_MAX_CLASSTYPES; ii++) {
-				/* FIXME: check only for task class types */
-				list_for_each_entry_reverse(rule,
-							    &rules_list[ii],
-							    obj.link) {
-					rule->index = newidx++;
-					for (i = rule->num_terms; --i >= 0;) {
-						int idx = rule->terms[i];
-						newterms[newidx] = terms[idx];
-						rule->terms[i] = newidx++;
-					}
-				}
-			}
-			kfree(terms);
-			gl_allocated = nsz;
-			gl_released = 0;
-			gl_num_terms = newidx;
-			gl_terms = newterms;
-
-			gl_action &= ~POLICY_ACTION_PACK_TERMS;
-			gl_action |= POLICY_ACTION_NEW_VERSION;
-		}
-	}
-
-	num_terms = gl_num_terms;
-	bsize = gl_allocated / 8 + sizeof(bitvector_t);
-	mask_vecs = gl_mask_vecs;
-	terms = gl_terms;
-
-	if (gl_action & POLICY_ACTION_NEW_VERSION) {
-		/* allocate new mask vectors */
-		char *temp = kmalloc(NUM_TERM_MASK_VECTOR * bsize, GFP_ATOMIC);
-
-		if (!temp) {
-			return;
-		}
-		if (mask_vecs[0]) {/* index 0 has the alloc returned address */
-			kfree(mask_vecs[0]);
-		}
-		for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
-			mask_vecs[i] = (bitvector_t *) (temp + i * bsize);
-			bitvector_init(mask_vecs[i], gl_allocated);
-		}
-		gl_action &= ~POLICY_ACTION_NEW_VERSION;
-		gl_action |= POLICY_ACTION_REDO_ALL;
-		gl_bitmap_version++;
-	}
-
-	/* We do two things here at once
-	 * 1) recompute the rulemask for each required rule
-	 *      we guarantee proper dependency order during creation time and
-	 *      by reversely running through this list.
-	 * 2) recompute the mask for each term and rule, if required
-	 */
-
-	redoall = gl_action & POLICY_ACTION_REDO_ALL;
-	gl_action &= ~POLICY_ACTION_REDO_ALL;
-
-	for (ii = 0; ii < CKRM_MAX_CLASSTYPES; ii++) {
-		/* FIXME: check only for task class types */
-		list_for_each_entry_reverse(rule, &rules_list[ii], obj.link) {
-			unsigned long termflag;
-
-			if (!redoall && !rule->do_opt)
-				continue;
-			termflag = 0;
-			for (i = rule->num_terms; --i >= 0;) {
-				int j, idx = rule->terms[i];
-				struct rbce_rule_term *term = &terms[idx];
-				int vecidx = termop_2_vecidx[term->op];
-
-				if (vecidx == -1) {
-					termflag |= term->u.deprule->termflag;
-					/* mark this term belonging to all
-					   contexts of deprule */
-					for (j = 0; j < NUM_TERM_MASK_VECTOR;
-					     j++) {
-						if (term->u.deprule->termflag
-						    & (1 << j)) {
-							bitvector_set(idx,
-								      mask_vecs
-								      [j]);
-						}
-					}
-				} else {
-					termflag |= TERM_2_TERMFLAG(vecidx);
-					/* mark this term belonging to
-					   a particular context */
-					bitvector_set(idx, mask_vecs[vecidx]);
-				}
-			}
-			for (i = 0; i < NUM_TERM_MASK_VECTOR; i++) {
-				if (termflag & (1 << i)) {
-					bitvector_set(rule->index,
-						      mask_vecs[i]);
-				}
-			}
-			rule->termflag = termflag;
-			rule->do_opt = 0;
-		}
-	}
-	return;
-}
-
-/* ======================= Rule related Functions ========================= */
-
-/*
- * This function takes terms as input and digests the valid rbce terms
- * and fills the newrule appropriately.
- *	 Valid terms have op != RBCE_RULE_INVALID
- * This function returns the number of valid terms found.
- * In case of error it return -errno
- */
-static inline int
-digest_terms(struct rbce_rule *newrule,
-	struct rbce_rule_term *terms, int nterms)
-{
-	char *strtab = NULL;
-	struct rbce_rule *deprule;
-	int i, j, real_nterms = 0, strtablen = 0;
-
-	for (i = 0; i < nterms; i++) {
-		if (terms[i].op == RBCE_RULE_INVALID)
-			continue;
-		real_nterms++;
-
-		switch (terms[i].op) {
-		case RBCE_RULE_DEP_RULE:
-			/* check if the depend rule is valid */
-			deprule = find_rule_name(terms[i].u.string);
-			if (!deprule || deprule == newrule) {
-				real_nterms = -EINVAL;
-				goto out;
-			} else {
-				/* make sure _a_ depend rule */
-				/* appears in only one term. */
-				for (j = 0; j < i; j++) {
-					if (terms[j].op ==
-					    RBCE_RULE_DEP_RULE
-					    && terms[j].u.deprule ==
-					    deprule) {
-						real_nterms = -EINVAL;
-						goto out;
-					}
-				}
-				terms[i].u.deprule = deprule;
-			}
-
-			/* +depend is acceptable and -depend is not */
-			if (terms[i].operator != TOKEN_OP_DEP_DEL)
-				terms[i].operator = RBCE_EQUAL;
-			else {
-				real_nterms = -EINVAL;
-				goto out;
-			}
-			break;
-
-		case RBCE_RULE_CMD_PATH:
-		case RBCE_RULE_CMD:
-		case RBCE_RULE_ARGS:
-		case RBCE_RULE_APP_TAG:
-		case RBCE_RULE_IPV4:
-		case RBCE_RULE_IPV6:
-			/* sum up the string length */
-			strtablen += strlen(terms[i].u.string) + 1;
-			break;
-		default:
-			break;
-
-		}
-	}
-	if (strtablen) {
-		strtab = kmalloc(strtablen, GFP_ATOMIC);
-		if (!strtab)
-			real_nterms = -ENOMEM;
-		else {
-			if (newrule->strtab)
-				kfree(newrule->strtab);
-			newrule->strtab = strtab;
-		}
-	}
-out:
-	return real_nterms;
-}
-
-/*
- * This function takes terms as input and digests the non rbce terms
- * and fills newrule appropriately.
- * non rbce teerms are used to get attribute/value that are not part
- * of the rule terms.
- *	 non rbce terms have op != RBCE_RULE_INVALID
- * This function returns 0 on success and -errno in case of error
- */
-static inline int
-digest_nonterms(struct rbce_rule *newrule,
-	struct rbce_rule_term *terms, int nterms)
-{
-	char *class = NULL;
-	int state = -1, order = -1, rc = 0, i;
-
-	for (i = 0; i < nterms; i++) {
-		if (terms[i].op != RBCE_RULE_INVALID)
-			continue;
-		switch (terms[i].operator) {
-		case TOKEN_OP_ORDER:
-			order = terms[i].u.id;
-			if (order < 0) {
-				rc = -EINVAL;
-				goto out;
-			}
-			break;
-		case TOKEN_OP_STATE:
-			state = terms[i].u.id != 0;
-			break;
-		case TOKEN_OP_CLASS:
-			class = terms[i].u.string;
-			break;
-		default:
-			break;
-		}
-	}
-
-	/* Check if class was specified */
-	if (class != NULL) {
-		int classtype;
-		struct rbce_class *targetcls;
-		if ((targetcls = get_class(class, &classtype)) == NULL) {
-			rc = -EINVAL;
-			goto out;
-		}
-		if (newrule->target_class)
-			put_class(newrule->target_class);
-
-		newrule->target_class = targetcls;
-		newrule->classtype = classtype;
-	}
-	if (!newrule->target_class) {
-		rc = -EINVAL;
-		goto out;
-	}
-	if (state != -1)
-		newrule->state = state;
-	if (order != -1)
-		newrule->order = order;
-out:
-	return rc;
-}
-
-/*
- * Allocate and fill the term vectors of the newrule from the terms array.
- * Only handle the realy terms and ignore the nonterms.
- */
-static inline int
-fill_term_vector(struct rbce_rule *newrule,
-	struct rbce_rule_term *terms, int real_nterms)
-{
-	int i, rc = 0, strtablen = 0, j, ii;
-	struct rbce_rule_term *term;
-
-	newrule->terms = kmalloc(real_nterms * sizeof(int), GFP_ATOMIC);
-	if (!newrule->terms) {
-		rc = -ENOMEM;
-		goto out;
-	}
-
-	for (i = 0, j = 0; j < real_nterms; i++, j++) {
-		if (terms[i].op == RBCE_RULE_INVALID)
-			continue;
-
-		newrule->terms[j] = alloc_term_index();
-		if (newrule->terms[j] < 0) {
-			for (ii = 0; ii < j; ii++)
-				release_term_index(newrule->terms[ii]);
-			rc = -ENOMEM;
-			goto out;
-		}
-		term = &gl_terms[newrule->terms[j]];
-		term->op = terms[i].op;
-		term->operator = terms[i].operator;
-		switch (terms[i].op) {
-		case RBCE_RULE_CMD_PATH:
-		case RBCE_RULE_CMD:
-		case RBCE_RULE_ARGS:
-		case RBCE_RULE_APP_TAG:
-		case RBCE_RULE_IPV4:
-		case RBCE_RULE_IPV6:
-			term->u.string = &newrule->strtab[strtablen];
-			strcpy(term->u.string, terms[i].u.string);
-			strtablen = strlen(term->u.string) + 1;
-			break;
-
-		case RBCE_RULE_REAL_UID:
-		case RBCE_RULE_REAL_GID:
-		case RBCE_RULE_EFFECTIVE_UID:
-		case RBCE_RULE_EFFECTIVE_GID:
-			term->u.id = terms[i].u.id;
-			break;
-
-		case RBCE_RULE_DEP_RULE:
-			term->u.deprule = terms[i].u.deprule;
-			INC_REF(term->u.deprule);
-			break;
-		default:
-			break;
-		}
-	}
-out:
-	if (rc) {
-		kfree(newrule->terms);
-		newrule->terms = NULL;
-	}
-	return rc;
-
-}
-
-/*
- * Caller need to hold rbce_rwlock in write mode.
- */
-static int
-fill_rule(struct rbce_rule *newrule, struct rbce_rule_term *terms, int nterms)
-{
-	int real_nterms, index = -1, rc = 0;
-	struct rbce_rule_term *term = NULL;
-
-	if (!newrule)
-		return -EINVAL;
-	newrule->num_terms = 0;
-	newrule->termflag = 0;
-
-	/* Digest filled terms. */
-	real_nterms = digest_terms(newrule, terms, nterms);
-	if (real_nterms < 0)
-		return real_nterms;
-	rc = digest_nonterms(newrule, terms, nterms);
-	if (rc < 0)
-		goto out;
-
-	if (newrule->index == -1) {
-		index = alloc_term_index();
-		if (index < 0) {
-			rc = -ENOMEM;
-			goto out;
-		}
-		newrule->index = index;
-		term = &gl_terms[newrule->index];
-		term->op = RBCE_RULE_DEP_RULE;
-		term->u.deprule = newrule;
-	}
-
-	rc = fill_term_vector(newrule, terms, real_nterms);
-out:
-	if (rc) {
-		if (newrule->target_class) {
-			put_class(newrule->target_class);
-			newrule->target_class = NULL;
-		}
-		if (index >= 0) {
-			release_term_index(index);
-			newrule->index = -1;
-		}
-		kfree(newrule->terms);
-		newrule->terms = NULL;
-		kfree(newrule->strtab);
-		newrule->strtab = NULL;
-		newrule->num_terms = 0;
-	} else
-		newrule->num_terms = real_nterms;
-	return rc;
-}
-
-static inline int
-rbce_create_rule(struct rbce_rule_term *new_terms,
-	int nterms, const char *rname)
-{
-	struct rbce_rule *rule;
-	int rc = -ENOMEM;
-
-	rule = kmalloc (sizeof(struct rbce_rule), GFP_ATOMIC);
-	if (rule) {
-		rule->obj.name = kmalloc(strlen(rname) + 1, GFP_ATOMIC);
-		if (rule->obj.name) {
-			strcpy(rule->obj.name, rname);
-			GET_REF(rule) = 0;
-			rule->order = -1;
-			rule->index = -1;
-			rule->num_terms = 0;
-			rule->state = RBCE_RULE_ENABLED;
-			rule->target_class = NULL;
-			rule->strtab = NULL;
-			rule->classtype = -1;
-			rule->terms = NULL;
-			rule->do_opt = 1;
-			INIT_LIST_HEAD(&rule->obj.link);
-			rc = fill_rule(rule, new_terms, nterms);
-			if (rc) {
-				kfree(rule->obj.name);
-				kfree(rule);
-			} else if ((rc = insert_rule(rule,
-					rule->order, INSERT)) != 0)
-				__delete_rule(rule);
-		} else
-			kfree(rule);
-	}
-	return rc;
-}
-
-static inline struct rbce_rule_term *
-merge_terms(struct rbce_rule *rule, struct rbce_rule_term *new_terms,
-	int nterms, int new_term_mask, int *merged_nterms)
-{
-	struct rbce_rule_term *terms, *term;
-	struct rbce_rule *deprule;
-	int i, j, k, oterms, tot_terms, strlocal_len;
-	char *strlocal;
-
-	oterms = rule->num_terms;
-	tot_terms = nterms + oterms;
-	*merged_nterms = 0;
-
-	terms = kmalloc(tot_terms * sizeof(struct rbce_rule_term), GFP_ATOMIC);
-
-	if (!terms) {
-		return NULL;
-	}
-
-	/* Assume we are going to copy all strings from the original rule. */
-	strlocal_len = 0;
-	for (i = 0; i < oterms; i++) {
-		term = &gl_terms[rule->terms[i]];
-		switch (term->op) {
-		case RBCE_RULE_CMD_PATH:
-		case RBCE_RULE_CMD:
-		case RBCE_RULE_ARGS:
-		case RBCE_RULE_APP_TAG:
-		case RBCE_RULE_IPV4:
-		case RBCE_RULE_IPV6:
-			strlocal_len += strlen(term->u.string) + 1;
-			break;
-		default:
-			break;
-		}
-	}
-
-	strlocal = kmalloc(strlocal_len, GFP_ATOMIC);
-	if (!strlocal) {
-		kfree(terms);
-		return NULL;
-	}
-
-	strlocal_len = 0;
-	new_term_mask &= ~(1 << RBCE_RULE_DEP_RULE);
-	/* ignore the new deprule terms for the first iteration. */
-	/* taken care of later. */
-	for (i = 0; i < oterms; i++) {
-		term = &gl_terms[rule->terms[i]];	/* old term */
-
-		if ((1 << term->op) & new_term_mask) {
-			/* newrule has this attr/value */
-			for (j = 0; j < nterms; j++)
-				if (term->op == new_terms[j].op) {
-					terms[i].op = new_terms[j].op;
-					terms[i].operator = new_terms[j].
-					    operator;
-					terms[i].u.string =
-					    new_terms[j].u.string;
-					new_terms[j].op = RBCE_RULE_INVALID2;
-					break;
-				}
-		} else {
-			terms[i].op = term->op;
-			terms[i].operator = term->operator;
-			switch (term->op) {
-			case RBCE_RULE_CMD_PATH:
-			case RBCE_RULE_CMD:
-			case RBCE_RULE_ARGS:
-			case RBCE_RULE_APP_TAG:
-			case RBCE_RULE_IPV4:
-			case RBCE_RULE_IPV6:
-				terms[i].u.string = &strlocal[strlocal_len];
-				strcpy(terms[i].u.string, term->u.string);
-				strlocal_len = strlen(terms[i].u.string) + 1;
-				break;
-			default:
-				terms[i].u.string = term->u.string;
-				break;
-			}
-		}
-	}
-
-	i = oterms;		/* for readability */
-
-	for (j = 0; j < nterms; j++) {
-		/* handled in the previous iteration */
-		if (new_terms[j].op == RBCE_RULE_INVALID2)
-			continue;
-		if (new_terms[j].op == RBCE_RULE_DEP_RULE) {
-			if (new_terms[j].operator == TOKEN_OP_DEP) {
-				/*
-				 * "depend=rule" deletes all depends in the
-				 * original rule so, delete all depend rule
-				 * terms in the original rule
-				 */
-				for (k = 0; k < oterms; k++)
-					if (terms[k].op == RBCE_RULE_DEP_RULE)
-						terms[k].op = RBCE_RULE_INVALID;
-				/* must copy the new deprule term */
-			} else {
-				/*
-				 * delete the depend rule term if was defined
-				 * in the original rule for both +depend
-				 * and -depend
-				 */
-				deprule = find_rule_name(new_terms[j].u.string);
-				if (deprule)
-					for (k = 0; k < oterms; k++) {
-						if (terms[k].op ==
-						    RBCE_RULE_DEP_RULE
-						    && terms[k].u.deprule ==
-						    deprule) {
-							terms[k].op =
-							    RBCE_RULE_INVALID;
-							break;
-						}
-					}
-				if (new_terms[j].operator == TOKEN_OP_DEP_DEL)
-					/* No need to copy the new deprule */
-					continue;
-			}
-		}
-		terms[i].op = new_terms[j].op;
-		terms[i].operator = new_terms[j].operator;
-		terms[i].u.string = new_terms[j].u.string;
-		i++;
-		new_terms[j].op = RBCE_RULE_INVALID2;
-	}
-
-	tot_terms = i;
-
-	/* convert old deprule pointers to name pointers. */
-	for (i = 0; i < oterms; i++) {
-		if (terms[i].op != RBCE_RULE_DEP_RULE)
-			continue;
-		terms[i].u.string = terms[i].u.deprule->obj.name;
-	}
-
-	*merged_nterms = tot_terms;
-	return terms;
-}
-
-int rbce_change_rule(const char *rname, char *rdefn)
-{
-	struct rbce_rule *rule;
-	struct rbce_rule_term *new_terms = NULL, *merged_terms;
-	int nterms, new_term_mask = 0, merged_nterms, rc = -ENOMEM;
-
-	if ((nterms = rules_parse(rdefn, &new_terms, &new_term_mask)) <= 0)
-		return !nterms ? -EINVAL : nterms;
-
-	write_lock(&rbce_rwlock);
-	rule = find_rule_name(rname);
-	if (rule == NULL) {
-		rc = rbce_create_rule(new_terms, nterms, rname);
-		kfree(new_terms);
-		write_unlock(&rbce_rwlock);
-		return rc;
-	}
-
-	merged_terms = merge_terms(rule, new_terms, nterms, new_term_mask,
-			&merged_nterms);
-
-	if (merged_terms) {
-		/* release the rule */
-		__release_rule(rule);
-
-		rule->do_opt = 1;
-		rc = fill_rule(rule, merged_terms, merged_nterms);
-		if (rc == 0)
-			rc = insert_rule(rule, rule->order, REINSERT);
-		if (rc != 0)	/* rule creation/insertion failed */
-			__delete_rule(rule);
-	}
-
-	write_unlock(&rbce_rwlock);
-	kfree(merged_terms);
-	kfree(new_terms);
-	return rc;
-}
-
-/*
- * Delete the specified rule.
- *
- */
-int rbce_delete_rule(const char *rname)
-{
-	int rc = 0;
-	struct rbce_rule *rule;
-
-	write_lock(&rbce_rwlock);
-
-	if ((rule = find_rule_name(rname)) != NULL)
-		rc = __delete_rule(rule);
-	write_unlock(&rbce_rwlock);
-	return rc;
-}
-
-/*
- * copy the rule specified by rname and to the given result string.
- *
- */
-void rbce_get_rule(const char *rname, char *result)
-{
-	int i;
-	struct rbce_rule *rule;
-	struct rbce_rule_term *term;
-	char *cp = result, oper, idtype[3], str[5];
-
-	read_lock(&rbce_rwlock);
-
-	rule = find_rule_name(rname);
-	if (rule != NULL) {
-		for (i = 0; i < rule->num_terms; i++) {
-			term = gl_terms + rule->terms[i];
-			switch (term->op) {
-			case RBCE_RULE_REAL_UID:
-				strcpy(idtype, "u");
-				goto handleid;
-			case RBCE_RULE_REAL_GID:
-				strcpy(idtype, "g");
-				goto handleid;
-			case RBCE_RULE_EFFECTIVE_UID:
-				strcpy(idtype, "eu");
-				goto handleid;
-			case RBCE_RULE_EFFECTIVE_GID:
-				strcpy(idtype, "eg");
-			handleid:
-				switch (term->operator) {
-				case RBCE_LESS_THAN:
-					oper = '<';
-					break;
-				case RBCE_GREATER_THAN:
-					oper = '>';
-					break;
-				case RBCE_NOT:
-					oper = '!';
-					break;
-				default:
-					oper = '=';
-					break;
-				}
-				cp +=
-				    sprintf(cp, "%sid%c%ld,", idtype, oper,
-					    term->u.id);
-				break;
-			case RBCE_RULE_CMD_PATH:
-				strcpy(str, "path");
-				goto handle_str;
-			case RBCE_RULE_CMD:
-				strcpy(str, "cmd");
-				goto handle_str;
-			case RBCE_RULE_ARGS:
-				strcpy(str, "args");
-				goto handle_str;
-			case RBCE_RULE_APP_TAG:
-				strcpy(str, "tag");
-				goto handle_str;
-			case RBCE_RULE_IPV4:
-				strcpy(str, "ipv4");
-				goto handle_str;
-			case RBCE_RULE_IPV6:
-				strcpy(str, "ipv6");
-			      handle_str:
-				cp +=
-				    sprintf(cp, "%s=%s,", str, term->u.string);
-				break;
-			case RBCE_RULE_DEP_RULE:
-				cp +=
-				    sprintf(cp, "depend=%s,",
-					    term->u.deprule->obj.name);
-				break;
-			default:
-				break;
-			}
-		}
-
-		cp +=
-		    sprintf(cp, "order=%d,state=%d,", rule->order, rule->state);
-		cp +=
-		    sprintf(cp, "class=%s",
-			    rule->target_class ? rule->target_class->obj.
-			    name : "*****REMOVED*****");
-		*cp = '\0';
-	} else
-		sprintf(result, "***** Rule %s doesn't exist *****", rname);
-
-	read_unlock(&rbce_rwlock);
-	return;
-}
-
-/*
- * Change the name of the given rule "from_rname" to "to_rname"
- *
- */
-int rbce_rename_rule(const char *from_rname, const char *to_rname)
-{
-	struct rbce_rule *rule;
-	int nlen, rc = -EINVAL;
-
-	if (!to_rname || !*to_rname)
-		return rc;
-	write_lock(&rbce_rwlock);
-
-	rule = find_rule_name(from_rname);
-	if (rule != NULL) {
-		if ((nlen = strlen(to_rname)) > strlen(rule->obj.name)) {
-			char *name = kmalloc(nlen + 1, GFP_ATOMIC);
-			if (!name)
-				return -ENOMEM;
-			kfree(rule->obj.name);
-			rule->obj.name = name;
-		}
-		strcpy(rule->obj.name, to_rname);
-		rc = 0;
-	}
-	write_unlock(&rbce_rwlock);
-	return rc;
-}
-
-/*
- * Return TRUE if the given rule exists, FALSE otherwise
- *
- */
-int rbce_rule_exists(const char *rname)
-{
-	struct rbce_rule *rule;
-
-	read_lock(&rbce_rwlock);
-	rule = find_rule_name(rname);
-	read_unlock(&rbce_rwlock);
-	return rule != NULL;
-}
-
-/*====================== Magic file handling =======================*/
-static inline
-void reset_evaluation(struct rbce_private_data *pdata,int termflag)
-{
-	/* reset TAG ruleterm evaluation results to pick up
- 	 * on next classification event
- 	 */
-	if (termflag >= NUM_TERM_MASK_VECTOR) {
-		printk(KERN_ERR "rbce:reset_evaluation: trying to access "
-			"past valid address\n");
-		return;
-	}
- 	if (use_persistent_state && gl_mask_vecs[termflag]) {
- 		bitvector_and_not( pdata->eval, pdata->eval,
- 				   gl_mask_vecs[termflag] );
- 		bitvector_and_not( pdata->true, pdata->true,
- 				   gl_mask_vecs[termflag] );
- 	}
-}
-
-int rbce_set_tasktag(int pid, char *tag)
-{
-	char *tp;
-	int rc = 0;
-	struct task_struct *tsk;
-	struct rbce_private_data *pdata;
-	int len;
-
-	if (!tag)
-		return -EINVAL;
-	len = strlen(tag) + 1;
-	tp = kmalloc(len, GFP_ATOMIC);
-	if (!tp)
-		return -ENOMEM;
-	strncpy(tp,tag,len);
-
-	read_lock(&tasklist_lock);
-	if ((tsk = find_task_by_pid(pid)) == NULL) {
-		rc = -EINVAL;
-		goto out;
-	}
-
-	if (!RBCE_DATA(tsk)) {
-		RBCE_DATAP(tsk) = create_private_data(NULL, 0);
-		if (!RBCE_DATA(tsk)) {
-			rc = -ENOMEM;
-			goto out;
-		}
-	}
-	pdata = RBCE_DATA(tsk);
-	if (pdata->app_tag)
-		kfree(pdata->app_tag);
-	pdata->app_tag = tp;
-
-out:
-	read_unlock(&tasklist_lock);
-	if (rc != 0)
-		kfree(tp);
-	return rc;
-}
-
-/* ======================= Module definition Functions ====================== */
-
-int init_rbce(void)
-{
-	int rc, i, line;
-
-	printk(KERN_INFO "Installing \'%s\' module\n", modname);
-
-	for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
-		INIT_LIST_HEAD(&rules_list[i]);
-	}
-
-	rc = init_rbce_ext_pre();
-	line = __LINE__;
-	if (rc)
-		goto out;
-
-	rc = register_classtype_engines();
-	line = __LINE__;
-	if (rc)
-		goto out_unreg_ckrm;
-
-	/* register any other class type engine here */
-  	rc = rcfs_register_engine(&rbce_rcfs_ecbs);
-  	line = __LINE__;
-  	if (rc)
-		goto out_unreg_classtype;;
-
-	if (rcfs_mounted) {
-		rc = rbce_create_config();
-		line = __LINE__;
-		if (rc)
-			goto out_unreg_rcfs;
-	}
-
-	rc = init_rbce_ext_post();
-	line = __LINE__;
-	if (rc)
-		goto out_unreg_rcfs;
-	return 0;
-
-out_unreg_rcfs:
-	rcfs_unregister_engine(&rbce_rcfs_ecbs);
-out_unreg_classtype:
- 	unregister_classtype_engines();
-out_unreg_ckrm:
-	exit_rbce_ext();
-out:
-	printk(KERN_ERR "%s: error installing rc=%d line=%d\n",
-		__FUNCTION__, rc, line);
-	return rc;
-}
-
-void exit_rbce(void)
-{
-	int i;
-	printk(KERN_INFO "Removing \'%s\' module\n", modname);
-
-	exit_rbce_ext();
-
-	/* Print warnings if lists are not empty, which is a bug */
-	if (!list_empty(&class_list)) {
-		printk(KERN_WARNING "exit_rbce: Class list is not empty\n");
-	}
-
-	for (i = 0; i < CKRM_MAX_CLASSTYPES; i++) {
-		if (!list_empty(&rules_list[i])) {
-			printk(KERN_WARNING "exit_rbce: Rules list for "
-				"classtype %d is not empty\n", i);
-		}
-	}
-
-	if (rcfs_mounted)
-		rbce_clear_config();
-
-	rcfs_unregister_engine(&rbce_rcfs_ecbs);
-	unregister_classtype_engines();
-	free_all_private_data();
-}
-
-module_init(init_rbce);
-module_exit(exit_rbce);
Index: linux-2.6.13-rc6/kernel/ckrm/rbce/rbce_token.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/rbce/rbce_token.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/* Tokens for Rule-based Classification Engine (RBCE) and
- * Consolidated RBCE module code (combined)
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003
- *           (C) Chandra Seetharaman, IBM Corp. 2003
- *           (C) Vivek Kashyap, IBM Corp. 2004
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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 would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *
- */
-
-#include <linux/parser.h>
-#include <linux/ctype.h>
-#include "rbce_internal.h"
-
-int token_to_ruleop[TOKEN_INVALID + 1] = {
-	[TOKEN_PATH] = RBCE_RULE_CMD_PATH,
-	[TOKEN_CMD] = RBCE_RULE_CMD,
-	[TOKEN_ARGS] = RBCE_RULE_ARGS,
-	[TOKEN_RUID_EQ] = RBCE_RULE_REAL_UID,
-	[TOKEN_RUID_LT] = RBCE_RULE_REAL_UID,
-	[TOKEN_RUID_GT] = RBCE_RULE_REAL_UID,
-	[TOKEN_RUID_NOT] = RBCE_RULE_REAL_UID,
-	[TOKEN_RGID_EQ] = RBCE_RULE_REAL_GID,
-	[TOKEN_RGID_LT] = RBCE_RULE_REAL_GID,
-	[TOKEN_RGID_GT] = RBCE_RULE_REAL_GID,
-	[TOKEN_RGID_NOT] = RBCE_RULE_REAL_GID,
-	[TOKEN_EUID_EQ] = RBCE_RULE_EFFECTIVE_UID,
-	[TOKEN_EUID_LT] = RBCE_RULE_EFFECTIVE_UID,
-	[TOKEN_EUID_GT] = RBCE_RULE_EFFECTIVE_UID,
-	[TOKEN_EUID_NOT] = RBCE_RULE_EFFECTIVE_UID,
-	[TOKEN_EGID_EQ] = RBCE_RULE_EFFECTIVE_GID,
-	[TOKEN_EGID_LT] = RBCE_RULE_EFFECTIVE_GID,
-	[TOKEN_EGID_GT] = RBCE_RULE_EFFECTIVE_GID,
-	[TOKEN_EGID_NOT] = RBCE_RULE_EFFECTIVE_GID,
-	[TOKEN_TAG] = RBCE_RULE_APP_TAG,
-	[TOKEN_IPV4] = RBCE_RULE_IPV4,
-	[TOKEN_IPV6] = RBCE_RULE_IPV6,
-	[TOKEN_DEP] = RBCE_RULE_DEP_RULE,
-	[TOKEN_DEP_ADD] = RBCE_RULE_DEP_RULE,
-	[TOKEN_DEP_DEL] = RBCE_RULE_DEP_RULE,
-	[TOKEN_ORDER] = RBCE_RULE_INVALID,
-	[TOKEN_CLASS] = RBCE_RULE_INVALID,
-	[TOKEN_STATE] = RBCE_RULE_INVALID,
-};
-
-enum op_token token_to_operator[TOKEN_INVALID + 1] = {
-	[TOKEN_PATH] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_CMD] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_ARGS] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_RUID_EQ] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_RUID_LT] = (__force op_token_t) TOKEN_OP_LESS_THAN,
-	[TOKEN_RUID_GT] = (__force op_token_t) TOKEN_OP_GREATER_THAN,
-	[TOKEN_RUID_NOT] = (__force op_token_t) TOKEN_OP_NOT,
-	[TOKEN_RGID_EQ] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_RGID_LT] = (__force op_token_t) TOKEN_OP_LESS_THAN,
-	[TOKEN_RGID_GT] = (__force op_token_t) TOKEN_OP_GREATER_THAN,
-	[TOKEN_RGID_NOT] = (__force op_token_t) TOKEN_OP_NOT,
-	[TOKEN_EUID_EQ] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_EUID_LT] = (__force op_token_t) TOKEN_OP_LESS_THAN,
-	[TOKEN_EUID_GT] = (__force op_token_t) TOKEN_OP_GREATER_THAN,
-	[TOKEN_EUID_NOT] = (__force op_token_t) TOKEN_OP_NOT,
-	[TOKEN_EGID_EQ] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_EGID_LT] = (__force op_token_t) TOKEN_OP_LESS_THAN,
-	[TOKEN_EGID_GT] = (__force op_token_t) TOKEN_OP_GREATER_THAN,
-	[TOKEN_EGID_NOT] = (__force op_token_t) TOKEN_OP_NOT,
-	[TOKEN_TAG] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_IPV4] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_IPV6] = (__force op_token_t) TOKEN_OP_EQUAL,
-	[TOKEN_DEP] = (__force op_token_t) TOKEN_OP_DEP,
-	[TOKEN_DEP_ADD] = (__force op_token_t) TOKEN_OP_DEP_ADD,
-	[TOKEN_DEP_DEL] = (__force op_token_t) TOKEN_OP_DEP_DEL,
-	[TOKEN_ORDER] = (__force op_token_t) TOKEN_OP_ORDER,
-	[TOKEN_CLASS] = (__force op_token_t) TOKEN_OP_CLASS,
-	[TOKEN_STATE] = (__force op_token_t) TOKEN_OP_STATE
-};
-
-static match_table_t tokens = {
-	{TOKEN_PATH, "path=%s"},
-	{TOKEN_CMD, "cmd=%s"},
-	{TOKEN_ARGS, "args=%s"},
-	{TOKEN_RUID_EQ, "uid=%d"},
-	{TOKEN_RUID_LT, "uid<%d"},
-	{TOKEN_RUID_GT, "uid>%d"},
-	{TOKEN_RUID_NOT, "uid!%d"},
-	{TOKEN_RGID_EQ, "gid=%d"},
-	{TOKEN_RGID_LT, "gid<%d"},
-	{TOKEN_RGID_GT, "gid>%d"},
-	{TOKEN_RGID_NOT, "gid!d"},
-	{TOKEN_EUID_EQ, "euid=%d"},
-	{TOKEN_EUID_LT, "euid<%d"},
-	{TOKEN_EUID_GT, "euid>%d"},
-	{TOKEN_EUID_NOT, "euid!%d"},
-	{TOKEN_EGID_EQ, "egid=%d"},
-	{TOKEN_EGID_LT, "egid<%d"},
-	{TOKEN_EGID_GT, "egid>%d"},
-	{TOKEN_EGID_NOT, "egid!%d"},
-	{TOKEN_TAG, "tag=%s"},
-	{TOKEN_IPV4, "ipv4=%s"},
-	{TOKEN_IPV6, "ipv6=%s"},
-	{TOKEN_DEP, "depend=%s"},
-	{TOKEN_DEP_ADD, "+depend=%s"},
-	{TOKEN_DEP_DEL, "-depend=%s"},
-	{TOKEN_ORDER, "order=%d"},
-	{TOKEN_CLASS, "class=%s"},
-	{TOKEN_STATE, "state=%d"},
-	{TOKEN_INVALID, NULL}
-};
-
-/*
- * return -EINVAL in case of failures
- * returns number of terms in terms on success.
- * never returns 0.
- */
-
-int
-rules_parse(char *rule_defn, struct rbce_rule_term **rterms, int *term_mask)
-{
-	char *p, *rp = rule_defn;
-	int option, i = 0, nterms;
-	struct rbce_rule_term *terms;
-
-	*rterms = NULL;
-	*term_mask = 0;
-	if (!rule_defn)
-		return -EINVAL;
-
-	nterms = 0;
-	while (*rp++)
-		if (*rp == '>' || *rp == '<' || *rp == '=' || *rp == '!')
-			nterms++;
-
-	if (!nterms)
-		return -EINVAL;
-
-	terms = kmalloc(nterms * sizeof(struct rbce_rule_term), GFP_KERNEL);
-	if (!terms)
-		return -ENOMEM;
-
-	while ((p = strsep(&rule_defn, ",")) != NULL) {
-
-		substring_t args[MAX_OPT_ARGS];
-		int token;
-
-		while (*p && isspace(*p))
-			p++;
-		if (!*p)
-			continue;
-
-		token = match_token(p, tokens, args);
-
-		terms[i].op = token_to_ruleop[token];
-		terms[i].operator = token_to_operator[token];
-		switch (token) {
-
-		case TOKEN_PATH:
-		case TOKEN_CMD:
-		case TOKEN_ARGS:
-		case TOKEN_TAG:
-		case TOKEN_IPV4:
-		case TOKEN_IPV6:
-			/* all these tokens can be specified only once */
-			if (*term_mask & (1 << terms[i].op)) {
-				nterms = -EINVAL;
-				goto out;
-			}
-		/*FALLTHRU*/
-		case TOKEN_CLASS:
-		case TOKEN_DEP:
-		case TOKEN_DEP_ADD:
-		case TOKEN_DEP_DEL:
-			terms[i].u.string = args->from;
-			break;
-
-		case TOKEN_RUID_EQ:
-		case TOKEN_RUID_LT:
-		case TOKEN_RUID_GT:
-		case TOKEN_RUID_NOT:
-		case TOKEN_RGID_EQ:
-		case TOKEN_RGID_LT:
-		case TOKEN_RGID_GT:
-		case TOKEN_RGID_NOT:
-		case TOKEN_EUID_EQ:
-		case TOKEN_EUID_LT:
-		case TOKEN_EUID_GT:
-		case TOKEN_EUID_NOT:
-		case TOKEN_EGID_EQ:
-		case TOKEN_EGID_LT:
-		case TOKEN_EGID_GT:
-		case TOKEN_EGID_NOT:
-			/* all these tokens can be specified only once */
-			if (*term_mask & (1 << terms[i].op)) {
-				nterms = -EINVAL;
-				goto out;
-			}
-		/*FALLTHRU*/
-		case TOKEN_ORDER:
-		case TOKEN_STATE:
-			if (match_int(args, &option)) {
-				nterms = -EINVAL;
-				goto out;
-			}
-			terms[i].u.id = option;
-			break;
-		default:
-			nterms = -EINVAL;
-			goto out;
-		}
-		/* Check range of term value */
-		switch(token){
-		case TOKEN_STATE:
-			if ((terms[i].u.id != 0) && (terms[i].u.id != 1)){
-				nterms = -EINVAL;
-				goto out;
-			}
-			break;
-		default: /* Non-numerical value */
-			break;
-		}
-		*term_mask |= (1 << terms[i].op);
-		i++;
-	}
-	*rterms = terms;
-
-      out:
-	if (nterms < 0) {
-		kfree(terms);
-		*term_mask = 0;
-	}
-	return nterms;
-}
Index: linux-2.6.13-rc6/kernel/ckrm/ckrm.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/ckrm.c
+++ linux-2.6.13-rc6/kernel/ckrm/ckrm.c
@@ -27,10 +27,11 @@
 #include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
+#include <linux/ckrm.h>
 #include <linux/ckrm_rc.h>
 #include <linux/rcfs.h>
 #include <net/sock.h>
 #include <linux/ip.h>
 
@@ -40,13 +41,10 @@
 rwlock_t ckrm_class_lock;	/* protects classlists */
 
 struct rcfs_functions rcfs_fn;
 EXPORT_SYMBOL_GPL(rcfs_fn);
 
-int rcfs_engine_regd;		/* rcfs state needed by another module */
-EXPORT_SYMBOL_GPL(rcfs_engine_regd);
-
 int rcfs_mounted;
 EXPORT_SYMBOL_GPL(rcfs_mounted);
 
 /*
  * Helper Functions
@@ -119,17 +117,10 @@ EXPORT_SYMBOL_GPL(ckrm_classobj);
 
 /*
  * Internal Functions/macros
  */
 
-static inline void set_callbacks_active(struct ckrm_classtype *ctype)
-{
-	ctype->ce_cb_active = ((atomic_read(&ctype->ce_regd) > 0) &&
-			       (ctype->ce_callbacks.always_callback
-				|| (ctype->num_classes > 1)));
-}
-
 int ckrm_validate_and_grab_core(struct ckrm_core_class *core)
 {
 	int rc = 0;
 	read_lock(&ckrm_class_lock);
 	if (likely(ckrm_is_core_valid(core))) {
@@ -139,87 +130,10 @@ int ckrm_validate_and_grab_core(struct c
 	read_unlock(&ckrm_class_lock);
 	return rc;
 }
 
 /*
- * Interfaces for classification engine
- */
-
-/*
- * Registering a callback structure by the classification engine.
- *
- * Returns typeId of class on success -errno for failure.
- */
-int ckrm_register_engine(const char *typename, struct ckrm_eng_callback * ecbs)
-{
-	struct ckrm_classtype *ctype;
-
-	ctype = ckrm_find_classtype_by_name(typename);
-	if (ctype == NULL)
-		return (-ENOENT);
-
-	atomic_inc(&ctype->ce_regd);
-
-	/* another engine registered or trying to register ? */
-	if (atomic_read(&ctype->ce_regd) != 1) {
-		atomic_dec(&ctype->ce_regd);
-		return (-EBUSY);
-	}
-
-	/*
-	 * One of the following must be set:
-	 * classify, class_delete (due to object reference) or
-	 * notify (case where notification supported but not classification)
-	 * The function pointer must be set the momement the mask is non-null
-	 */
-	if (!(((ecbs->classify) && (ecbs->class_delete)) || (ecbs->notify)) ||
-	    (ecbs->c_interest && ecbs->classify == NULL) ||
-	    (ecbs->n_interest && ecbs->notify == NULL)) {
-		atomic_dec(&ctype->ce_regd);
-		return -EINVAL;
-	}
-
-	ctype->ce_callbacks = *ecbs;
-	set_callbacks_active(ctype);
-
-	if (ctype->ce_callbacks.class_add) {
-		struct ckrm_core_class *core;
-
-		read_lock(&ckrm_class_lock);
-		list_for_each_entry(core, &ctype->classes, clslist) {
-			(*ctype->ce_callbacks.class_add) (core->name, core,
-							  ctype->type_id);
-		}
-		read_unlock(&ckrm_class_lock);
-	}
-	return ctype->type_id;
-}
-
-/*
- * Unregistering a callback structure by the classification engine.
- *
- * Returns 0 on success -errno for failure.
- */
-int ckrm_unregister_engine(const char *typename)
-{
-	struct ckrm_classtype *ctype;
-
-	ctype = ckrm_find_classtype_by_name(typename);
-	if (ctype == NULL)
-		return (-ENOENT);
-
-	ctype->ce_cb_active = 0;
-	if (atomic_read(&ctype->ce_nr_users) > 1) {
-		/* Somebody is currently using the engine, cannot deregister. */
-		return (-EAGAIN);
-	}
-	atomic_set(&ctype->ce_regd, 0);
-	memset(&ctype->ce_callbacks, 0, sizeof(struct ckrm_eng_callback));
-	return 0;
-}
-
-/*
  * Interfaces to manipulate class (core or resource) hierarchies
  */
 
 static void
 ckrm_add_child(struct ckrm_core_class *parent, struct ckrm_core_class *child)
@@ -423,11 +337,10 @@ ckrm_init_core_class(struct ckrm_classty
 
 	INIT_LIST_HEAD(&dcore->objlist);
 	list_add_tail(&dcore->clslist, &clstype->classes);
 
 	clstype->num_classes++;
-	set_callbacks_active(clstype);
 
 	write_unlock(&ckrm_class_lock);
 	ckrm_add_child(parent, dcore);
 
 	for (i = 0; i < clstype->max_resid; i++)
@@ -497,11 +410,10 @@ void ckrm_free_core_class(struct ckrm_co
 	core->res_class = NULL;
 #endif
 	/* Remove this core class from its linked list. */
 	list_del(&core->clslist);
 	clstype->num_classes--;
-	set_callbacks_active(clstype);
 	write_unlock(&ckrm_class_lock);
 
 	/* fix for race condition seen in stress with numtasks */
 	if (parent)
 		ckrm_core_drop(parent);
@@ -842,11 +754,10 @@ void __init ckrm_init(void)
 	/* register/initialize the Metatypes */
 
 #ifdef CONFIG_CKRM_TYPE_TASKCLASS
 	{
 		extern void ckrm_meta_init_taskclass(void);
-		ckrm_cb_newtask(&init_task);
 		ckrm_meta_init_taskclass();
 		/* prepare init_task and then rely on inheritance
 		   of properties */
 	}
 #endif
@@ -857,13 +768,10 @@ void __init ckrm_init(void)
 	}
 #endif
 	printk("CKRM Initialization done\n");
 }
 
-EXPORT_SYMBOL_GPL(ckrm_register_engine);
-EXPORT_SYMBOL_GPL(ckrm_unregister_engine);
-
 EXPORT_SYMBOL_GPL(ckrm_register_res_ctlr);
 EXPORT_SYMBOL_GPL(ckrm_unregister_res_ctlr);
 
 EXPORT_SYMBOL_GPL(ckrm_init_core_class);
 EXPORT_SYMBOL_GPL(ckrm_free_core_class);
@@ -876,15 +784,10 @@ EXPORT_SYMBOL_GPL(ckrm_find_classtype_by
 EXPORT_SYMBOL_GPL(ckrm_core_grab);
 EXPORT_SYMBOL_GPL(ckrm_core_drop);
 EXPORT_SYMBOL_GPL(ckrm_is_core_valid);
 EXPORT_SYMBOL_GPL(ckrm_validate_and_grab_core);
 
-EXPORT_SYMBOL_GPL(ckrm_register_event_set);
-EXPORT_SYMBOL_GPL(ckrm_unregister_event_set);
-EXPORT_SYMBOL_GPL(ckrm_register_event_cb);
-EXPORT_SYMBOL_GPL(ckrm_unregister_event_cb);
-
 EXPORT_SYMBOL_GPL(ckrm_class_show_stats);
 EXPORT_SYMBOL_GPL(ckrm_class_show_config);
 EXPORT_SYMBOL_GPL(ckrm_class_show_shares);
 
 EXPORT_SYMBOL_GPL(ckrm_class_set_config);
Index: linux-2.6.13-rc6/init/Kconfig
===================================================================
--- linux-2.6.13-rc6.orig/init/Kconfig
+++ linux-2.6.13-rc6/init/Kconfig
@@ -200,50 +200,10 @@ config CKRM_RES_NUMTASKS
 	help
 	  Provides a Resource Controller for CKRM that allows limiting no of
 	  tasks a task class can have.
 
 	  Say N if unsure, Y to use the feature.
-
-
-choice
-	prompt "Classification Engine"
-	depends on CKRM && RCFS_FS
-	default CKRM_RBCE
-	optional
-	help
-	 Select a classification engine (CE) that assists in
-	 automatic classification of kernel objects managed by CKRM when
-	 they are created. Without a CE, a user must manually
-	 classify objects into classes. Processes inherit their parent's
-	 classification.
-
-	 Only one engine can be built into the kernel though all can be
-	 built as modules (only one will load).
-
- 	 Classification engines are optional component of CKRM.
-	 If unsure, say N.
-
-config CKRM_RBCE
-	tristate "Rule-based Classification Engine (RBCE)"
-	help
-	  Vanilla Rule-based Classification Engine (RBCE). Rules for
-	  classifying kernel objects are created/deleted/modified through
-	  a RCFS directory using a filesystem interface.
-
-config CKRM_CRBCE
-	tristate "Enhanced Rule-based Classification Engine (CRBCE)"
-	depends on DELAY_ACCT && NET
-	help
- 	  Enhanced Rule-based Classification Engine (CRBCE). Like the Vanilla
- 	  RBCE, rules for classifying kernel objects are created, deleted and
- 	  modified through a RCFS directory using a filesystem interface
- 	  (requires CKRM_RCFS configured).
-
- 	  In addition, CRBCE provides per-process delay data
- 	  (requires DELAY_ACCT configured) and makes information on significant
- 	  kernel events available to userspace tools through netlink.
-endchoice
 endmenu
 
 config SYSCTL
 	bool "Sysctl support"
 	---help---
Index: linux-2.6.13-rc6/kernel/ckrm/ckrmutils.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/ckrmutils.c
+++ linux-2.6.13-rc6/kernel/ckrm/ckrmutils.c
@@ -18,48 +18,12 @@
 #include <linux/err.h>
 #include <linux/mount.h>
 #include <linux/module.h>
 #include <linux/ckrm_rc.h>
 
-int get_exe_path_name(struct task_struct *tsk, char *buf, int buflen)
-{
-	struct vm_area_struct *vma;
-	struct vfsmount *mnt;
-	struct mm_struct *mm = get_task_mm(tsk);
-	struct dentry *dentry;
-	char *lname;
-	int rc = 0;
-
-	*buf = '\0';
-	if (!mm) {
-		return -EINVAL;
-	}
-	down_read(&mm->mmap_sem);
-	vma = mm->mmap;
-	while (vma) {
-		if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) {
-			dentry = dget(vma->vm_file->f_dentry);
-			mnt = mntget(vma->vm_file->f_vfsmnt);
-			lname = d_path(dentry, mnt, buf, buflen);
-			if (!IS_ERR(lname)) {
-				strncpy(buf, lname, strlen(lname) + 1);
-			} else {
-				rc = (int)PTR_ERR(lname);
-			}
-			mntput(mnt);
-			dput(dentry);
-			break;
-		}
-		vma = vma->vm_next;
-	}
-	up_read(&mm->mmap_sem);
-	mmput(mm);
-	return rc;
-}
-
 /*
- * TODO:  Use sparce to enforce cnt_lock.
+ * TODO:  Use sparse to enforce cnt_lock.
  *
  * must be called with cnt_lock of parres held
  * Caller is responsible for making sure that the new guarantee doesn't
  * overflow parent's total guarantee.
  */
@@ -185,9 +149,8 @@ set_shares(struct ckrm_shares *new, stru
 	rc = 0;
 set_share_err:
 	return rc;
 }
 
-EXPORT_SYMBOL_GPL(get_exe_path_name);
 EXPORT_SYMBOL_GPL(child_guarantee_changed);
 EXPORT_SYMBOL_GPL(child_maxlimit_changed);
 EXPORT_SYMBOL_GPL(set_shares);
Index: linux-2.6.13-rc6/kernel/ckrm/ckrm_events.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/ckrm_events.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ckrm_events.c - Class-based Kernel Resource Management (CKRM)
- *               - event handling routines
- *
- * Copyright (C) Hubertus Franke, IBM Corp. 2003, 2004
- *           (C) Chandra Seetharaman,  IBM Corp. 2003
- *
- *
- * Provides API for event registration and handling for different
- * classtypes.
- *
- * Latest version, more details at http://ckrm.sf.net
- *
- * 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.
- *
- */
-
-#include <linux/config.h>
-#include <linux/stddef.h>
-#include <linux/ckrm_events.h>
-
-/*******************************************************************
- *   Event callback invocation
- *******************************************************************/
-
-struct ckrm_hook_cb *ckrm_event_callbacks[CKRM_NONLATCHABLE_EVENTS];
-
-/* Registration / Deregistration / Invocation functions */
-
-int ckrm_register_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb)
-{
-	struct ckrm_hook_cb **cbptr;
-
-	if ((ev < CKRM_LATCHABLE_EVENTS) || (ev >= CKRM_NONLATCHABLE_EVENTS))
-		return 1;
-	cbptr = &ckrm_event_callbacks[ev];
-	while (*cbptr != NULL)
-		cbptr = &((*cbptr)->next);
-	*cbptr = cb;
-	return 0;
-}
-
-int ckrm_unregister_event_cb(enum ckrm_event ev, struct ckrm_hook_cb *cb)
-{
-	struct ckrm_hook_cb **cbptr;
-
-	if ((ev < CKRM_LATCHABLE_EVENTS) || (ev >= CKRM_NONLATCHABLE_EVENTS))
-		return -1;
-	cbptr = &ckrm_event_callbacks[ev];
-	while ((*cbptr != NULL) && (*cbptr != cb))
-		cbptr = &((*cbptr)->next);
-	if (*cbptr)
-		(*cbptr)->next = cb->next;
-	return (*cbptr == NULL);
-}
-
-int ckrm_register_event_set(struct ckrm_event_spec especs[])
-{
-	struct ckrm_event_spec *espec = especs;
-
-	for (espec = especs; espec->ev != -1; espec++)
-		ckrm_register_event_cb(espec->ev, &espec->cb);
-	return 0;
-}
-
-int ckrm_unregister_event_set(struct ckrm_event_spec especs[])
-{
-	struct ckrm_event_spec *espec = especs;
-
-	for (espec = especs; espec->ev != -1; espec++)
-		ckrm_unregister_event_cb(espec->ev, &espec->cb);
-	return 0;
-}
-
-void ckrm_invoke_event_cb_chain(enum ckrm_event ev, void *arg)
-{
-	struct ckrm_hook_cb *cb, *anchor;
-
-	if ((anchor = ckrm_event_callbacks[ev]) != NULL) {
-		for (cb = anchor; cb; cb = cb->next)
-			(*cb->fct) (arg);
-	}
-}
-
Index: linux-2.6.13-rc6/kernel/ckrm/ckrm_tc.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/ckrm_tc.c
+++ linux-2.6.13-rc6/kernel/ckrm/ckrm_tc.c
@@ -100,11 +100,11 @@ struct ckrm_classtype ct_taskclass = {
  * Function is also called with a ckrm_core_grab on the new core, hence
  * it needs to be dropped if no assignment takes place.
  */
 static void
 ckrm_set_taskclass(struct task_struct *tsk, struct ckrm_task_class *newcls,
-		   struct ckrm_task_class *oldcls, enum ckrm_event event)
+		   struct ckrm_task_class *oldcls)
 {
 	int i;
 	struct ckrm_classtype *clstype;
 	struct ckrm_res_ctlr *rcbs;
 	struct ckrm_task_class *curcls;
@@ -181,12 +181,10 @@ ckrm_set_taskclass(struct task_struct *t
 	if (newcls == curcls) {
 		spin_unlock(&tsk->ckrm_tsklock);
 		goto out;
 	}
 
-	CE_NOTIFY(&ct_taskclass, event, newcls, tsk);
-
 	spin_unlock(&tsk->ckrm_tsklock);
 
       rc_handling:
 	clstype = &ct_taskclass;
 	if (clstype->bit_res_ctlrs) {
@@ -230,102 +228,10 @@ static void tc_add_resctrl(struct ckrm_c
 						  core->res_class[resid]);
 	}
 	class_unlock(core);
 }
 
-/**************************************************************************
- *                   Functions called from classification points          *
- **************************************************************************/
-
-#define CE_CLASSIFY_TASK(event, tsk)					\
-do {									\
-	struct ckrm_task_class *newcls = NULL;				\
- 	struct ckrm_task_class *oldcls = tsk->taskclass;		\
-									\
-	CE_CLASSIFY_RET(newcls,&ct_taskclass,event,tsk);		\
-	if (newcls) {							\
-		/* called synchrously. no need to get task struct */	\
-		ckrm_set_taskclass(tsk, newcls, oldcls, event);		\
-	}								\
-} while (0)
-
-
-#define CE_CLASSIFY_TASK_PROTECT(event, tsk)	\
-do {						\
-	ce_protect(&ct_taskclass);		\
-	CE_CLASSIFY_TASK(event,tsk);		\
-	ce_release(&ct_taskclass);              \
-} while (0)
-
-static void cb_taskclass_newtask(void *tsk1)
-{
-	struct task_struct *tsk = (struct task_struct *)tsk1;
-
-	tsk->taskclass = NULL;
-	INIT_LIST_HEAD(&tsk->taskclass_link);
-}
-
-static void cb_taskclass_fork(void *tsk1)
-{
-	struct task_struct *tsk = (struct task_struct *)tsk1;
-	struct ckrm_task_class *cls = NULL;
-
-	pr_debug("%p:%d:%s\n", tsk, tsk->pid, tsk->comm);
-
-	ce_protect(&ct_taskclass);
-	CE_CLASSIFY_RET(cls, &ct_taskclass, CKRM_EVENT_FORK, tsk);
-	if (cls == NULL) {
-		spin_lock(&tsk->parent->ckrm_tsklock);
-		cls = tsk->parent->taskclass;
-		ckrm_core_grab(class_core(cls));
-		spin_unlock(&tsk->parent->ckrm_tsklock);
-	}
-	if (!list_empty(&tsk->taskclass_link))
-		pr_debug("cb_taskclass_fork: BUG in cb_fork.. tsk (%s:%d> already linked\n",
-		       tsk->comm, tsk->pid);
-
-	ckrm_set_taskclass(tsk, cls, NULL, CKRM_EVENT_FORK);
-	ce_release(&ct_taskclass);
-}
-
-static void cb_taskclass_exit(void *tsk1)
-{
-	struct task_struct *tsk = (struct task_struct *)tsk1;
-
-	CE_CLASSIFY_NORET(&ct_taskclass, CKRM_EVENT_EXIT, tsk);
-	ckrm_set_taskclass(tsk, TASK_EXIT_CLASS, NULL, CKRM_EVENT_EXIT);
-}
-
-static void cb_taskclass_exec(void *filename)
-{
-	pr_debug("%p:%d:%s <%s>\n", current, current->pid, current->comm,
-		   (const char *)filename);
-	CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_EXEC, current);
-}
-
-static void cb_taskclass_uid(void *arg)
-{
-	pr_debug("%p:%d:%s\n", current, current->pid, current->comm);
-	CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_UID, current);
-}
-
-static void cb_taskclass_gid(void *arg)
-{
-	pr_debug("%p:%d:%s\n", current, current->pid, current->comm);
-	CE_CLASSIFY_TASK_PROTECT(CKRM_EVENT_GID, current);
-}
-
-static struct ckrm_event_spec taskclass_events_callbacks[] = {
-	{CKRM_EVENT_NEWTASK, { cb_taskclass_newtask, NULL}},
-	{CKRM_EVENT_EXEC, { cb_taskclass_exec, NULL }},
-	{CKRM_EVENT_FORK, { cb_taskclass_fork, NULL }},
-	{CKRM_EVENT_EXIT, { cb_taskclass_exit, NULL }},
-	{CKRM_EVENT_UID, { cb_taskclass_uid, NULL }},
-	{CKRM_EVENT_GID, { cb_taskclass_gid, NULL }},
-	{-1, { NULL, NULL }}
-};
-
 /*
  * Asynchronous callback functions   (driven by RCFS)
  *
  *    Async functions force a setting of the task structure
  *    synchronous callbacks are protected against race conditions
@@ -333,141 +239,16 @@ static struct ckrm_event_spec taskclass_
  *    Async calls need to be serialized to ensure they can't
  *    race against each other
  */
 
 static DECLARE_MUTEX(ckrm_async_serializer);	/* serialize all async functions */
-
-/*
- * Go through the task list and reclassify all tasks according to the current
- * classification rules.
- *
- * We have the problem that we can not hold any lock (including the
- * tasklist_lock) while classifying. Two methods possible
- *
- * (a) go through entire pidrange (0..pidmax) and if a task exists at
- *     that pid then reclassify it
- * (b) go several time through task list and build a bitmap for a particular
- *     subrange of pid otherwise the memory requirements ight be too much.
- *
- * We use a hybrid by comparing ratio nr_threads/pidmax
- */
-
-static int ckrm_reclassify_all_tasks(void)
-{
-	extern int pid_max;
-
-	struct task_struct *proc, *thread;
-	int i;
-	int curpidmax = pid_max;
-	int ratio;
-	int use_bitmap;
-
-	/* Check permissions */
-	if ((!capable(CAP_SYS_NICE)) && (!capable(CAP_SYS_RESOURCE))) {
-		return -EPERM;
-	}
-
-	ratio = curpidmax / nr_threads;
-	if (curpidmax <= PID_MAX_DEFAULT) {
-		use_bitmap = 1;
-	} else {
-		use_bitmap = (ratio >= 2);
-	}
-
-	ce_protect(&ct_taskclass);
-
-      retry:
-
-	if (use_bitmap == 0) {
-		/* Go through it in one walk. */
-		read_lock(&tasklist_lock);
-		for (i = 0; i < curpidmax; i++) {
-			if ((thread = find_task_by_pid(i)) == NULL)
-				continue;
-			get_task_struct(thread);
-			read_unlock(&tasklist_lock);
-			CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY, thread);
-			put_task_struct(thread);
-			read_lock(&tasklist_lock);
-		}
-		read_unlock(&tasklist_lock);
-	} else {
-		unsigned long *bitmap;
-		int bitmapsize;
-		int order = 0;
-		int num_loops;
-		int pid, do_next;
-
-		bitmap = (unsigned long *)__get_free_pages(GFP_KERNEL, order);
-		if (bitmap == NULL) {
-			use_bitmap = 0;
-			goto retry;
-		}
-
-		bitmapsize = 8 * (1 << (order + PAGE_SHIFT));
-		num_loops = (curpidmax + bitmapsize - 1) / bitmapsize;
-
-		do_next = 1;
-		for (i = 0; i < num_loops && do_next; i++) {
-			int pid_start = i * bitmapsize;
-			int pid_end = pid_start + bitmapsize;
-			int num_found = 0;
-			int pos;
-
-			memset(bitmap, 0, bitmapsize / 8);	/* start afresh */
-			do_next = 0;
-
-			read_lock(&tasklist_lock);
-			do_each_thread(proc, thread) {
-				pid = thread->pid;
-				if ((pid < pid_start) || (pid >= pid_end)) {
-					if (pid >= pid_end) {
-						do_next = 1;
-					}
-					continue;
-				}
-				pid -= pid_start;
-				set_bit(pid, bitmap);
-				num_found++;
-			}
-			while_each_thread(proc, thread);
-			read_unlock(&tasklist_lock);
-
-			if (num_found == 0)
-				continue;
-
-			pos = 0;
-			for (; num_found--;) {
-				pos = find_next_bit(bitmap, bitmapsize, pos);
-				pid = pos + pid_start;
-
-				read_lock(&tasklist_lock);
-				if ((thread = find_task_by_pid(pid)) != NULL) {
-					get_task_struct(thread);
-					read_unlock(&tasklist_lock);
-					CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY,
-							 thread);
-					put_task_struct(thread);
-				} else {
-					read_unlock(&tasklist_lock);
-				}
-				pos++;
-			}
-		}
-
-	}
-	ce_release(&ct_taskclass);
-	return 0;
-}
-
 /*
  * Reclassify all tasks in the given core class.
  */
 
 static void ckrm_reclassify_class_tasks(struct ckrm_task_class *cls)
 {
-	int ce_regd;
 	struct ckrm_hnode *cnode;
 	struct ckrm_task_class *parcls;
 	int num = 0;
 
 	if (!ckrm_validate_and_grab_core(&cls->core))
@@ -475,53 +256,34 @@ static void ckrm_reclassify_class_tasks(
 
 	down(&ckrm_async_serializer);
 	pr_debug("start %p:%s:%d:%d\n", cls, cls->core.name,
 		 atomic_read(&cls->core.refcnt),
 		 atomic_read(&cls->core.hnode.parent->refcnt));
-	/*
-	 * If no CE registered for this classtype, following will be needed
-	 * repeatedly.
-	 */
-	ce_regd = atomic_read(&class_core(cls)->classtype->ce_regd);
 	cnode = &(class_core(cls)->hnode);
 	parcls = class_type(struct ckrm_task_class, cnode->parent);
 
-      next_task:
-	class_lock(class_core(cls));
-	if (!list_empty(&class_core(cls)->objlist)) {
+	do {
 		struct ckrm_task_class *newcls = NULL;
-		struct task_struct *tsk =
-		    list_entry(class_core(cls)->objlist.next,
-			       struct task_struct, taskclass_link);
+		struct task_struct *tsk = NULL;
+
+		class_lock(class_core(cls));
+		if (list_empty(&class_core(cls)->objlist))
+			break;
+		tsk = list_entry(class_core(cls)->objlist.next,
+				 struct task_struct, taskclass_link);
 
 		get_task_struct(tsk);
 		class_unlock(class_core(cls));
 
-		if (ce_regd) {
-			CE_CLASSIFY_RET(newcls, &ct_taskclass,
-					CKRM_EVENT_RECLASSIFY, tsk);
-			if (cls == newcls) {
-				/*
-				 * Don't allow reclassifying to the same class
-				 * as we are in the process of cleaning up
-				 * this class
-				 */
-
-				/* compensate for CE's grab */
-				ckrm_core_drop(class_core(newcls));
-				newcls = NULL;
-			}
-		}
 		if (newcls == NULL) {
 			newcls = parcls;
 			ckrm_core_grab(class_core(newcls));
 		}
-		ckrm_set_taskclass(tsk, newcls, cls, CKRM_EVENT_RECLASSIFY);
+		ckrm_set_taskclass(tsk, newcls, cls);
 		put_task_struct(tsk);
 		num++;
-		goto next_task;
-	}
+	} while (1);
 	pr_debug("stop  %p:%s:%d:%d   %d\n", cls, cls->core.name,
 		 atomic_read(&cls->core.refcnt),
 		 atomic_read(&cls->core.hnode.parent->refcnt), num);
 	class_unlock(class_core(cls));
 	ckrm_core_drop(class_core(cls));
@@ -559,17 +321,11 @@ int ckrm_forced_reclassify_pid(pid_t pid
 			ckrm_core_drop(class_core(cls));
 		put_task_struct(tsk);
 		return -EPERM;
 	}
 
-	ce_protect(&ct_taskclass);
-	if (cls == NULL)
-		CE_CLASSIFY_TASK(CKRM_EVENT_RECLASSIFY,tsk);
-	else
-		ckrm_set_taskclass(tsk, cls, NULL, CKRM_EVENT_MANUAL);
-
-	ce_release(&ct_taskclass);
+	ckrm_set_taskclass(tsk, cls, NULL);
 	put_task_struct(tsk);
 
 	return 0;
 }
 
@@ -578,20 +334,11 @@ static struct ckrm_core_class *ckrm_allo
 {
 	struct ckrm_task_class *taskcls;
 	taskcls = kmalloc(sizeof(struct ckrm_task_class), GFP_KERNEL);
 	if (taskcls == NULL)
 		return NULL;
-	memset(taskcls, 0, sizeof(struct ckrm_task_class));
-
 	ckrm_init_core_class(&ct_taskclass, class_core(taskcls), parent, name);
-
-	ce_protect(&ct_taskclass);
-	if (ct_taskclass.ce_cb_active && ct_taskclass.ce_callbacks.class_add)
-		(*ct_taskclass.ce_callbacks.class_add) (name, taskcls,
-							ct_taskclass.type_id);
-	ce_release(&ct_taskclass);
-
 	return class_core(taskcls);
 }
 
 static int ckrm_free_task_class(struct ckrm_core_class *core)
 {
@@ -607,43 +354,49 @@ static int ckrm_free_task_class(struct c
 	}
 
 	pr_debug("%p:%s:%d\n", core, core->name, atomic_read(&core->refcnt));
 
 	taskcls = class_type(struct ckrm_task_class, core);
-
-	ce_protect(&ct_taskclass);
-
-	if (ct_taskclass.ce_cb_active && ct_taskclass.ce_callbacks.class_delete)
-		(*ct_taskclass.ce_callbacks.class_delete) (core->name, taskcls,
-							   ct_taskclass.type_id);
 	ckrm_reclassify_class_tasks(taskcls);
-
-	ce_release(&ct_taskclass);
-
 	ckrm_release_core_class(core);
 	return 0;
 }
 
+void ckrm_init_task_struct (struct task_struct *tsk)
+{
+	tsk->ckrm_tsklock = SPIN_LOCK_UNLOCKED;
+	tsk->taskclass = NULL;
+	INIT_LIST_HEAD(&tsk->taskclass_link);
+}
+
+void ckrm_dup_task_struct (struct task_struct *dst,
+			   struct task_struct *src)
+{
+	ckrm_init_task_struct(dst);
+}
+
 void __init ckrm_meta_init_taskclass(void)
 {
 	pr_debug("...... Initializing ClassType<%s> ........\n",
 	       ct_taskclass.name);
+
+
 	/* intialize the default class */
 	ckrm_init_core_class(&ct_taskclass, class_core(&taskclass_dflt_class),
 			     NULL, dflt_taskclass_name);
 
 	/* register classtype and initialize default task class */
 	ckrm_register_classtype(&ct_taskclass);
-	ckrm_register_event_set(taskclass_events_callbacks);
 
 	/*
 	 * note registeration of all resource controllers will be done
 	 * later dynamically as these are specified as modules
 	 */
 
 	/* prepare init_task and then rely on inheritance of properties */
-	ckrm_set_taskclass(&init_task, NULL, NULL, CKRM_EVENT_NEWTASK);
+	ckrm_init_task_struct(&init_task);
+	ckrm_set_taskclass(&init_task, NULL, NULL);
 }
 
 static int tc_show_members(struct ckrm_core_class *core, struct seq_file *seq)
 {
 	struct list_head *lh;
@@ -669,11 +422,11 @@ static int tc_forced_reclassify(struct c
 	down(&ckrm_async_serializer);	/* protect against race with reclassify_class */
 	if (pid < 0) {
 		/* TBD: We could treat this as a process group. */
 		rc = -EINVAL;
 	} else if (pid == 0) {
-		rc = (target == NULL) ? ckrm_reclassify_all_tasks() : -EINVAL;
+		rc = -EINVAL;
 	} else {
 		struct ckrm_task_class *cls = NULL;
 		if (target)
 			cls = class_type(struct ckrm_task_class, target);
 		rc = ckrm_forced_reclassify_pid(pid,cls);
Index: linux-2.6.13-rc6/kernel/exit.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/exit.c
+++ linux-2.6.13-rc6/kernel/exit.c
@@ -25,11 +25,10 @@
 #include <linux/mount.h>
 #include <linux/proc_fs.h>
 #include <linux/mempolicy.h>
 #include <linux/cpuset.h>
 #include <linux/syscalls.h>
-#include <linux/ckrm_events.h>
 #include <linux/signal.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 #include <asm/pgtable.h>
@@ -659,12 +658,10 @@ static void exit_notify(struct task_stru
 {
 	int state;
 	struct task_struct *t;
 	struct list_head ptrace_dead, *_p, *_n;
 
-	ckrm_cb_exit(tsk);
-
 	if (signal_pending(tsk) && !(tsk->signal->flags & SIGNAL_GROUP_EXIT)
 	    && !thread_group_empty(tsk)) {
 		/*
 		 * This occurs when there was a race between our exit
 		 * syscall and a group signal choosing us as the one to
Index: linux-2.6.13-rc6/kernel/fork.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/fork.c
+++ linux-2.6.13-rc6/kernel/fork.c
@@ -39,13 +39,12 @@
 #include <linux/mount.h>
 #include <linux/audit.h>
 #include <linux/profile.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
-#include <linux/ckrm_events.h>
-#include <linux/ckrm_tsk.h>
 #include <linux/ckrm_tc.h>
+#include <linux/ckrm_tsk.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -175,11 +174,12 @@ static struct task_struct *dup_task_stru
 	*ti = *orig->thread_info;
 	*tsk = *orig;
 	tsk->thread_info = ti;
 	ti->task = tsk;
 
-	ckrm_cb_newtask(tsk);
+	ckrm_dup_task_struct(tsk, orig);
+
 	/* One for us, one for whoever does the "release_task()" (usually parent) */
 	atomic_set(&tsk->usage,2);
 	return tsk;
 }
 
@@ -1227,20 +1227,19 @@ long do_fork(unsigned long clone_flags,
 	}
 
 	if (numtasks_get_ref(&current->taskclass->core, 0) == 0) {
 		return -ENOMEM;
 	}
-	p = copy_process(clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);
+	p = copy_process(clone_flags, stack_start, regs,
+			 stack_size, parent_tidptr, child_tidptr, pid);
 	/*
 	 * Do this prior waking up the new thread - the thread pointer
 	 * might get invalid after that point, if the thread exits quickly.
 	 */
 	if (!IS_ERR(p)) {
 		struct completion vfork;
 
-		ckrm_cb_fork(p);
-
 		if (clone_flags & CLONE_VFORK) {
 			p->vfork_done = &vfork;
 			init_completion(&vfork);
 		}
 
Index: linux-2.6.13-rc6/init/main.c
===================================================================
--- linux-2.6.13-rc6.orig/init/main.c
+++ linux-2.6.13-rc6/init/main.c
@@ -45,11 +45,11 @@
 #include <linux/efi.h>
 #include <linux/unistd.h>
 #include <linux/rmap.h>
 #include <linux/mempolicy.h>
 #include <linux/key.h>
-#include <linux/ckrm_events.h>
+#include <linux/ckrm.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
Index: linux-2.6.13-rc6/fs/exec.c
===================================================================
--- linux-2.6.13-rc6.orig/fs/exec.c
+++ linux-2.6.13-rc6/fs/exec.c
@@ -46,11 +46,10 @@
 #include <linux/mount.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
-#include <linux/ckrm_events.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
 
 #ifdef CONFIG_KMOD
@@ -1103,11 +1102,10 @@ int search_binary_handler(struct linux_b
 				allow_write_access(bprm->file);
 				if (bprm->file)
 					fput(bprm->file);
 				bprm->file = NULL;
 				current->did_exec = 1;
-				ckrm_cb_exec(bprm->filename);
 				return retval;
 			}
 			read_lock(&binfmt_lock);
 			put_binfmt(fmt);
 			if (retval != -ENOEXEC || bprm->mm == NULL)
Index: linux-2.6.13-rc6/kernel/sys.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/sys.c
+++ linux-2.6.13-rc6/kernel/sys.c
@@ -29,11 +29,10 @@
 #include <linux/tty.h>
 #include <linux/signal.h>
 
 #include <linux/compat.h>
 #include <linux/syscalls.h>
-#include <linux/ckrm_events.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/unistd.h>
 
@@ -582,11 +581,10 @@ asmlinkage long sys_setregid(gid_t rgid,
 		current->sgid = new_egid;
 	current->fsgid = new_egid;
 	current->egid = new_egid;
 	current->gid = new_rgid;
 	key_fsgid_changed(current);
-	ckrm_cb_gid();
 	return 0;
 }
 
 /*
  * setgid() is implemented like SysV w/ SAVED_IDS 
@@ -622,11 +620,10 @@ asmlinkage long sys_setgid(gid_t gid)
 	}
 	else
 		return -EPERM;
 
 	key_fsgid_changed(current);
-	ckrm_cb_gid();
 	return 0;
 }
   
 static int set_user(uid_t new_ruid, int dumpclear)
 {
@@ -712,13 +709,10 @@ asmlinkage long sys_setreuid(uid_t ruid,
 	    (euid != (uid_t) -1 && euid != old_ruid))
 		current->suid = current->euid;
 	current->fsuid = current->euid;
 
 	key_fsuid_changed(current);
-
-	ckrm_cb_uid();
-
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RE);
 }
 
 
 		
@@ -761,13 +755,10 @@ asmlinkage long sys_setuid(uid_t uid)
 	}
 	current->fsuid = current->euid = uid;
 	current->suid = new_suid;
 
 	key_fsuid_changed(current);
-
-	ckrm_cb_uid();
-
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID);
 }
 
 
 /*
@@ -811,13 +802,10 @@ asmlinkage long sys_setresuid(uid_t ruid
 	current->fsuid = current->euid;
 	if (suid != (uid_t) -1)
 		current->suid = suid;
 
 	key_fsuid_changed(current);
-
-	ckrm_cb_uid();
-
 	return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES);
 }
 
 asmlinkage long sys_getresuid(uid_t __user *ruid, uid_t __user *euid, uid_t __user *suid)
 {
@@ -865,11 +853,10 @@ asmlinkage long sys_setresgid(gid_t rgid
 		current->gid = rgid;
 	if (sgid != (gid_t) -1)
 		current->sgid = sgid;
 
 	key_fsgid_changed(current);
-	ckrm_cb_gid();
 	return 0;
 }
 
 asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid)
 {
Index: linux-2.6.13-rc6/net/ipv4/tcp.c
===================================================================
--- linux-2.6.13-rc6.orig/net/ipv4/tcp.c
+++ linux-2.6.13-rc6/net/ipv4/tcp.c
@@ -261,12 +261,10 @@
 #include <net/icmp.h>
 #include <net/tcp.h>
 #include <net/xfrm.h>
 #include <net/ip.h>
 
-#include <linux/ckrm_events.h>
-
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 
 int sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
 
@@ -481,11 +479,10 @@ int tcp_listen_start(struct sock *sk)
 	if (!sk->sk_prot->get_port(sk, inet->num)) {
 		inet->sport = htons(inet->num);
 
 		sk_dst_reset(sk);
 		sk->sk_prot->hash(sk);
-		ckrm_cb_listen_start(sk);
 		return 0;
 	}
 
 	sk->sk_state = TCP_CLOSE;
 	reqsk_queue_destroy(&tp->accept_queue);
@@ -509,12 +506,10 @@ static void tcp_listen_stop (struct sock
 
 	/* make all the listen_opt local to us */
 	lopt = reqsk_queue_yank_listen_sk(&tp->accept_queue);
 	acc_req = reqsk_queue_yank_acceptq(&tp->accept_queue);
 
-	ckrm_cb_listen_stop(sk);
-
 	if (lopt->qlen) {
 		for (i = 0; i < TCP_SYNQ_HSIZE; i++) {
 			while ((req = lopt->syn_table[i]) != NULL) {
 				lopt->syn_table[i] = req->dl_next;
 				lopt->qlen--;
Index: linux-2.6.13-rc6/kernel/ckrm/ckrm_sockc.c
===================================================================
--- linux-2.6.13-rc6.orig/kernel/ckrm/ckrm_sockc.c
+++ linux-2.6.13-rc6/kernel/ckrm/ckrm_sockc.c
@@ -114,11 +114,11 @@ void ckrm_ns_put(struct ckrm_net_struct 
  *
  */
 
 static void
 ckrm_sock_set_class(struct ckrm_net_struct *ns, struct ckrm_sock_class *newcls,
-	       struct ckrm_sock_class *oldcls, enum ckrm_event event)
+	       struct ckrm_sock_class *oldcls)
 {
 	int i;
 	struct ckrm_res_ctlr *rcbs;
 	struct ckrm_classtype *clstype;
 	void *old_res_class, *new_res_class;
@@ -203,19 +203,12 @@ static void cb_sockclass_listen_start(vo
 	ns->ns_dport = inet_sk(sk)->num;
 
 	ns->ns_pid = current->pid;
 	ns->ns_tgid = current->tgid;
 	ns->ns_tsk = current;
-	ce_protect(&ct_sockclass);
-	CE_CLASSIFY_RET(newcls, &ct_sockclass, CKRM_EVENT_LISTEN_START, ns,
-			current);
-	ce_release(&ct_sockclass);
-
-	if (newcls == NULL) {
-		newcls = &ckrm_sockclass_dflt_class;
-		ckrm_core_grab(class_core(newcls));
-	}
+	newcls = &ckrm_sockclass_dflt_class;
+	ckrm_core_grab(class_core(newcls));
 
 	class_lock(class_core(newcls));
 	list_add(&ns->ckrm_link, &class_core(newcls)->objlist);
 	ns->core = newcls;
 	class_unlock(class_core(newcls));
@@ -273,16 +266,10 @@ static void cb_sockclass_listen_stop(voi
 	// Should be the last count and free it
 	ckrm_ns_put(ns);
 	return;
 }
 
-static struct ckrm_event_spec ckrm_sock_events_callbacks[] = {
-	{CKRM_EVENT_LISTEN_START, {cb_sockclass_listen_start, NULL}},
-	{CKRM_EVENT_LISTEN_STOP, {cb_sockclass_listen_stop, NULL}},
-	{-1, {NULL, NULL}}
-};
-
 /**************************************************************************
  *                  Class Object Creation / Destruction
  **************************************************************************/
 
 static struct ckrm_core_class *ckrm_sock_alloc_class(struct ckrm_core_class *parent,
@@ -293,17 +280,10 @@ static struct ckrm_core_class *ckrm_sock
 	if (sockcls == NULL)
 		return NULL;
 	memset(sockcls, 0, sizeof(struct ckrm_sock_class));
 
 	ckrm_init_core_class(&ct_sockclass, class_core(sockcls), parent, name);
-
-	ce_protect(&ct_sockclass);
-	if (ct_sockclass.ce_cb_active && ct_sockclass.ce_callbacks.class_add)
-		(*ct_sockclass.ce_callbacks.class_add) (name, sockcls,
-							ct_sockclass.type_id);
-	ce_release(&ct_sockclass);
-
 	return class_core(sockcls);
 }
 
 static int ckrm_sock_free_class(struct ckrm_core_class *core)
 {
@@ -319,20 +299,11 @@ static int ckrm_sock_free_class(struct c
 		return 0;
 	}
 
 	sockcls = class_type(struct ckrm_sock_class, core);
 
-	ce_protect(&ct_sockclass);
-
-	if (ct_sockclass.ce_cb_active && ct_sockclass.ce_callbacks.class_delete)
-		(*ct_sockclass.ce_callbacks.class_delete) (core->name, sockcls,
-							   ct_sockclass.type_id);
-
 	ckrm_sock_reclassify_class(sockcls);
-
-	ce_release(&ct_sockclass);
-
 	ckrm_release_core_class(core);
 	/* Could just drop the class?  Error message? */
 
 	return 0;
 }
@@ -402,11 +373,11 @@ ckrm_sock_forced_reclassify_ns(struct ck
 	list_del(&ns->ckrm_link);
 	INIT_LIST_HEAD(&ns->ckrm_link);
 	ns->core = NULL;
 	class_unlock(class_core(oldcls));
 
-	ckrm_sock_set_class(ns, newcls, oldcls, CKRM_EVENT_MANUAL);
+	ckrm_sock_set_class(ns, newcls, oldcls);
 	ckrm_ns_put(ns);
 	rc = 0;
       out:
 	release_sock(sk);
 	sock_put(sk);
@@ -529,16 +500,17 @@ static void ckrm_sock_reclassify_class(s
 	ckrm_core_drop(core);
 
 	list_for_each_entry_safe(ns, tns, &local_list, ckrm_link) {
 		ckrm_ns_hold(ns);
 		list_del(&ns->ckrm_link);
-		if (ns->ns_sk) {
-			lock_sock(ns->ns_sk);
-			ckrm_sock_set_class(ns, &ckrm_sockclass_dflt_class, NULL,
-				       CKRM_EVENT_MANUAL);
-			release_sock(ns->ns_sk);
+		if (!ns->ns_sk) {
+			ckrm_ns_put(ns);
+			continue;
 		}
+		lock_sock(ns->ns_sk);
+		ckrm_sock_set_class(ns, &ckrm_sockclass_dflt_class, NULL);
+		release_sock(ns->ns_sk);
 		ckrm_ns_put(ns);
 	}
 	return;
 }
 
@@ -550,11 +522,10 @@ void __init ckrm_meta_init_sockclass(voi
 	ckrm_init_core_class(&ct_sockclass, class_core(&ckrm_sockclass_dflt_class),
 			     NULL, dflt_sockclass_name);
 
 	/* register classtype and initialize default task class */
 	ckrm_register_classtype(&ct_sockclass);
-	ckrm_register_event_set(ckrm_sock_events_callbacks);
 
 	/*
 	 * note registeration of all resource controllers will be done
 	 * later dynamically as these are specified as modules
 	 */
Index: linux-2.6.13-rc6/include/linux/ckrm_tc.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/ckrm_tc.h
+++ linux-2.6.13-rc6/include/linux/ckrm_tc.h
@@ -27,20 +27,34 @@
 
 struct ckrm_task_class {
 	struct ckrm_core_class core;
 };
 
+extern void ckrm_init_task_struct (struct task_struct *tsk);
+extern void ckrm_dup_task_struct(struct task_struct *dst,
+				 struct task_struct *src);
+
 /*
  * Index into genmfdesc array, defined in rcfs/dir_modules.c,
  * which has the mfdesc entry that taskclass wants to use.
  */
 #define TC_MF_IDX  0
 
-extern int ckrm_forced_reclassify_pid(int, struct ckrm_task_class *);
+extern int ckrm_forced_reclassify_pid(pid_t, struct ckrm_task_class *);
 
 #else /* CONFIG_CKRM_TYPE_TASKCLASS */
 
-#define ckrm_forced_reclassify_pid(a, b) (0)
+inline int ckrm_forced_reclassify_pid(pid_t pid, void *classp)
+{
+	return 0;
+}
+
+static inline void ckrm_init_task_struct (struct task_struct *tsk)
+{}
+
+static inline void ckrm_dup_task_struct(struct task_struct *dst,
+       					struct task_struct *src)
+{}
 
-#endif
+#endif /* CONFIG_CKRM_TYPE_TASKCLASS */
 
 #endif /* _LINUX_CKRM_TC_H_ */
Index: linux-2.6.13-rc6/include/linux/ckrm.h
===================================================================
--- /dev/null
+++ linux-2.6.13-rc6/include/linux/ckrm.h
@@ -0,0 +1,47 @@
+/*
+ *  ckrm.h - Header file to be used by CKRM
+ *
+ * Copyright (C) Matt Helsley, IBM Corp. 2005
+ *
+ * Provides data structures, macros and kernel API of CKRM for
+ * resource controllers.
+ *
+ * More details at http://ckrm.sf.net
+ *
+ * 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.
+ *
+ */
+
+#ifndef _LINUX_CKRM_H
+#define _LINUX_CKRM_H
+#ifdef CONFIG_CKRM
+extern void ckrm_init(void);
+#include <linux/ckrm_rc.h>
+
+extern void ckrm_init_task_struct (struct task_struct *tsk);
+extern void ckrm_dup_task_struct(struct task_struct *dst,
+				 struct task_struct *src);
+
+extern int ckrm_forced_reclassify_pid(pid_t, struct ckrm_core_class *);
+
+#else
+/* !CONFIG_CKRM */
+
+inline int ckrm_forced_reclassify_pid(pid_t pid, void *classp)
+{
+	return 0;
+}
+
+static inline void ckrm_init_task_struct (struct task_struct *tsk)
+{}
+
+static inline void ckrm_dup_task_struct(struct task_struct *dst,
+       					struct task_struct *src)
+{}
+
+#define ckrm_init() do { } while(0)
+#endif /* CONFIG_CKRM */
+#endif /* _LINUX_CKRM_H */
Index: linux-2.6.13-rc6/include/linux/sched.h
===================================================================
--- linux-2.6.13-rc6.orig/include/linux/sched.h
+++ linux-2.6.13-rc6/include/linux/sched.h
@@ -540,22 +540,10 @@ struct sched_domain {
 	/* try_to_wake_up() stats */
 	unsigned long ttwu_wake_remote;
 	unsigned long ttwu_move_affine;
 	unsigned long ttwu_move_balance;
 #endif
-#ifdef CONFIG_DELAY_ACCT
-	struct task_delay_info delays;
-#endif
-#ifdef CONFIG_CKRM
-	spinlock_t  ckrm_tsklock;
-	void       *ce_data;
-#ifdef CONFIG_CKRM_TYPE_TASKCLASS
-	struct ckrm_task_class *taskclass;
-	struct list_head taskclass_link;
-#endif /* CONFIG_CKRM_TYPE_TASKCLASS */
-#endif /* CONFIG_CKRM */
-
 };
 
 extern void partition_sched_domains(cpumask_t *partition1,
 				    cpumask_t *partition2);
 #ifdef ARCH_HAS_SCHED_DOMAIN
@@ -781,10 +769,21 @@ struct task_struct {
 	struct cpuset *cpuset;
 	nodemask_t mems_allowed;
 	int cpuset_mems_generation;
 #endif
 	atomic_t fs_excl;	/* holding fs exclusive resources */
+
+#ifdef CONFIG_DELAY_ACCT
+	struct task_delay_info delays;
+#endif
+#ifdef CONFIG_CKRM
+	spinlock_t  ckrm_tsklock;
+#ifdef CONFIG_CKRM_TYPE_TASKCLASS
+	struct ckrm_task_class *taskclass;
+	struct list_head taskclass_link;
+#endif /* CONFIG_CKRM_TYPE_TASKCLASS */
+#endif /* CONFIG_CKRM */
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
 {
 	return tsk->signal->pgrp;
