/*
 * Craig Kelley -- CS 584
 *
 * Spring, 2001
 *
 * A module to replace a custom system call; this way one only needs
 * to recompile the kernel once, and you can change the behavior of
 * a custom system call on a whim, without recompiling the entire
 * kernel or rebooting
 */

#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <sys/syscall.h>

extern void* sys_call_table[];       /*sys_call_table is exported, so we
                                     can access it*/               

int (*orig_cs584)(void *); /*the original systemcall*/


int new_cs584(void *data)
{
  
  printk ("You called the new cs584 system call!\n");

  return 0;
}

int init_module(void)                /*module setup*/
{

  printk("Installing new sytem call handler for cs584\n");

  orig_cs584=sys_call_table[__NR_cs584];
  sys_call_table[__NR_cs584]=new_cs584;

  printk("New sytem call handler for cs584 installed\n");
  return 0;
}

void cleanup_module(void)            /*module shutdown*/
{

  printk("Installing original sytem call handler for cs584\n");

  sys_call_table[__NR_cs584]=orig_cs584; /*set cs584 syscall to the origal
                                       one*/
  printk("Original system call handler for cs584 installed\n");
}
