Since my idea of providing an accounting framework was considered
'overkill', here i submit a tiny patch just to allow CSA to
handle end-of-process (eop) situation by saving off accounting
data before a task_struct is disposed.

This patch is to modify the acct_process() in acct.c, which is
invoked from do_exit() to handle eop for BSD accounting. Now
the acct_process() wrapper will also take care of CSA, if it has
been loaded. If the CSA module has been loaded, a CSA routine
will be invoked to construct a CSA job record and to write the
record to the CSA accounting file.

This patch only touchs one file: kernel/acct.c.

Signed-off-by: Jay Lan <[EMAIL PROTECTED]>


Index: linux/kernel/acct.c
===================================================================
--- linux.orig/kernel/acct.c    2005-02-24 15:55:05.519092861 -0800
+++ linux/kernel/acct.c 2005-02-24 16:33:56.381584083 -0800
@@ -73,6 +73,11 @@ int acct_parm[3] = {4, 2, 30};
 /*
  * External references and all of the globals.
  */
+
+/* do_exit hook used by CSA */
+void (*do_exit_csa)(int, struct task_struct *) = NULL;
+EXPORT_SYMBOL_GPL(do_exit_csa);
+
 static void do_acct_process(long, struct file *);
 
 /*
@@ -504,12 +509,17 @@ static void do_acct_process(long exitcod
 }
 
 /*
- * acct_process - now just a wrapper around do_acct_process
+ * acct_process - now just a wrapper around
+ *     do_acct_process - for BSD accounting
+ *     do_exit_csa     - for CSA
  */
 void acct_process(long exitcode)
 {
        struct file *file = NULL;
 
+       if (do_exit_csa != NULL)
+               do_exit_csa(exitcode, current);
+
        /*
         * accelerate the common fastpath:
         */

Reply via email to