Results 1 to 2 of 2
I'm trying to add a custom ("Hello world" :o) system call.
In /usr/src/linux/hello/ I put simple hello.c ...
Code:
#include "linux/linkage.h" // for linking a system call
#include "linux/kernel.h" // ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 01-09-2011 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 15
Adding custom ("Hello") system call: help
I'm trying to add a custom ("Hello world" :o) system call.
In /usr/src/linux/hello/ I put simple hello.c ...... and in home directory helloTest.c:Code:#include "linux/linkage.h" // for linking a system call #include "linux/kernel.h" // for "printk" asmlinkage int sys_hello() { printk(KERN_ALERT "Hello!"); return 1; }I compiled helloTest.c and ran ./a.out: in /var/log/messages nothing gets written!Code:#include <stdio.h> #include <sys/syscall.h> #include <linux/unistd.h> #define __NR_hello 338 int main() { syscall(__NR_hello); return 0; }
Before "compile & install & reboot" I did these steps (linux is symbolic link to linux-2.6.35.10):
- In /usr/src/linux/arch/x86/include/asm/unistd_32.h, I've added/changed: Code:
#define __NR_hello 338 #define __NR_syscalls 339
- In /usr/src/linux/arch/x86/kernel/syscall_table.S, I've added (on the last line): Code:
.long sys_hello
- In /usr/src/linux/hello, I've created a Makefile: ... and in /usr/src/linux, I've modified Makefile and added hello/ directory:Code:
obj-y += hello.o
Code:core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ hello/
- In /usr/src/linux/include/linux/syscalls.h, I've added (on the last line): Code:
asmlinkage long sys_hello(void)
- 01-13-2011 #2Just Joined!
- Join Date
- Dec 2010
- Posts
- 15
"Hello!" IS in dmesg but NOT in /var/log/messages
I've checked System.map (in /boot directory) and 'hello' is indeed there:
Does that imply that something is wrong with my test call, helloTest.c?Code:c015c3c0 T sys_hello
EDIT: dmesg* does print "Hello!" on the last line, but there is nothing in /var/log/messages file.
* dmesg - prints or controls the kernel ring bufferLast edited by courteous; 01-13-2011 at 08:33 AM.


Reply With Quote
