]> hackdaworld.org Git - my-code/kernel.git/commitdiff
reorganized things
authorhackbard <hackbard>
Fri, 23 Sep 2005 07:19:35 +0000 (07:19 +0000)
committerhackbard <hackbard>
Fri, 23 Sep 2005 07:19:35 +0000 (07:19 +0000)
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
general.h [deleted file]
hello/Makefile [deleted file]
hello/hello-1.c [deleted file]
hello/hello.c [deleted file]
mproc/Makefile [new file with mode: 0644]
mproc/mproc.c [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..b7d4f29
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+ifneq ($(KERNELRELEASE),)
+       obj-y += hello/
+       obj-y += mproc/
+else
+       KERNELDIR ?= /usr/src/linux
+       PWD := $(shell pwd)
+default:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
+endif
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..1a88352
--- /dev/null
+++ b/README
@@ -0,0 +1,35 @@
+several kernel modules
+----------------------
+
+build:
+******
+
+  - link this directory into the kernel source tree
+
+      example:
+
+        ln -s $PWD /usr/src/linux/driver/misc/foo
+
+  - add a line containing 'obj-y += foo/' to the Makefile
+
+      example:
+
+        echo "obj-y +=foo/" >> /usr/src/linux/driver/misc/Makefile
+
+  - build the modules
+
+      example:
+
+        make 
+
+      or if that doesnt' work ...
+
+        make -C /usr/src/linux SUBDIRS=$PWD modules
+
+
+what is what:
+*************
+
+h3ll0.c        - the hello world kernel module
+mproc.c - process monitor in kernelspace
+
diff --git a/general.h b/general.h
deleted file mode 100644 (file)
index 1974c1a..0000000
--- a/general.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* general stuff */
-
-#define ME_THE_AUTHOR "hackbard/qubit http://hackdaworld.dyndns.org"
-
diff --git a/hello/Makefile b/hello/Makefile
deleted file mode 100644 (file)
index c1f7bfc..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# Makefile of hello.o - my first kernel module.
-
-INCLUDEDIR = /usr/include
-CC = gcc
-CFLAGS = -D__KERNEL__ -DMODULE -O -Wall # -I$(INCLUDEDIR)
-
-# findout kernel version.
-VER = $(shell awk -F\" '/REL/ {print $$2}' $(INCLUDEDIR)/linux/version.h)
-
-OBJS = hello.o hello-1.o
-
-all: $(OBJS)
-
-#hello.o: hello.o
-#      $(LD) -r $^ -o $@
-
-install:
-       install -d /lib/modules/$(VER)/misc
-       install -c hello.o /lib/modules/$(VER)/misc
-
-clean:
-       rm -f *.o *~ core
-
-uninstall:
-       rm -f /lib/modules/$(VER)/misc/hello.o
-
diff --git a/hello/hello-1.c b/hello/hello-1.c
deleted file mode 100644 (file)
index a0d241d..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* hello world */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include "../general.h"
-
-#if CONFIG_MODVERSIONS==1
- #define MODVERSIONS
-#endif
-
-#include <linux/devfs_fs_kernel.h>
-
-#ifndef CONFIG_DEVFS_FS
- #error no devfs
-#endif
-
-#include <sys/syscall.h>
-#include <linux/sched.h>
-
-extern void *sys_call_table[];
-
-static devfs_handle_t devfs_handle; 
-
-static struct file_operations fops = 
-{
- .read=device_read,
- .write=device_write,
- .open=device_open,
- .release=device_release,
- .ioctl=device_ioctl
-}
-
-int my_uid=0;
-char *parm_string="blah";
-
-MODULE_PARM(my_uid,"i");
-MODULE_PARM(parm_string,"s");
-
-int my_init(void)
-{
- devfs_handle=devfs_register(NULL,"hackbard/1",DEVFS_FL_DEFAULT,0,0,
- printk(KERN_ALERT "module loaded with uid %d, string %s\n",my_uid,parm_string);
- return 0;
-}
-
-void my_cleanup(void)
-{
- printk(KERN_ALERT "module unloaded\n");
-}
-
-module_init(my_init);
-module_exit(my_cleanup);
-
-MODULE_AUTHOR(ME_THE_AUTHOR);
-MODULE_DESCRIPTION("bullshit ;)");
-MODULE_LICENSE("GPL");
-
diff --git a/hello/hello.c b/hello/hello.c
deleted file mode 100644 (file)
index cf6bd93..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* my first kernel driver :-) */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-
-int init_module(void) {
-       printk(KERN_ALERT "hi hackbard, here is your kernel speaking! :)\n");
-       printk(KERN_ALERT "some info : %s has process id %i\n",current->comm,
-                                                               current->pid);
-       return 0;
-}
-
-void cleanup_module(void) {
-       printk(KERN_ALERT "bye hackbard ...\n");
-}
-
diff --git a/mproc/Makefile b/mproc/Makefile
new file mode 100644 (file)
index 0000000..fce386d
--- /dev/null
@@ -0,0 +1 @@
+obj-m += mproc.o
diff --git a/mproc/mproc.c b/mproc/mproc.c
new file mode 100644 (file)
index 0000000..4cf0ca4
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * mproc kernel module
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+
+MODULE_LICENSE("GPL");
+
+static int __init mproc_init(void)
+{
+       printk(KERN_INFO "mproc module loaded\n");
+       printk(KERN_INFO "process: %s | pid: %i\n",
+                       current->comm,current->pid);
+       return 0; 
+}
+
+static void __exit mproc_exit(void)
+{
+       printk(KERN_INFO "process: %s | pid: %i\n",
+                       current->comm,current->pid);
+       printk(KERN_INFO "mproc module unloaded\n");
+}
+
+module_init(mproc_init);
+module_exit(mproc_exit);