日期:2014-05-16  浏览次数:20585 次

VMware fedora 11下添加系统调用的问题
一、从网上下载的内核版本:linux-2.6.29.4,解压到/usr/src下,进入解压后的目录cd linux-2.6.29.4;
二、将原内核配置复制过来:cp /boot/config<Tab>.config,make oldconfig,然后make;make modules_install;make install 这样在不添加系统调用的情况下重新编译内核后可以启动新内核;但是加入自己的系统调用后就无法启动,添加步骤如下:
  1)修改用户空间unistd.h,在/usr/include/asm/unistd_32.h,添加#define __NR_mysyscall 223
  2) 修改内核空间unistd.h,在/linux-2.6.29.4/arch/x86/include/asm/unistd_32.h,添加#define __NR_mysyscall 223
  3) 修改syscall_table_32.s,在/linux-2.6.29.4/arch/x86/kernel/syscall_table_32.s,添加.long sys_mysyscall
  4) 在/linux-2.6.29.4/kernel/sys.c中添加实现(实现遍历每个进程,输出名字、id及状态)如下:
 
C/C++ code

      asmlinkage int sys_mysyscall(void)
      {
         struct task_struct *task,*p;
         struct list_head *list;
         task = &init_task;
         list_for_each(list,&task->tasks);
         {
             p=list_entry(list,struct task_struct,tasks);
             printk("Thread_name: %16s, pid: %10d, state: %6ld",p->comm,p->pid,p->state);
         }
         return 0;
      }


  5)重新编译,make mrproper;cp /boot/config<Tab>.config;make oldconfig;make;make modules_install;make install,编译没有问题
  6)reboot重启后,选择linux-2.6.29.4登录时,死在那里:
  cannot set up thread-local storage:set_thread_area failed when setting up thread-local storage

编译了N遍,都是杯具...





------解决方案--------------------
添加系统调用参考:http://blog.csdn.net/wenxy1/archive/2009/11/20/4841661.aspx
你的sys_mysyscall()函数是否有问题?只用printk输出试试。
------解决方案--------------------
http://www.chinalinuxpub.com/read.php?wid=23

看下这篇文章,不一定有用。我也试过,但是照这篇文章也悲剧了。