[問題] Linux2.6.28.1 增加 system call

看板Linux作者 (U你媽)時間16年前 (2009/04/05 17:51), 編輯推噓3(305)
留言8則, 3人參與, 最新討論串1/1
剛剛試著要增加一個system call 一開始先進到 /usr/src/linux-2.6.28.1/usr/include/asm/unistd_32.h 在裡面最後一筆增加一個system call number #define __NR_helloworld 333 然後再來到 /usr/src/linux-2.6.28.1/arch/x86/kernel/syscall_table_32.S 在最後面增加 .long sys_helloworld 接著到 /usr/include/asm/unistd_32.h 也在最後面增加一筆 #define __NR_helloworld 333 然後到/usr/src/linux-2.6.28.1/arch/x86/kernel/ 新增一個helloworld.c檔 裡面程式碼是這樣 #include <linux/linkage.h> #include <linux/kernel.h> asmlinkage int sys_helloworld() { printk("******hello world!******"); return 0; } 然後在Makefile 增加obj-y += helloworld.o 接著就到/usr/src/linux-2.6.28.1裡進行編譯 執行make install 然後也成功編譯沒有產生error 就產生一個test.c來跑 程式如下 #define __KERNEL__ #include <sys/syscall.h> #include <linux/unistd.h> #include <errno.h> #undef __KERNEL__ //_syscall0(int,helloworld);/*因為版本關係不能用這行的樣子..*/ int helloworld()/*所以先定義*/ { return syscall(__NR_helloworld); }; int main(void) { helloworld(); } 然後也成功編譯過 gcc test.c -o test.o 執行./test.o 然後再輸入 dmesg 結果跑了很多很多東西出來 但就是沒有******hello world!****** 到底是哪裡出現問題ˊˋ 因為中間沒有編譯錯誤我不知道該如何下手找起ˊˋ 因為應該只是個小小的system call程式阿ˊˋ 請教一下各位是哪裡出錯了呢? 先謝謝各位摟:) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.136.244.158

04/05 19:03, , 1F
加上errno以後出現Function not implemented.
04/05 19:03, 1F

04/05 19:04, , 2F
應該是沒有把syscall的大小增加....只是找不到在哪個檔
04/05 19:04, 2F

04/05 19:04, , 3F
裡面真冏...
04/05 19:04, 3F

04/06 20:44, , 4F
請問第一步的unistd_32.h是在哪裡找到的? usr下沒有include
04/06 20:44, 4F

04/07 01:10, , 5F
我的底下有耶 版本一樣媽?
04/07 01:10, 5F

04/07 14:12, , 6F
沒有耶,2.6.28我應該是沒看錯..., 但是官方的LXR上也沒有
04/07 14:12, 6F

04/07 22:33, , 7F
ˊˋ
04/07 22:33, 7F

04/08 17:40, , 8F
dmesg | tail
04/08 17:40, 8F
文章代碼(AID): #19s7yNJ3 (Linux)