السلام عليكــم ورحمـة الله وبركاتــه
احاول تعلم كتابة kernel module ،،
نفذت اول برنامج من كتاب Linux Device Drivers
و الذي كان
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
=====================
You can test the module with the insmod and rmmod utilities, as shown below. Note that only the superuser can load and unload a module.
% make
make[1]: Entering directory `/usr/src/linux-2.6.10'
CC [M] /home/ldd3/src/misc-modules/hello.o
Building modules, stage 2.
MODPOST
CC /home/ldd3/src/misc-modules/hello.mod.o
LD [M] /home/ldd3/src/misc-modules/hello.ko
make[1]: Leaving directory `/usr/src/linux-2.6.10'
% su
root# insmod ./hello.ko
Hello, world
root# rmmod hello
Goodbye cruel world
root#لكن يظهر لي خطأ كما في الصورة
--------------
انا لم اكون Makefile لانه في الكتاب لم يكون ،،
انا حاولت في مثال اخر مع ال makefile لكن ايضا ظهر لي خطأ