시스템 콜 추가하는 법좀 갈켜 주세여

익명 사용자의 이미지

커널프로그래밍을 방금 시작한 초짜임당.....
책을 보고 하구 있는데 그대로 따라했는데도 안되서염.....
커널 버전은 2.4.17임당
시스템 호출을 구현하려구 하는데여...

include/asm-i386/unistd.h 파일을 열어서
시스템콜 엔트리 마지막에

#define __NR_newsyscall 222

라고 추가하고

arch/i386/kernel/entry.S 파일 열어서
sys_call_table 엔트리 마지막에

.long SYMBOL_NAME(sys_newsyscall)
.rept NR_syscalls-222

이렇게 추가하고

kernel 디렉토리에 newfile.c라는 이름의 파일을 아래와 같이 생성 했음

=============================================================
#include
#include
#include
#include
asmlinkage int sys_newsyscall()
{
printk("Hello Linux, I'm in Kernel");
return 0;
}
===============================================================

그리고 kernel/Makefile을 o_objs 부분에 newfile.o를 추가하고
커널 컴파일해서 재부팅한다음
시스템콜을 써먹을 test_newsyscall.c 파일을 다음과 같이 만든다음에

================================================================
#include
_syscall0(int,newsyscall);

main()
{
int i;
i=newsyscall();
}
===================================================================

gcc로 컴파일 했더니 아래와 같은 에러 메시지가 뜨더군여....

====================================================================
=
[root@localhost /root]# gcc test_newsyscall.c
test_newsyscall.c In function `newsyscall'
test_newsyscall.c2 `__NR_newsyscall' undeclared (first use in
this
function)
test_newsyscall.c2 (Each undeclared identifier is reported only
once
test_newsyscall.c2 for each function it appears in.)
====================================================================
==
원래는 에러메시지가 안뜨고
실행하면 Hello Linux, I'm in Kernel라는 글자가 출력되야 하는데....
여기까지 읽어주시느라 감사함당.....

어케 하면 시스템콜을 제대로 구현할수 있을까여....
이것만 일주일 동안 잡고 있음당.......
고수님덜의 가르침을 기다리겠음당.....
꾸벅......

익명 사용자의 이미지

#include < >와
#include " "의 차이점을 공부해보면 알게 됩니다.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.