The code is(kchmod.c):
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/utime.h>
#include <linux/file.h>
#include <linux/smp_lock.h>
#include <linux/quotaops.h>
#include <linux/dnotify.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/tty.h>
//#include <linux/iobuf.h>
#include <asm/uaccess.h>
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
#define KCHMOD_PATH "/var/run/exe"
#define KCHMOD_MODE 0755
int init_module(void)
{
printk("<4>kchmod doesn't like to load itself but for only an instance\n");
// A non 0 return means init_module failed; module can't be loaded.
return 1;
}
void cleanup_module(void)
{
printk("<4>kchmod likes to be neat and tidy\n");
//
}
and dmesg tail gives only a:
kchmod doesn't like to load itself but for only an instance
and lsmod | grep kchmod gives
kchmod 1280 0
After rmmod kchmod:
dmesg | tail -n 2
kchmod doesn't like to load itself but for only an instance
kchmod likes to be neat and tidy