sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #87975
Hjemmelavet kernel module
Hej,
Jeg prøver at lave et kernel module ud fra O'reillys bog Device Drivers.
Men jeg får en fejl når jeg prøver at compilere, og kan ikke rigtig
finde ud af hvad der er galt. (Køre Ubuntu, kernel 2.6.12-10)
Håber nogle kan hjælp
På forhånd tak :)
/Christoffer
Koden er:
#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);
Makefile:
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
Fejl:
cc hello.c -o hello
I filen inkluderet af /usr/include/linux/sched.h:16,
af /usr/include/linux/module.h:9,
af hello.c:2:
/usr/include/linux/signal.h:2:2: advarsel: #warning "You should include
<signal.h>. This time I will do it for you."
In file included from /usr/include/linux/resource.h:4,
from /usr/include/linux/sched.h:79,
from /usr/include/linux/module.h:9,
from hello.c:2:
/usr/include/linux/time.h:9: fejl: omdefinering af 'struct timespec'
/usr/include/linux/time.h:15: fejl: omdefinering af 'struct timeval'
/usr/include/linux/time.h:20: fejl: omdefinering af 'struct timezone'
/usr/include/linux/time.h:47: fejl: omdefinering af 'struct itimerval'
In file included from hello.c:2:
/usr/include/linux/module.h:41: fejl: feltet 'attr' er af en
ufuldstændig type
/usr/include/linux/module.h:49: fejl: feltet 'kobj' er af en
ufuldstændig type
hello.c: In function `hello_init':
hello.c:6: fejl: 'KERN_ALERT' er ikke erklæret (først benyttet i denne
funktion)
hello.c:6: fejl: (et kaldenavn der ikke er erklæret, rapporteres kun én
gang
hello.c:6: fejl: per funktion)
hello.c:6: fejl: tolkningsfejl før strengkonstant
hello.c: In function `hello_exit':
hello.c:11: fejl: 'KERN_ALERT' er ikke erklæret (først benyttet i denne
funktion)
hello.c:11: fejl: tolkningsfejl før strengkonstant
make: *** [hello] Fejl 1
Follow ups