summaryrefslogtreecommitdiff
path: root/pid/pid.c
diff options
context:
space:
mode:
author0xwille2011-07-12 20:51:00 +0200
committer0xwille2011-07-12 20:51:00 +0200
commit389cc1ba8d9e673f1313fd966820c6d9d463525f (patch)
tree77bac88a1faa54c28e8d38bcee7485c742680105 /pid/pid.c
parentc8f116e17b471704abbb3b1508733aa1bddda7da (diff)
downloadlkm-389cc1ba8d9e673f1313fd966820c6d9d463525f.tar.gz
AƱadido pid
Diffstat (limited to 'pid/pid.c')
-rw-r--r--pid/pid.c34
1 files changed, 34 insertions, 0 deletions
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");