Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Unhappy 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 ...
    #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;
    ... and in home directory helloTest.c:
    #include <stdio.h>
    #include <sys/syscall.h>
    #include <linux/unistd.h>
    #define __NR_hello	338
    int main()
    	return 0;
    I compiled helloTest.c and ran ./a.out: in /var/log/messages nothing gets written!

    Before "compile & install & reboot" I did these steps (linux is symbolic link to linux-
    1. In /usr/src/linux/arch/x86/include/asm/unistd_32.h, I've added/changed:
      #define __NR_hello	 338
      #define __NR_syscalls	 339
    2. In /usr/src/linux/arch/x86/kernel/syscall_table.S, I've added (on the last line):
      .long sys_hello
    3. In /usr/src/linux/hello, I've created a Makefile:
      obj-y += hello.o
      ... and in /usr/src/linux, I've modified Makefile and added hello/ directory:
      core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ hello/
    4. In /usr/src/linux/include/linux/syscalls.h, I've added (on the last line):
      asmlinkage long sys_hello(void)

  2. #2

    "Hello!" IS in dmesg but NOT in /var/log/messages

    I've checked (in /boot directory) and 'hello' is indeed there:
    c015c3c0 T sys_hello
    Does that imply that something is wrong with my test call, helloTest.c?

    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 buffer
    Last edited by courteous; 01-13-2011 at 09:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts