출처: https://3months.tistory.com/307 [Deep Play]

4-1/시스템프로그래밍

Metadata, sharing and redirection

코딩하는 랄뚜기 2022. 4. 4. 10:39

File Metadate

 

 

Metadata는 data에 대한 data이다.

stat 그리고 fstat 함수를 이용하여 접근할 수 있다.

 


 

How the Unix Kernel Represents Open Files

 

Descriptor table, Open file table, v-node table 모두 kernel 영역에 있다.

v-node table에는 file의 meta data가 있고 이 정보를 통해 Disk에 있는 file정보를 불러올 수 있다.

 


 

File Sharing

두 개의 descriptor가 같은 file에 access하게 되면 아래와 같은 구조로 접근하게 된다.

 

같은 file에 접근하더라도 descriptor들은 다른 open file table entry를 가지고 있고 다른 open file table이 같은 v-node table을 가리킨다. Open file table은 file에 대한 정보를 담고 있다기 보다는 file descriptor에 대한 정보를 담고 있다고 보는 것이 맞는 것 같다.

 


 

How Process Share Files : fork

 

 

Fork를 띄우게 되면 child process는 parent process와 open file table을 공유하게 된다. refcnt는 몇 개의 process가 자신을 참조하고 있는지 나타낸다.

 


 

I/O Redirection

 

I/O redirection이란 file descriptor에 있는 값을 변경하는 것이다.

 

 

dup,dup2 함수를 사용하여 I/O redirection을 구현 할 수 있다.

 

'4-1 > 시스템프로그래밍' 카테고리의 다른 글

Network Programming  (0) 2022.04.05
Standard I/O, Unix I/O vs Standard I/O vs RIO  (0) 2022.04.04
Unix I/O, RIO package  (0) 2022.04.04
Signal  (0) 2022.03.28
Shell  (0) 2022.03.22