Вот какая у меня проблема. Собираю элементарный модуль hello2.c:
Код: Выделить всё
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int __init hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void __exit hello_exit(void)
{
printk(KERN_ALERT "Goodbye, world\n");
}
module_init(hello_init);
module_exit(hello_exit);
Код: Выделить всё
#Makefile - makefile of our first driver
#if KERNELRELEASE is defined, invocation is from kernel build system and can use its language
ifneq (${KERNELRELEASE},)
obj-m:= hello2.o
# Otherwise we were called directly from the command line.
# Invoke the kernel build system
else
KERNEL_SOURCE:=/usr/src/linux-headers-3.13.0-39-generic
PWD:=$(shell pwd)
default:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
clean:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
endif
Код: Выделить всё
gcarpov@ubuntu: ~/TEST/hello$ make
make -C /usr/src/linux-headers-3.13.0-39-generic SUBDIRS=/home/users/gcarpov/TEST/hello modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-39-generic'
CC [M] /home/users/gcarpov/TEST/hello/hello2.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/users/gcarpov/TEST/hello/hello2.mod.o
LD [M] /home/users/gcarpov/TEST/hello/hello2.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-39-generic'
Вот что получается:
Код: Выделить всё
root@ubuntu:/home/users/gcarpov/TEST/hello# lsmod |head -2
Module Size Used by
hello2 12425 0 [permanent]
Въгрузить модуль с помощью rmmod не получается.
Пробовал и с modprobe - тоже нет.
ERROR: Removing 'hello2': Device or resource busy
В чем проблема не пойму..