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

Why system call is returning -1 ??????



hi,
   Any one  plz help me....
   I want to write a system call into a kernel.
   i followed all steps of writing a system call to kernel.
   i did.....
   1) updated ./linux/include/asm/unistd.h
   2)updated ./linux/arch/386/kernel/syscall_table.S
  3) then wrote my own  system call code in ./linux/kernel/sys.c file
 
asmlinkage long sys_getjiffies( void )       
{
  return (long)get_jiffies_64();       // read jiffies with the get_jiffies_64 function.
}
 
//The Linux kernel maintains a global variable called jiffies, which represents the number of timer ticks since the machine started
 
 4) after compiling kernel , when i tried to call that system call , it returned me -1.
 
Following code i used to call system call created above.
#include <linux/unistd.h>
#include <sys/syscall.h>

#define __NR_getjiffies 320

int main()
{
  long jiffies;

  jiffies = syscall( __NR_getjiffies );

  printf( "Current jiffies is %lx\n", jiffies );

  return 0;
}
 
Plz help me....... why system call  is returning negative value.
 
Thanks in advance.