[커널프로그래밍] 파일의 이름만으로 inode struct 을 구할려고 하는데 도움이 필요해요

nfs1004의 이미지

유저가 저의 어플리 케이션을 실행할때 파일이름을 입력해게 되있습니다...그래서 그 프로그램은 system call 하게되면서 그파일의 data block 에 접근해서 그 내용물을 바꿀려고 합니다.
제가시도한 방법은 일단 각 파일마다 struct dentry 있으니깐, 유저의 입력한 파일의 dentry 를 구한다음에 거기의 inode 를 이용해서 데이터 블락에 접근할려고 하는데... 잘 안되네요
namei(file_name) 이용해서 struct dentry 를 구할려고 했는데 저 메소드는 더이상 리눅스에 존재하는게 아니라고 하네요.

또 다른방법으로 ext3_get_inode 콜을 이용해서 ext3_inode 를 구할려고 하는데 아이노드 넘버는 stat() 이용해서 구할구 있는데 super_block sb 를 어떻게 얻어야하는지 몰라서 저 시스템 콜은 못쓰고있습니다..
제가 결국 할려는 거는 유저의 파일네임만으로 그 파일의 데이터 블락에 접근해서 그 내용물을 바꾸려고 하는건데...어떻게 해야하나요?

JuEUS-U의 이미지

fs 쪽은 영~~~~~~~~~~~~~~~~~~~~ 관심 없어서 저도 잘은 모르지만... =ㅅ=)...
pathname으로 접근하는건 애시당초 완벽한 정석인 방법으로 알고 있습니다.

2.6.22.5 뒤로 deprecated되지 않았다면 (분석한 소스 중 가장 최근버전...orz)
그 작업은 fs/namei.c의 open_namei()를 씁니다.
( sys_open() -> filp_open() -> open_namei() )

open_namei : int ( fs/namei.c )
Return - error code
Result - nameidata (struct nameidata nd)

filp_open : struct file ( fs/open.c )

filp_open()을 참조해서, open_namei()를 이용해
목표 파일의 nameidata를 얻은 후,
nd.mnt->mnt_sb가 목표 파일의 super_block입니다.

nd : nameidata ( include/linux/namei.h )
nd.mnt : vfsmount ( include/linux/mount.h )
nd.mnt->mnt_sb : super_block (생략!;;;)

댓글 달기

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