나무 숲

File System 본문

Career

File System

wood.forest 2016. 6. 6. 01:19

File Concept

- File

* Logical storage unit - abstract the physical properties of the storage저장 장치의 물리적 속성 추상화

* A file has a certain defined structure, which depends on its type (text, source, object, executable...)


-File Attributes

* Name 사람이 읽을 수 있는 형태로 유지된 정보

* Identifier 파일 시스템 내에서 파일을 구분하는 고유의 태그(숫자)

* Type 파일 형식

* Location 파일이 존재하는 장치와 그 장치 내의 위치에 대한 포인터

* Size 파일의 현재 크기 (byte, block..)

* Protection 접근 제어 정보(rwx...)

* Time, date, and user identification 생성, 최근 변경,  최근 사용 등을 유지 (보호, 보안 및 사용자 감시 위해 사용)

A file's attributes vary from one operating system to another


- Modern OSes support very few file structures

file은 application에게는 의미가 있지만 기계에게는 없다(모름) 따라서 OS는 고유의 디렉토리 구조를 통해 해당 파일의 정보를 가져온다

모든 파일에 대한 정보는 보조저장장치에 상주하는 디렉토리 구조에 의해서 유지됨



Internal File Structure

- Disk provides OS with a block abstraction(e.g 512bytes)

* All disk I/O is performed in number of blocks


- Each file is stored in a number of blocks                     

아래 그림의 흰 빈 부분이 internal fragmentation. 남는 공간이 있어도 블락 단위로 할당됨을 알 수 있다



File Operations

- File is an abstract data type

- File Operations

* Create

* Write

* Reposition within file 파일 내용 변경 등등

* Delete 파일 삭제

* Truncate 속성값을 유지하면서 파일 값 지움

-> Most of the file operations involve searching the directory for the entry associated with the name file

-> To avoid this constant searching, many systems require that an open() system call be made before a file is first used

* Open : Search the directory structure on disk for the named file and move the content of entry to memory

* Close: Move content of entry to directory structure on disk



Open Files

- several pieces of data are needed to manage open files

* File pointer : A pointer to last read/write location, per process that has the file open

* File-open counter : Counter of the number of times a file is open-> to allow removal of data from open-file table when last process closes it

* Disk location of the file : Cache of the data access information

* Access right : Per-process access made information


- Open File Locking

* Shared lock : akin to a reader lock   읽기lock과 비슷. 여러 사람이 동시에 읽을 수 있다

  Exclusive lock : akin to a writer lock   쓰기lock과 비슷. 여러 사람이 동시에 쓸 수 없다

* Mandatory : access is denied depending on locks held and requested

  Advisory : processes can find status of locks and decide what to do



Access Methods

- The information in the file can be accessed in several ways

Sequential access : Information in the file is processed in order, one record after the other


만약 그림에서 beginning~current position 가운데에 원하는 지점이 있다고 하면  

current position에서 beginning까지 간 후 하나씩 읽어서 원하는 지점까지 간다

 sequential access

implementation for direct access 

 reset

 cp=0;

 read next

 read cp; cp+=1;

 write next

 write cp; cp+=1;

* Direct access : A file is made up of fixed-length logical records that allow programs to r/w records rapidly in no particular order



- Variant of Direct Access Method

* To find a record in the file, the index is searched and the pointer is used to access the file directly and to find the desired record

* Index contains pointers to the various blocks

* With large files, the index file itself may become too large to be kept in memory



Disk Structure

- Disk can be subdivided into partitions


- Disks or partitions can be used raw - without file system, or formatted with a file system


- Entity containing file system is known as a volume


- Each volume containing file system also track that file system's info in device directory or volume table of contents



Directory

디렉토리 안에 파일들이 있다. 디렉토리는 파일에 대한 정보(이름, 타입 등..)를 가진 노드

- Directory can be viewed as a symbol table that translates file names into their directory entries


- Operations on directory

* Search for a file

* Create a file : add to directory

* Delete a file : erase form the directory

* List a directory 

* Rename a file

* Traverse the file system


- Directory must be organized to obtain 세 가지 관점에서 이해

* Efficiency : Locating a file quickly 파일을 빨리 찾을 수 있게

* Naming : Convenient to users (alias: pathname+inode, hard link: inode, soft link: path name)

* Grouping : Logical grouping of files by properties





- Single level directory

모든 사용자의 파일이 하나의 directory 아래에 위치해 있으며 각 파일은 유일한 이름을 가져야 한다




- Two-level directory

각 사용자는 자신의 UFD(user file directory)를 가져, 사용자 기반의 디렉토리 구분이 가능하다.

Path name은 사용자 이름+파일 이름을 통해 알 수 있다

서로 다른 유저들 간에 같은 이름의 파일을 가질 수 있다

효과적인 검색이 가능하다



- Three-Structured Directory

효과적인 서칭이 가능하고 grouping이 가능하다. 경로명Pathname이 절대적(root를 기준으로 밑으로 내려온다)이거나 상대적(현재 디렉토리를 기준으로 이동)일 수 있다



- Acyclic-Graph directory

디렉토리들이 서브디렉토리와 파일을 공유할 수 있도록 한다 (공유된 파일은 한 파일의 복사본이 아니다)

검색 알고리즘이 무한루프에 빠지거나 어떤 파일은 트리에서 끊어진 채로 참조 회수가 0이 되지 않을 수 있기 때문에 사이클이 없다

다른 파일 이름으로 같은 파일을 가리킬 수 있다(aliasing)

만약 파일이 삭제되었을 때, dangling pointers가 남아있을 수 있다. (파일은 없는데 링크만 살아있는 경우)

어쩌지?

모든 링크를 지운다->비쌈

그것을 다시 사용하려 할 때까지 링크를 남겨둔다

참조 회수가 0이 될 때까지 보존하기 위해, maintain file reference list to a file 혹은 variable and potentially large size of the file-reference list

참조 회수만 남겨둔다 (뭔말?)



- General Graph Directory

book과 avi를 보면 infinite loop에 빠질 수 있다

어쩌지?

서브디렉토리에 대한 링크는 없애고 파일만 링크하도록 한다

순환 알고리즘을 이용한다

필요없는 데이터 링크를 제거한다

파일 삭제에 대해서 acyclic graph와 비슷한 문제들이 생긴다







File System Mount

- 파일 시스템은 액세스 되기 전 반드시 마운트되어야 한다 (해당 파일 시스템에 접근하기 위해 반드시 마운트)

- 마운트되지 않은 파일 시스템은 mount point에 마운트 된다


a) existing

b) unmounted (pathname이 없다)

c) mounted (pathname을 따라 접근이 가능하다)





File Protection

- 파일 시스템은 controlled access를 제공한다

- Access Control Lists(ACLs) : for each file/directory, keep a list of all users and of all allowed accesses for each user

728x90
반응형

'Career' 카테고리의 다른 글

DeadLock Avoidance Algorithms  (0) 2016.06.08
RISC vs CISC  (0) 2016.06.07
Demand Paging  (0) 2016.06.05
Virtual Memory Management Strategy  (0) 2016.06.05
Memory Management  (0) 2016.06.04
Comments