diff options
author | 0xwille | 2011-07-12 20:51:00 +0200 |
---|---|---|
committer | 0xwille | 2011-07-12 20:51:00 +0200 |
commit | 389cc1ba8d9e673f1313fd966820c6d9d463525f (patch) | |
tree | 77bac88a1faa54c28e8d38bcee7485c742680105 /pid | |
parent | c8f116e17b471704abbb3b1508733aa1bddda7da (diff) | |
download | lkm-389cc1ba8d9e673f1313fd966820c6d9d463525f.tar.gz |
AƱadido pid
Diffstat (limited to 'pid')
-rw-r--r-- | pid/Makefile | 7 | ||||
-rw-r--r-- | pid/pid.c | 34 |
2 files changed, 41 insertions, 0 deletions
diff --git a/pid/Makefile b/pid/Makefile new file mode 100644 index 0000000..b9e7cfd --- /dev/null +++ b/pid/Makefile @@ -0,0 +1,7 @@ +obj-m += pid.o + +all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules + +clean: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean diff --git a/pid/pid.c b/pid/pid.c new file mode 100644 index 0000000..b930fe6 --- /dev/null +++ b/pid/pid.c @@ -0,0 +1,34 @@ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/sched.h> + +static char modname[] = "pid.ko"; +static struct task_struct *mytask; +static struct task_struct *parent; + +static int __init init(void) +{ + mytask = current; + printk(KERN_ALERT "%s loaded by %s (%d)\n", + modname, mytask->comm, mytask->pid); + parent = mytask->parent; + while (mytask->pid != parent->pid) { + printk(KERN_ALERT "current: %s (%d) - parent: %s (%d)\n", + mytask->comm, mytask->pid, parent->comm, parent->pid); + mytask = mytask->parent; + parent = mytask->parent; + } + + return 0; +} + +static void __exit exit(void) +{ + printk(KERN_ALERT "%s unloaded\n", modname); +} + +module_init(init); +module_exit(exit); + +MODULE_LICENSE("GPL"); |