作者whiteash (白小尘)
看板LinuxDev
标题Re: [问题] 自己增加新的system call,没办法呼叫
时间Wed May 6 21:08:25 2015
借题发问,
本人linux 初心者,
因为课程的关系所以在练习新增kernel,
我参考的网页是:
http://www.functor.me/hello-kernel/
和
http://it.livekn.com/2013/01/kernel-system-call.html?
showComment=1430913871922
#c8818990812637366221
也确实有跑出结果来,
https://drive.google.com/file/d/0Bx8PQxTU7Vk8U2dKY1pYdFVlem8/view
但是我希望能用类似 common_hello() 方法
而不是用syscall()来呼叫自己新增的syscall,
所以在估狗大神的帮忙之下凑出了下面这个结果:
https://drive.google.com/file/d/0Bx8PQxTU7Vk8bXQ4X1lwN1hHNlU/view
然後我就不知道该怎麽继续下一步了... Orz
请问我是不是做错了什麽步骤或漏了什麽而不自知 ?_____?
然後爬文和google都有提到Syscall macros被移除掉了,
但是因为找到的资料都是2006左右时间久远的话题,
所以不太确定现在情况是...?
如果是被移除掉的话我该怎麽达到我的目的呢?
作业系统: Ubuntu 14.04 (32位元)
核心: 3.19.6
谢谢大家 :)
※ 引述《sacanner (Sam)》之铭言:
: 给个简单的范例程式
: 参考看看吧~~
: --------------------------
: #include <stdio.h>
: #include <asm/unistd.h>
: #include <unistd.h>
: #include <stdlib.h>
: #include <string.h>
: int errno;
: #define __NR_occupy 289 //自己定义的数字
: _syscall1(long,occupy,int,cpu_id);
: int main(int argc,char *argv[])
: {
: int cpu_id=0;
: occupy(cpu_id);
: return 0;
: }
: ※ 引述《pinkisme ()》之铭言:
: : 我是在Fedora上增加一个新的system call,
: : 下面是呼叫的程式
: : include <linux/unistd.h>
: : #include <sys/syscall.h>
: : #include <errno.h>
: : #include <stdio.h>
: : int main()
: : {
: : int rc;
: : rc = syscall(318,15);
: : printf("RC=%d\n",rc);
: : if(rc==-1)
: : printf("ERROR\n");
: : return 0;
: : }
: : 可是跑出来却还是没有呼叫自订的system call
: : 想请问一下可能是哪个环节出问题吗?
: : 谢谢
--
今天和明天都是蓝绿藻可以想像的未来
一陈不变的日子堆积了五公分厚的灰尘
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 163.22.18.74
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/LinuxDev/M.1430917711.A.4A3.html
1F:→ jserv: 可以请你的老师不要再出这种单调的题目了吗? :) 06/03 11:14