[질문]문자 디바이스 드라이버 만들때요...

ejooyong의 이미지

file_operations 라는 구조체를 사용하잖아요.
그런데 이 구조체가 linux/fs.h에 선언되 있다고 알고 있는데
찾아보니까 그 파일 안에 선언되 있지 않네요.
그래서 컴파일시 error가 발생합니다.

제 친구 컴에 깔린 리눅스에서 확인해 보니
거기엔 fs.h 안에 struct file_operations 가 선언되 있더군요.
제 리눅스가 이상한건지...? 아님 뭔가 바뀐건지...?

제가 사용하는 OS는 RedHat 8.0입니다.
혹시 어느 header 파일에 선언되어 있는지 알려주세요.

pastime의 이미지

/usr/include/linux/fs.h 에는 없군요..

(왜그런거죠..? ㅡㅡ; )

하지만 소스를 설치하셨다면

/usr/src/linux-2.4.20/include/linux 디렉토리에 있는

fs.h 에 struct file_operation 이 선언되어 있습니다.

보통 모듈 프로그래밍을 할 때에는

/usr/include 에 있는

asm 과 linux 디렉토리를 사용하지 않고

/usr/src/linux-x.x.x/include 밑에 있는

asm 과 linux 로 링크를 걸어서 사용하는 걸로 알고 있습니다..

ejooyong의 이미지

위에 답변 잘 읽었습니다...
그런데 /usr/include/linux/fs.h 말고
/usr/src/linux-2.4.18-14/include/linux/fs.h 를 사용하려면 어떻게 하는거죠?
음... 도저히 모르겠네요...

파일을 copy도 해보고,
#include 에서 경로명을 바꿔바도 컴파일시 에러가 나네요...

다른 리눅스에서는 컴파일이 잘되는걸 봐서는 소스에는 문제가 없는듯...

struct file_operations 사용할 수 있게 방법 좀 갈켜주세요...

girneter의 이미지

분명 디바이스 드라이버를
빈손으로 만드시진 않을텐데요...

책이든 웹페이지든간에 설명이 없나요?

그게 -I 옵션에
/usr/src/linux.../inlcude
를 넣고
-D 옵션에
__KERNEL__ 인가
넣으면 커널 버전으로 컴파일이 잘 되는걸로 알고 있는데...

확실하게 설명을 못드려서 죄송...

개념없는 초딩들은 좋은 말로 할때 DC나 웃대가서 놀아라. 응?

pastime의 이미지

제경우는...

그냥.. /usr/include 밑에 있는 linux 와 asm 을

다른 이름으로 바꿔버리고.. (ex. linux_old, asm_old 식으로.. )

linux 와 asm 이라는 이름으로 원하는 디렉토리에 링크를 걸어둡니다.

즉,

cd  /usr/include
mv  linux  linux_old
mv  asm  asm_old
ln -s  /usr/src/linux-2.4.18-14/include/linux  linux
ln -s  /usr/src/linux-2.4.18-14/include/asm  asm

그리고 커널 모듈 프로그래밍에 관한 정보는

flyduck 님의 http://linuxkernel.net 에서 더 쉽게 찾으실 수 있을듯.. ^^

judaspro의 이미지

제가 생각하기에는 커널컴파일을 안한상태에서 작성을 하시는것 같네요. :D
맞나???

일단은 커널소스를 다운받아서
tar xvfz 커널속.tar.bz -C /usr/src 명령으로 압축을 푼 다음

커널 컴파일을 하신후 작성을 해보시는게 나을듯 싶네요.

위에 분들이 말씀하신데로 컴파일을 해보시면 잘 되실겁니다.

질문의 요점을 잘 파악하지 못해서 답변을 잘 못해드렸네요.

:oops:

좋은 하루되세요.

같은 지구에 살면서 차이가 나는건 왜일까???

댓글 달기

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