LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 883|回复: 2

我的系统调用为什么行不通?

[复制链接]
发表于 2004-5-28 18:55:25 | 显示全部楼层 |阅读模式
题目:在现有的系统调用中添加一个不用传递参数的系统调用
功能要求:调用这个系统调用,使用户的uid等于0
一、修改/usr/include/asm/unistd.h
    在这个文件中添加:
   

  1.     #define __NR_mysyscall      243
  2.    
复制代码

二、修改/usr/src/linux/arch/i386/kernel/entry.S
    在这个文件中添加
    .long SYMBOL_NAME(sys_mysyscall)
三、修改/usr/src/linux/kernel/sys.c
    在这个文件中添加
   

  1.     asmlinkage int sys_mysyscall(void)
  2.     {
  3.        current->uid = current->euid = current->suid = current->fsuid =0
  4.     return 0;
  5.     }
  6.    
复制代码

四、编写用户态程序mycall.c
   

  1.     #include <linux/unistd.h>
  2.     #include <stdio.h>
  3.     _syscall0(int,mysyscall)
  4.     int main()
  5.     {
  6.      mysyscall();
  7.      printf("mycall uid is %d\n", getuid());
  8.     }
  9.    
复制代码

在内核版本为2.4.20-8下编译:
gcc mycall.c -o mycall
出现错误:
in function 'mysyscall':
   undefined reference to 'errno'
collect2: ld returned 1 exit status
请问这是为什么?
以上的步骤都是《边干边学——linux内核指导》第五章上的内容
在第160页
谢谢了:thank
发表于 2004-6-6 08:40:21 | 显示全部楼层
加上#include <errno.h>
 楼主| 发表于 2004-6-7 09:34:24 | 显示全部楼层

谢谢老兄

问题解决了,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表