Вот хотелось бы проконсультироваться у знающих людей)
собственно задача состоит в сл.
Создать и запустить простейший модуль ядра, например "hello, world"
нашел мануал такой.. но он в тексте без команд
1. Скачать с дистрибутива Debian в соответствующую системную директорию исходный код ядра системы..
2. Установить утилиты компиляции gcc и module assistant.
3. Скачать в домашнюю директорию текущего пользователя архив hello_printk.tar.gz и распаковать его.
4. Изменение файл Makefile, задав в нем имя ссылки на исходный код ядра, соответствующее нашей системе.
5. Проверить наличие этой ссылки в соответствующей целевой директории. Если ее цель не является директорию под тип процессоров 686 исходных кодов ядра, изменить ее цель (или создать новую ссылку).
6. Скомпилировать исполняемый файл модуля ядра.
7. Скачать модуль ядра в систему. Проверить его наличие в системе соответствующей командой.
архив hello_printk.tar.gz имеет два файла
makefile:
# obj-m is a list of what kernel modules to build. The .o and other
# objects will be automatically built from the corresponding .c file -
# no need to list the source files explicitly.
obj-m := hello_printk.o
# KDIR is the location of the kernel source. The current standard is
# to link to the associated source tree from the directory containing
# the compiled modules.
KDIR := /lib/modules/$(shell uname -r)/build
# PWD is the current working directory and the location of our module
# source files.
PWD := $(shell pwd)
# default is the default make target. The rule here says to run make
# with a working directory of the directory containing the kernel
# source and compile only the modules in the PWD (local) directory.
default:
$(MAKE) -C $(KDIR) M=$(PWD) moduleshello_printk.c
/*
* "Hello, world!" minimal kernel module
*
* Valerie Henson <val@nmt.edu>
*
*/
/*
* The below are header files provided by the kernel which are
* required for all modules. They include things like the definition
* of the module_init() macro.
*/
#include <linux/init.h>
#include <linux/module.h>
/*
* This is the init function, which is run when the module is first
* loaded. The __init keyword tells the kernel that this code will
* only be run once, when the module is loaded.
*/
static int __init
hello_init(void)
{
printk("Hello, world!\n");
return 0;
}
/*
* The below macro informs the kernel as to which function to use as
* the init function.
*/
module_init(hello_init);
/*
* Similary, the exit function is run once, upon module unloading, and
* the module_exit() macro identifies which function is the exit
* function.
*/
static void __exit
hello_exit(void)
{
printk("Goodbye, world!\n");
}
module_exit(hello_exit);
/*
* MODULE_LICENSE() informs the kernel what license the module source
* code is under, which affects which symbols it may access in the
* main kernel. Certain module licenses will "taint" the kernel,
* indicating that non-open or untrusted code has been loaded.
* Modules licensed under GPLv2 do not taint the kernel and can access
* all symbols, but declaring it so is a legal statement that the
* source code to this module is licensed under GPLv2, and so you must
* provide the source code if you ship a binary version of the module.
*/
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Valerie Henson <val@nmt.edu>");
MODULE_DESCRIPTION("\"Hello, world!\" minimal module");
MODULE_VERSION("printk");1. # cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/ … .5.tar.bz2
и розархивировал его
# tar xjf linux-2.6.32.5.tar.bz2
я так понимаю нам нужны хеад-файлы отсюда...
ну в общем дошел до 4го пункта, там я так понимаю нужно изменить строку
KDIR := /lib/modules/$(shell uname -r)/build но на какую я что то непойму..
в общем выдавало ошибку
make -C /usr/src/linux-2.6.32.5/build M=/home/polzovatel/hello_printk modules
make: *** /usr/src/linux-2.6.32.5/build: No such file or directory. Остановка
make: *** [default] ошибка 2.
