1 / 6

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) 트리의 산책이 종료되는 경우 1) leaf 에 도달 2) 오류 발생

mavis
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) • 트리의 산책이 종료되는 경우 1) leaf에 도달 2) 오류 발생 3) 사용자가 정의한 함수가 0가 아닌 값을 return

  2. Chapter 4 • ftw 예제 (p104) test1.c • stat에 의해 획득한 정보 list test2.c • 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 • 파일시스템 (p106) • 부트스트랩 블록 • 수퍼블록 • 파일시스템의 총 크기 • inode들을 위해 분비된 블록수 • 파일시스템이 마지막으로 갱신된 날짜와 시간 • 가용 자료 블록 번호 리스트 • 가용 inode 번호 리스트 • inode 블록 • 자료 블록

  4. Chapter 4 • 파일시스템 (p106) • 부트스트랩 블록 • 수퍼블록 • 파일시스템의 총 크기 • inode들을 위해 분비된 블록수 • 파일시스템이 마지막으로 갱신된 날짜와 시간 • 가용 자료 블록 번호 리스트 • 가용 inode 번호 리스트 • inode 블록 • 자료 블록

  5. Chapter 4 • void sync(void) : 파일시스템에 관한 정보를 포함하고 있는 모든 주메모리 버퍼를 flush • int fsync(int filedes) : 한 특정 파일과 연관된 모든 자료와 속성을 flush • 차이점 • fsync는 모든 파일 데이터가 디스크에 쓰여지기 전까지는 복귀하지 않음 • sync는 자료의 쓰기가 schedule되면 쓰기 완료전에 복귀 • sync는 복귀 값이 없음. fsync는 성공시 0, 오류시 -1을 복귀 • /dev (pp.108~109)

  6. Chapter 4 • block device • 디스크와 같이 자료 이동이 블록 단위로 발생. block device driver에 의해 제어 • block device switch table • st_mode는 파일 허가에 060000를 더한 값을 갖는다 (S_IFBLK) • character device • 단말기 프린터와 같이 임의 길이의 바이트열로 자료 이동이 발생 • character device switch table • st_mode는 파일 허가에 020000을 더한 값을 갖는다 (S_IFCHR)

More Related