linux 2.4.28에서 새로운 시스템콜 추가하기

juluv의 이미지

안녕하세요. 그냥 간단한 시스템 콜 하나를 추가하려고 하는데 잘 해결되지 않네요.. 고수님들의 도움 바랍니다. 제가 작업한 내용은 다음과 같습니다.

0. 추가할 시스템콜이름 = mysyscall

1. "/usr/src/linux/arch/i386/kernel/entry.S" 에 ".long SYMBOL_NAME(sys_mysyscall)" 을 240번째에 적어주었습니다.

2. "/usr/src/linux/include/linux/asm-i386/unistd.h" 에
"#define __NR_mysyscall 240" 을 적어주었습니다.

3. "/usr/src/linux/kernel/newfile.c" 를 다음과 같이 작성해주었습니다.
------------------------------------------
#include <linux/unistd.h>
#include <linux/kernel.h>

asmlinkage int sys_mysyscall(){
printk("I'm in kernel."); return(0);
}
------------------------------------------

4. /usr/src/linux/kernel/Makefile에 newfile.o가 컴파일 되도록 추가했습니다.

5. make mrproper와 make menuconfig, make dep, make clean, make install을 실행하여 커널 컴파일을 해준 후 재부팅을 했습니다.
(이전에 커널 컴파일을 한 적이 있어서 make modules와 make modules_install은 따로 하지 않았습니다.)
(커널 컴파일 과정중 에러는 발생하지 않았습니다.)

6. 새 커널로 부팅된 상태에서 test.c 를 작성했습니다.
------------------------------------------
#include <linux/unistd.h>
#include <errno.h>

_syscall0(int, mysyscall);

int main(){
int i;
i = mysyscall();
if(i){
perror();
}
return 0;
}
------------------------------------------

7. test.c 를 컴파일 후 실행하면 다음과 같은 에러가 뜹니다.
------------------------------------------
"function not implemented"
------------------------------------------

ㅜㅜ 제발 도와주세요,, 벌써 10번도 넘게 해본 듯 합니다.
240번이 아닌것 같아 248, 253번 등에도 추가해봤는데 역시 같은 에러가 나는군요...

ps) /usr/include 밑에 있는 asm-i386과 linux는 각각 /usr/src/linux/include/asm-i386 와 /usr/src/linux/include/linux를 link 시켜 놨습니다.

et3569의 이미지

커널 버전이 2.4.28이라면 아마도 entry.S에 시스템 호출이
/*258*/까지 되어 있을겁니다. 새로 만든건 당근 이후 번호로
할당해야 겠지요. 제가 소스 보니깐 260까지로 정의 돼 있더군요 다른 헤더 파일에서요 그러니 259로 할당해서 한번 해보세요
위 파일에서 .long SYMBOL_NAME(작성한 시스템콜) 추가하
시구요 다음 .rept 어쩌구~~~ /4 되어어있어요 여기에다 -1
을 해주시고 저장하고 파일 닫으세요
-1 해주는건 rept가 반복하는거에요 endr 사이에 260개중에서
할당 안됀 부분에다 사이에 설정돼 있는 빈 시스템 호출을
넣는다는 뜻이죠 그러니깐 반복돼는 빈구간을 하나 줄여야 겠죠
새로운 시스템 콜을 추가 했으니 (교수님 말씀 저도 확인해봐야해요) usr/src/linux/include/asm-i386/unistd.h 요 파일에서 호출 함수 번호 썾주셔야 해요
#define __NR_작성한 시스템콜 259
저도 공부하다 오늘 교수님이랑 발견한건데요 저도 실행해봐야
해요 성공하시길 ^^;

juluv의 이미지

우선 저희학교 조교님께서 알려주셨어요. 조교님께 감솨~(성함이;;)

답은 'entry.s에서 시스템 콜 테이블 내에 빈 줄이 들어가는 것 때문'이었네요;;
에궁''

참고로 추가하는 번호(예:240,241...)등은 상관이 없다고 하시네요

도와주신 모든분들께 감솨드립니다~ :D

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.