Re: problem implementing own system call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add to include/linux/myservice.h

#include <linux/errno.h>

Because if syscalls need to return error codes, it gets them from
errno.h

dave

On Thu, 2004-05-20 at 02:04, bunty wrote:
>   hello,
>       i want to implement my own system in linux kernel. so i used the 
>        http://www.csee.umbc.edu/courses/undergraduate/CMSC421/fall02/burt/projects/howto_add_systemcall.html
> webpage that describes how to add syscall but getting errors. 
> i am using redhat linux with kernel 2.4.20-8.
>  i go through the page. but unable to add syscall. what i did from that webpage
> 1)create /usr/include/sys/myservice-user.h file with contents
> #include <linux/unistd.h>
> _syscall2(int, myservice, int, arg1, char*, arg2);
> 
> 2)create a entry in linux-2.4.24/arch/i386/kernel file as at end
>         .long SYMBOL_NAME(sys_myservice)        /*259*/
> 
> 
> 3) create a entry in linux-2.4.24/include/asm/unistd.h file
> #define __NR_myservice          259
> 
> 4) write a file myservice.c in linux-2.4.24/kernel/
> #include <linux/myservice.h>
> 
> asmlinkage int sys_myservice (int arg1, char* arg2) {
>     return(1);
> }
> 
> 5)write a file myservice.h in linux-2.4.24/include/linux/
> #ifndef __LINUX_MYSERVICE_H
> #define __LINUX_MYSERVICE_H
> 
> #include <linux/linkage.h>
> 
> #endif
> 
> 6) compile kernel. boot that iamge and run the user-app.c program
> #include <sys/myservice-user.h>
> 
> main() {
>   myservice(1, "hi");
> }
> 
> it gives error
> /tmp/ccfvjthg.o(.text+0x23): In function `myservice':
> : undefined reference to `errno'
> collect2: ld returned 1 exit status
> what should do?
> also please tell me to add syscall require kernel to be built and boot it and
> execute that syscal fron user program? cause i did same.
> 
> 
> 
> regards,
> parag.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux