public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* System Call Problem
@ 2003-01-12  0:38 Hall, Luca
  2003-01-12  1:04 ` Robert Love
  0 siblings, 1 reply; 6+ messages in thread
From: Hall, Luca @ 2003-01-12  0:38 UTC (permalink / raw)
  To: 'linux-kernel@vger.kernel.org'

Hello I have a small problem with a new sys call: 

Slackware 8 , Kernel 2.2.19
tring to add a system call i did:

/usr/src/linux/kernel/luca.c

#include <linux/luca.h>
#include <linux/kernel.h>

asmlinkage int sys_luca(void){
        printk("my call in the kernel\n");
        return(555);

}

/usr/src/linux/include/linux/luca.h

#ifndef __LINUX_LUCA_H
#define __LINUX_LUCA_H

#include <linux/linkage.h>
#include <linux/unistd.h>

_syscall0(int,luca)

#endif

/usr/src/linux/include/asm-i386/unistd.h

added: #define __NR_luca               191

/usr/src/linux/arch/i386/kernel/entry.S

added: .long SYMBOL_NAME(sys_luca)
changed from 190: .rept NR_syscalls-191

compiled with make dep, make bzImage

The problem is now that when I boot i see the printk messages at the 
bottom. around 5 - 7 times.
When I log in I see the printk messages, and dmesg also. I checked many 
resources and cant seem too find what I'm doing wrong; why is my funct being
called at boot time and 
login ?

thanks alot
luca


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System Call Problem
  2003-01-12  0:38 System Call Problem Hall, Luca
@ 2003-01-12  1:04 ` Robert Love
  0 siblings, 0 replies; 6+ messages in thread
From: Robert Love @ 2003-01-12  1:04 UTC (permalink / raw)
  To: Hall, Luca; +Cc: 'linux-kernel@vger.kernel.org'

On Sat, 2003-01-11 at 19:38, Hall, Luca wrote:

> The problem is now that when I boot i see the printk messages
> at the bottom. around 5 - 7 times.

You took the syscall number for getrlimit(2).

You cannot just arbitrarily pick a syscall number, it needs to be a new
and never-before-used number.

Look in include/asm/unistd.h and add your number to the bottom.

	Robert Love


^ permalink raw reply	[flat|nested] 6+ messages in thread

* System call problem
@ 2005-02-26 14:17 Josef E. Galea
  2005-02-26 14:43 ` Steven Rostedt
  2005-02-27 23:02 ` linux-os
  0 siblings, 2 replies; 6+ messages in thread
From: Josef E. Galea @ 2005-02-26 14:17 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am implemeting a new system call for a project I'm working on. I added 
the system call to the file arch/i386/kernel/process.c and added the 
relevant entries in the files arch/i386/entry.S and 
include/asm-i386/unistd.h. My system call is made up of only two lines, 
a printk statement, and a return statement which gets the value of a 
field that I added to the task_struct structure.

I compiled and booted the kernel and am trying to build a user space 
application that uses my system call, however gcc is returning this error:
/tmp/cc4zgzUr.o(.text+0x4e): In functiono `get_rmt_paging':
: undefined reference to `errno'

Can anyone help me with this?

Thanks
Josef

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System call problem
  2005-02-26 14:17 System call problem Josef E. Galea
@ 2005-02-26 14:43 ` Steven Rostedt
  2005-02-26 18:45   ` Josef E. Galea
  2005-02-27 23:02 ` linux-os
  1 sibling, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2005-02-26 14:43 UTC (permalink / raw)
  To: Josef E. Galea; +Cc: LKML

On Sat, 2005-02-26 at 15:17 +0100, Josef E. Galea wrote:

> I compiled and booted the kernel and am trying to build a user space 
> application that uses my system call, however gcc is returning this error:
> /tmp/cc4zgzUr.o(.text+0x4e): In functiono `get_rmt_paging':
> : undefined reference to `errno'
> 

Where you defined your system call in the user space program (ie. where
you declared your _syscall macro), did you also include <errno.h>?

-- Steve



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System call problem
  2005-02-26 14:43 ` Steven Rostedt
@ 2005-02-26 18:45   ` Josef E. Galea
  0 siblings, 0 replies; 6+ messages in thread
From: Josef E. Galea @ 2005-02-26 18:45 UTC (permalink / raw)
  To: linux-kernel

Steven Rostedt wrote:

>On Sat, 2005-02-26 at 15:17 +0100, Josef E. Galea wrote:
>
>  
>
>>I compiled and booted the kernel and am trying to build a user space 
>>application that uses my system call, however gcc is returning this error:
>>/tmp/cc4zgzUr.o(.text+0x4e): In functiono `get_rmt_paging':
>>: undefined reference to `errno'
>>
>>    
>>
>
>Where you defined your system call in the user space program (ie. where
>you declared your _syscall macro), did you also include <errno.h>?
>
>-- Steve
>
>
>  
>
I included <linux/errno.h> and it didn't solve the problem. Now i 
included <errno.h> and it did. Thanks for you help!

Josef

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: System call problem
  2005-02-26 14:17 System call problem Josef E. Galea
  2005-02-26 14:43 ` Steven Rostedt
@ 2005-02-27 23:02 ` linux-os
  1 sibling, 0 replies; 6+ messages in thread
From: linux-os @ 2005-02-27 23:02 UTC (permalink / raw)
  To: Josef E. Galea; +Cc: linux-kernel

On Sat, 26 Feb 2005, Josef E. Galea wrote:

> Hi,
>
> I am implemeting a new system call for a project I'm working on. I added the 
> system call to the file arch/i386/kernel/process.c and added the relevant 
> entries in the files arch/i386/entry.S and include/asm-i386/unistd.h. My 
> system call is made up of only two lines, a printk statement, and a return 
> statement which gets the value of a field that I added to the task_struct 
> structure.
>
> I compiled and booted the kernel and am trying to build a user space 
> application that uses my system call, however gcc is returning this error:
> /tmp/cc4zgzUr.o(.text+0x4e): In functiono `get_rmt_paging':
> : undefined reference to `errno'
>
> Can anyone help me with this?
>
> Thanks
> Josef

You can't use kernel headers in user-mode functions. For one thing,
they bring in undefined stuff.

Your user mode code can, of course get the definition of errno
by #include <errno.h>. That's the errno that exists in every user-
mode 'C' program-developed process space. However, if get_rmt_paging
is not one of your functions, you are in trouble by mixing up
user-mode and kernel-mode headers.

Normally, the return value of a kernel function is checked and
if it's negative, the positive equivalent is put into the global
variable errno and then the return value is changed to -1. This
is where the user-mode reference to errno occurs.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
  Notice : All mail here is now cached for review by Dictator Bush.
                  98.36% of all statistics are fiction.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-02-27 23:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-26 14:17 System call problem Josef E. Galea
2005-02-26 14:43 ` Steven Rostedt
2005-02-26 18:45   ` Josef E. Galea
2005-02-27 23:02 ` linux-os
  -- strict thread matches above, loose matches on Subject: below --
2003-01-12  0:38 System Call Problem Hall, Luca
2003-01-12  1:04 ` Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox