1 / 8

Chapter 4

Chapter 4. chdir 한 프로그램이 주어진 디렉토리에서 많은 파일들을 접근할 필요가 있을 때 유용 getcwd ftw 주어진 디렉토리로 부터 출발하여 그 디렉토리의 아래에 있는 모든 파일과 부디렉토리에 대한 작업을 진행 int ftw(const char *path, int(*func)(), int depth) int func(const char *name, const struct stat *sptr, int type) Flag FTW_F FTW_D FTW_DNR FTW_SL FTW_NS

talen
Télécharger la présentation

Chapter 4

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. Chapter 4 • chdir • 한 프로그램이 주어진 디렉토리에서 많은 파일들을 접근할 필요가 있을 때 유용 • getcwd • ftw • 주어진 디렉토리로 부터 출발하여 그 디렉토리의 아래에 있는 모든 파일과 부디렉토리에 대한 작업을 진행 • int ftw(const char *path, int(*func)(), int depth) • int func(const char *name, const struct stat *sptr, int type) • Flag • FTW_F • FTW_D • FTW_DNR • FTW_SL • FTW_NS • 트리의 산책이 종료되는 경우 1) leaf에 도달 2) 오류 발생 3) 사용자가 정의한 함수가 0가 아닌 값을 return

  2. Chapter 4 • ftw 예제 (p104) test1.c • stat에 의해 획득한 정보 list test2.c • (HW) test1.c와 test2.c를 수정하여 모든 내용에 대해 ls –al 명령어와 유사한 일을 수행하도록 하는 프로그램 작성 a. subdir을 생성 b. subdir안에 hard link 파일 2개, symbolic link 파일 2개, subsubdir을 생성 ln originalfile hardfile1 ln originalfile hardfile2 ln –s originalfile softfile1 ln –s originalfile softfile2 c. subsubdir안에 hard link 파일 2개, symbolic link 파일 2개, subsubdir을 생성

  3. Chapter 4 • 전통적 파일 시스템 (그림 4.6) • 슈퍼블록 • 파일 시스템의 총 크기 • inode 들을 위해 준비한 블록의 수 • 파일 시스템이 마지막으로 갱신한 날짜와 시간 • 가용 자료 블록 번호들의 체인 저장한 리스트 • 가용 inode 번호들에 대한 체인을 저장한 리스트 • inode 블록 • 자료 블록

  4. 일반 Ext2 디렉토리 MS_DOS 디스켓마운트 포인트 cp $ cp /floppy /TEST / tmp /test VFS int = open(“/floppy/TEST”, O_RDONLY, 0);outf = open(“/tmp/test”, O_WRONLY|O_CREATE|O_TRUNC, 0600);do { l = read(inf, buf, 4096); write(outf, buf, l);} while (l);close(outf);close(inf); Ext2 MS-DOS /tmp/test /floppy/TEST Chapter 4 • 가상 파일 시스템(VFS:Virtual File System)

  5. 부트 블록 블록그룹 0 ∙ ∙ ∙ ∙ ∙ 블록그룹 n 1블록 N블록 1블록 1블록 N블록 N블록 수퍼 블록 그룹 디스크립터 데이터 블록 비트맵 아이노드 비트맵 아이노드 테이블 데이터 블록 Chapter 4 • EXT2 파티션과 각 블록 그룹의 내부 배치

  6. 총 아이노드의 수, 파이시스템 크기, 불록 크기, 단편 크기, 그룹당 아이노드수, Kernel VFS ext2 H/W i_dev, i_ino, i_mode, i_nlink i_rdev, i_size i_atime, ctime, mtime ….. i_op … inode Meta data Super block free free free free free free free free free free free free 12 Direct block free free free free free free 3 indirect block

  7. Chapter 4 • int fsync(int filedes); void sync(void); p107 • sync는 파일 시스템에 관한 정보를 포함하고 있는 모든 주메모리 버퍼를 디스크에 write • fsync는 한 특정 파일과 연관된 모든 자료와 속성을 쓸때 호출 • fsync와 sync의 복귀 시점 • 오류 • Unix 장치 파일 • 특수파일들은 /dev에 저장 • Block device • 장치들과 커널 사이의 자료 이동이 블록 단위로 발생 • 디스크, 자기테이프 • Character device • 자료 전송이 임의 길이의 바이트 열로 발생 • 단말기, 프린터 • major number, minor number • 장치파일의 inode 안에 저장

  8. Chapter 4 • st_mode • 장치 파일의 경우, 허가+060000(블록장치), 허가+020000(문자장치) • S_IFBLK, S_IFCHAR • S_ISCHR, IS_DIR… • st_rdev • 주장지 번호와 소 장치 번호를 포함

More Related