-
[week4]File I/OComputer Science🖥️/System Programming 2021. 12. 6. 10:53
<File / Directory Concept>
1. What is File?
- Linux file은 byte의 나열이다. // kernel, HW partition 등 모두 file로 표현이 된다.
- All I/O devices 은 파일로 표현된다.
- /dev/sda1 (hard disk partition)
- /dev/tty2 (terminal) //ctrl + alt + F1~F7 (termianl 이동 단축키)
2. File Types
- 각 파일은 시스템 안에서의 역할을 가리키는 type을 갖고 있다.
- Regular file: 임의의 데이터를 담는 파일
- Directory: 관련된 파일의 그룹을 만들어 가리키는 그룹의 index
- Socket: another machine에서 프로세스로 소통하기 위해 필요한 것
1) Regular file
: 임의의 데이터(특정 data)를 담고있는 파일
- text file 과 binary file을 종종 구별한다.
- Text file은 대체로 아스키/ 유니코드 글자로 작성되는 regular file을 의미한다.
- Binary file 은 모든 파일을 표현 가능하다. // object file, JPEG images...
- 하지만 kernel은 이들의 차이를 알지 못한다.
2) Directory
: link들의 배열로 이루어져 있다. // 각 링크는 file을 filename으로 mapping한 것을 의미한다.
- Directory Hierarchy
- 모든 파일은 '/'(slash)의 이름을 가진 root directory에 의해 tree 형태로 조직되어 있다.
- kernel은 current working directory(cwd) 를 각 processd에서 관리한다.
- Pathnames
- pathname에 의해 파일의 계층적 위치를 표현한다. -> 표현방법: 절대경로, 상대경로가 존재
<Unix I/O>
<Standard I/O>
1. Standard I/O functions
: C standard library(libc.so)는 higher-level의 standard I/O functions의 집합을 포함한다.
// unix I/O와 matching 되는 함수들이 존재한다.
ex) standard I/O functions
- open, close files : fopen(), fclose()
- read, write bytes : fread(), fwrite()
- read, write text lines : fgets(), fputs()
- formatted reading and writing : fscanf(), fprintf()
2. Standard I/O Streams
'Computer Science🖥️ > System Programming' 카테고리의 다른 글
[week3] Shell script & Makefile (0) 2021.12.06