Reputation: 679
I'm trying to simply read the kernel ring buffer from a kernel module. Also known as /proc/kmsg and dmesg output.
From looking around it seems that the call for this is sys_syslog(); from what I've read dmesg uses syslog() which uses do_syslog() which resides in printk.c.
I grep around and see that do_syslog() is defined in linux/syslog.h, so I include this file.
The actual call to do_syslog() in the test module looks like this:
read_bytes = do_syslog(2, temp_buffer, 1024, 0);
Where temp_buffer is just a char temp_buffer[1024] meant for test purposes.
The program compiles, however when I try to load the module it fails:
insmod: error inserting 'testing.ko': -1 Unknown symbol in module
From dmesg I see: "Unknown symbol do_syslog (err 0)"
Why is this an unknown symbol? Do I need to link against something?
The makefile is as follows:
obj-m += testing.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
Upvotes: 2
Views: 2281
Reputation: 2635
You need to recompile a kernel with that symbol exported.
EXPORT_SYMBOL (do_syslog);
Upvotes: 2