커널 내에 system call을 추가하는 방법이 궁금합니다.

diki의 이미지

커널 내에 system call을 추가하는 방법이 궁금합니다.
정확히는 커널 내에 system call을 추가시킨 것 같은데, 반응이 안나오는군요.

http://kernelholic.com/zbxe/?document_srl=800
에 나와있는 내용과 거의 동일하게 진행했으며,

제가 진행한 순서는

1. /usr/src/ 폴더에서 커널 2.6.26.5 버전을 다운 및 압축을 풀었고,

2. ./include/asm-x86/unistd_32.h 파일의 335번째 라인에

#define __NR_helloworld		327

같은 파일 339번째 라인에
#define NR_syscalls	328

을 추가했으며

3. ./arch/x86/kernel/syscall_table_32.s 파일의 329번째 라인에

.long sys_helloworld

를 추가했으며

4. ./kernel/ 폴더에 helloworld.c 파일을 추가했고

#include <linux/linkage.h> // linux/linkage.h  이상하게 해더파일이 여기 화면에서 안보이는군요..;
#include <linux/kernel.h> // linux/kernel.h
asmlinkage sys_helloworld(void) {
	printk(KERN_EMERG "hello world!");
	return 1;
}
EXPORT_SYMBOL_GPL(sys_helloworld);

라고 입력했습니다.

5. 그 외에 ./kernel/Makefile 에 helloworld.o 라고 덧붙여주었고요.

6. 2.6버전 커널 컴파일하는대로 컴파일 후, initrd.img 파일까지 생성해서, /boot/grub/menu.lst 파일에 추가했습니다.
물론 컴파일된 커널로 정상적인 부팅까지 완료한 상태이고요.

문제는 커널에 정상적으로 추가되었는지 확인하기 위하여 text.c 파일을 하나 만들었고,

#include <linux/errno.h> // linux/errno.h
#include <sys/syscall.h> // sys/syscall.h
#include <linux/unistd.h> // linux/unistd.h
 
int main(void){
	syscall(__NR_helloworld);
}

라고 입력한 후 gcc test.c -o test -I /usr/src/linux-2.6.26.5 라고 컴파일해서 결과물을 얻었습니다.
근데, 분명 ./test라고 실행하면 hello world! 문구가 떠야 할텐데, 전혀 그런 내용이 화면에 안뜨네요.

분명 제가 어디선가 빠트린 부분이 있을 것 같은데,
도저히 저로서는 찾기가 어렵네요. ㅠ

현재 저는 VMware에서 Ubuntu 8.04버전을 사용중이며,
커널 버전은 2.6.24-19, gcc는 4.1.3을 사용중입니다.

기억상 기초적인 프로그래밍 툴(gcc같은)을 설치한 것 이외에는
심볼릭 링크 하나 새로 추가시키지도 않은 깨끗한 상태입니다.

그리고 새로 받은 커널 버전은 2.6.26.5 버전이고,

고수님들의 조언 부탁드립니다.

dragonkun의 이미지

컴파일이 잘 됐으면 된 거 아닐까요?

dmesg나 /var/log/messages의 커널 로그를 확인해 보세요.

syslogd 같은데서 커널로그를 콘솔에 출력 안하도록 설정되어 있을 수 있습니다.

---
Emerging the World!

Emerging the World!

paeksj98의 이미지

테스트 해봐야 겠습니다.
예전에 비슷한거 했었는데 안되서 말았는데.

댓글 달기

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