Linux에서 virtual filesystem number에 대한 정보를 읽어오려면

익명 사용자의 이미지

AIX에서 Linux로 포팅작업을 하고 있습니다.
AIX에 보면 file status를 저장하는 struct stat 구조체에 st_vfs라는
member가 있습니다.
file이 어느 filesystem에 mount되어 있는지를 알려주는 filesystem
number를 알려주는 member입니다.
여기서 filesystem은 virtual file system이구요.
아래는 제가 작업하고 있는 AIX의 mount 상황입니다.

node mounted mounted over
-------- --------------- ---------------
/dev/hd4 /
/dev/hd2 /usr
/dev/hd9var /var
/dev/hd3 /tmp
/dev/hd1 /home
/dev/lv00 /work
/dev/lvbox1 /box1
/dev/lvoracle /oracle
/dev/lvbox2 /box2
/dev/lv03 /ag

예를 들어 "/"의 st_vfs값은 5, "/dev"의 st_vfs값은 5, "/usr"의 st_vfs
값은 6, "/var"의 st_vfs값은 7, "/home"의 st_vfs값은
9, "/home/heavyman/foobar.c"의 fs_vfs값은 9 이런 식이죠.

Linux에서도 virtual filesystem을 사용하는 걸로 알고 있습니다.
이곳저곳에서 문서들을 뒤져보니 linux에서도 virtual filesystem을 사용
하더군요.
그런데 Linux에서 struct stat 구조체에는 st_vfs member가 없습니다.
그래서 Linux에서 virtual filesystem number를 얻을 수 있는 방법이 없을
까 한참을 찾아 헤매다가 결국 여기에다가 질문을 올립니다. ㅡ.ㅡ;;;
제가 kldp와 google 등에서 찾아본 문서들에는 virtual filesystem에 대
한 설명이 나와있는 문서는 찾았지만 virtual filesystem number를 읽을
수 있는 방법에 대한 문서는 못 찾았습니다.
그리고 fs.h, statfs.h, statvfs.h 등등 헤더파일들도 다 뒤져봤는데 못
찾겠더라구요. ㅡ.ㅡ;;;
그래서 이렇게 질문을 올립니다.

결국은 요약하면 Linux에서 virtual filesystem number에 대한 정보를 읽
어오려면 어떻게 해야하는지에 대한 질문입니다.

익명 사용자의 이미지

안녕하세요! 잘 모르지만 혹시나 해서 답장을 써봅니다.

님의 아래 샘플을 보면, 마치 특정 파일이 어느 장치 디바이스
에 연결되어 있는 지 정보가 궁금해 하는 것 같기도 하고요...

그렇다면, stat 구조체의 st_dev 멤버를 참고해 보시고요.....

예로,

/, /dev가 같은 파티션(장치디바이스,/dev/hda3)에 있을 경우 st_dev 값은
-> (MAJOR(dev)<<8) | MINOR(dev) 연산을 통해 771 입니다.

/home(/dev/hda4)에 있을 경우st_dev 값은
-> (MAJOR(dev)<<8) | MINOR(dev) 연산을 통해 772 입니다.

제가 잘 못 짚었다면, 커널 내에 stat 구조체 외에 vfsmount 관련 구조체
가 있습니다.

그 구조체 멤버은 다음과 같습니다.

struct vfsmount
{
struct list_head mnt_hash;
struct vfsmount *mnt_parent; /* fs we are mounted on */
struct dentry *mnt_mountpoint; /* dentry of mountpoint */
struct dentry *mnt_root; /* root of the mounted tree /
struct super_block *mnt_sb; /* pointer to superblock */
struct list_head mnt_mounts; /* list of children, anchored here */
struct list_head mnt_child; /* and going through their mnt_child */
atomic_t mnt_count;
int mnt_flags;
char *mnt_devname; /* Name of device e.g. /dev/dsk/hda1 */
struct list_head mnt_list;
};

위 구조체 멤버에 원하는 정보가 있다면 이 구조체를 사용하는 시스템
콜이 있는지 확인해 보시고요, 없다면 위 구조체를 사용하여 시스템 콜을 새로
작성해도 될 것 같기도 하고요..

님의 질문과 관련성이 있었는지 모르겠네요.. 수고하세요
-----
AIX에서 Linux로 포팅작업을 하고 있습니다.
AIX에 보면 file status를 저장하는 struct stat 구조체에 st_vfs라는
member가 있습니다.
file이 어느 filesystem에 mount되어 있는지를 알려주는 filesystem
number를 알려주는 member입니다.
여기서 filesystem은 virtual file system이구요.
아래는 제가 작업하고 있는 AIX의 mount 상황입니다.

node mounted mounted over
-------- --------------- ---------------
/dev/hd4 /
/dev/hd2 /usr
/dev/hd9var /var
/dev/hd3 /tmp
/dev/hd1 /home
/dev/lv00 /work
/dev/lvbox1 /box1
/dev/lvoracle /oracle
/dev/lvbox2 /box2
/dev/lv03 /ag

예를 들어 "/"의 st_vfs값은 5, "/dev"의 st_vfs값은 5, "/usr"의 st_vfs
값은 6, "/var"의 st_vfs값은 7, "/home"의 st_vfs값은
9, "/home/heavyman/foobar.c"의 fs_vfs값은 9 이런 식이죠.

Linux에서도 virtual filesystem을 사용하는 걸로 알고 있습니다.
이곳저곳에서 문서들을 뒤져보니 linux에서도 virtual filesystem을 사용
하더군요.
그런데 Linux에서 struct stat 구조체에는 st_vfs member가 없습니다.
그래서 Linux에서 virtual filesystem number를 얻을 수 있는 방법이 없을
까 한참을 찾아 헤매다가 결국 여기에다가 질문을 올립니다. ㅡ.ㅡ;;;
제가 kldp와 google 등에서 찾아본 문서들에는 virtual filesystem에 대
한 설명이 나와있는 문서는 찾았지만 virtual filesystem number를 읽을
수 있는 방법에 대한 문서는 못 찾았습니다.
그리고 fs.h, statfs.h, statvfs.h 등등 헤더파일들도 다 뒤져봤는데 못
찾겠더라구요. ㅡ.ㅡ;;;
그래서 이렇게 질문을 올립니다.

결국은 요약하면 Linux에서 virtual filesystem number에 대한 정보를 읽
어오려면 어떻게 해야하는지에 대한 질문입니다.

댓글 달기

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