1 / 10

장보길

ULKML 가상 파일 시스템 (VFS) - 1. 장보길. 한국 외국어대학교 디지털정보공학과 System Software LAB xearo@hufs.ac.kr. VFS 층이란 ?. 사용자로부터 어떤 이벤트가 들어오면 여러 종류의 파일시스템에 대해 공통 인터페이스를 제공하는 층. VFS 층의 데이터 구조 (1/2). inode 구조체 디스크 상의 파일 관리 정보라는 의미에서 유래 각 파일시스템에서 공통적으로 관리해야 할 정보를 다룸 address_space 구조체

gloria-todd
Download Presentation

장보길

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ULKML 가상 파일 시스템(VFS) - 1 장보길 한국 외국어대학교 디지털정보공학과 System Software LAB xearo@hufs.ac.kr

  2. VFS 층이란? 사용자로부터 어떤 이벤트가 들어오면 여러 종류의 파일시스템에 대해 공통 인터페이스를 제공하는 층

  3. VFS층의 데이터 구조(1/2) • inode 구조체 • 디스크 상의 파일 관리 정보라는 의미에서 유래 • 각 파일시스템에서 공통적으로 관리해야 할 정보를 다룸 • address_space구조체 • 파일과 가상 메모리 관리와의 교환을 제어(페이지 캐시) • inode와 address_space는 1:1로 대응 • dentry구조체 • 디렉토리엔트리를 모델화한 것 • d_parent : 디렉토리엔트리의 소유자 • d_name : 파일명 • d_inode : 파일명에 대응하는 inode • file 구조체 • 오픈한 파일을 관리(오픈 콘텍스트ex] current offset)

  4. VFS층의 데이터 구조(2/2) • super_block구조체 • 파일시스템표시, 파일시스템과 super_block은 1:1 대응 • 디스크 상의 파일시스템 관리 정보에서 유래함 • 각 파일 시스템에 공통된 관리 정보를 다룸 • vfsmount구조체 • 마운트된파일시스템의 위치 관계를 관리 • 파일시스템의 이름 공간을 구성하기 위한 구조체

  5. 오픈 파일 관리 task_struct 포인터 배열 file_struct file 구조체 file 구조체 file 구조체 file 구조체 file fdtable fd

  6. 오픈 파일 관리 file 구조체 file 구조체 task_struct task_struct file_struct file_struct file file fdtable fdtable fd fd dentry구조체 d_inode inode구조체 • 1개의 파일이 2회 오픈 되었을 때

  7. 리눅스저수준 파일 입출력 시스템 호출 함수 • open() – 파일이나 장치를 열거나 생성한다. • 함수의 원형 • 파일 생성 및 열기가 성공 하면, 해당 파일을 지시하는 int형의 파일 지시자를 반환한다. • Flag는 파일을 어떤 모드로 열 것인가를 결정 한다. (O_RDONLY, O_WRONLY, O_RDWR) • 에러가 발생 하면 -1을 반환 한다.

  8. 함수 위치? • file open 시스템 콜 호출시커널에서 이뤄지는 동작을 소스 레벨로 확인 해 보려했으나sys_open() 함수를 찾지 못했음. (요청한 파일에 대한 inode로 어떻게 접근 하는가?) • 2.6버전대커널에서는fs/open.c에 존재 했음 • asmlinkage long sys_open(const char __user * filename, int flags, int mode)

  9. fs/open.c – 소스 분석 • do_sys_open() • 2.6 버전 asmlinkage long sys_open() 함수와 가장 유사.

  10. fs/open.c – 소스 분석 • open_flags구조체 • build_open_flags() mode, flags를 바탕으로 내용을 채움 • get_unused_fd_flags(); • task_struct -> files_struct안에 있는 멤버 fdtable의 fd포인터 배열인덱스를 받음 • alloc_fd : • do_filp_open()

More Related