• No results found

File Management Chapters 10, 11, 12

N/A
N/A
Protected

Academic year: 2021

Share "File Management Chapters 10, 11, 12"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

File Management

File Management

(2)

Requirements

Requirements

• For long-term storage:

ibl l f i f

– possible to store large amount of info. – info must survive termination of

processes processes

– multiple processes must be able to access concurrently

• Solution: store in units called files • Filesystem: part of the OS

responsible for providing file services to users & apps

(3)

File Management Functions

File Management Functions

• Identify and locate a selected file • Use a directory to describe the

location of all files plus their tt ib t

attributes

• Describe shared user access t l

control

• Blocking for access to files • Allocate files to free blocks

• Manage free storage for available blocks

(4)

Files

• You should already be familiar with:

– types (regular, directory, character/block special)

– naming – naming

– protections (e.g., -rwxr-xr-x bits in Linux) – operations (create, delete, open, read, etc.)p ( , , p , , )

• Two types of file access:

– Sequential: read all bytes/records from q y / beginning

– Random: read in any order

k t t t i l ti i fil • use seek to move to certain location in file • essential for database files

(5)

File Organization

File Organization

• How are files organized physically? • Five main organizations:

– pile

– sequential file

– indexed sequential fileq – indexed file

(6)

File Organization

File Organization

• The Pile

– Data collected in chronological order

– Records may have different fields – No structure

– Record access is by exhaustive search

(7)

Pile

Pile

(8)

Sequential File

Sequential File

• Fixed length records

• All fields the same (order and length)

• Key field

– Uniquely identifies the record

– Records are stored in key sequence

• New records go in separate log fileg p g

(9)

Sequential File

Sequential File

(10)

Indexed Sequential File

Indexed Sequential File

• Index provides a fast lookup capability

capability

• Contains key field and a pointer to i fil

main file

• Only select indices from main file are stored in the index (requires some sequential search of file)

• New records stored in separate overflow file

(11)

Indexed Sequential File

Indexed Sequential File

(12)

Indexed File

Indexed File

• Multiple indices for different key • Multiple indices for different key

fields

• Exhaustive index: one entry per • Exhaustive index: one entry per

record

P ti l i d l t d f • Partial index: only to records of

interest

• No restriction on placement of records

(13)

Indexed File

Indexed File

(14)

Direct (hashed) file

Direct (hashed) file

• Directly access a block at a Directly access a block at a known address

• Key field required for each • Key field required for each

record

• For very fast access • For very fast access

(15)

Directories

Directories

• What is a directory?

• Directory: a file owned by the OS

– accessible by file management routinesg – contains info about the files

• attributes, location, ownership

• You should already be familiar with:

– pathnames

– naming directories – permissions

(16)

File Directories

(17)

File Directories

File Directories

(18)
(19)

File System

I

l

t ti

Implementation

A possible file system layout A possible file system layout

(20)

Physical Allocation of

Fil

Files

• How are files stored on disk? • Several approaches:

– contiguous allocationg – chained allocation

– indexed allocation

• Need some data structure to keep track of where files are on disk: file allocation table (FAT)

• Also need to track which disk blocks f

(21)

Methods of File

All

ti

Allocation

• Contiguous allocationContiguous allocation

– Contiguous set of blocks is allocated to a file at the time of creation

– Only a single entry in the file allocation table

• Starting block and length of the file

(22)
(23)

Contiguous Allocation

(24)

Contiguous Allocation

(25)

Methods of File

All

ti

Allocation

• Chained allocation

– Allocation on basis of individual block

– Each block contains a pointer to the next block

block

– Only single entry in the file allocation table

• Starting block and length of file

• No external fragmentation Best for sequential files

• Best for sequential files

• No accommodation of the principle of locality

(26)
(27)

Chained Allocation

(28)

Methods of File

All

ti

Allocation

• Indexed allocationIndexed allocation

– File allocation table contains a separate one-level index for each file

– The index is a block

– Index has one entry for each portion Index has one entry for each portion allocated

(29)
(30)

Indexed Allocation:

V i bl L

th P ti

(31)

FATs vs. I-nodes

FATs vs. I nodes

• File Allocation Table (FAT):

– tracks location of files on disk

– disadvantage: entire table must be in RAM

• Index-nodes (I-nodes):( )

– small data structure, one per file

– lists attributes and disk addresses of s s a bu s a d d s add ss s o file’s blocks

– advantage: I-node need be in RAM g only when file is opened

(32)
(33)
(34)

I-nodes on Disk

I nodes on Disk

(35)

Implementing Directories

(a) A simple directory (a) A simple directory

fixed size entries

disk addresses and attributes in directory entry (b) Directory in which each entry just refers to (b) Directory in which each entry just refers to

(36)

Implementing Directories

• Two ways of handling long file names in di ecto

directory

– (a) In-line

(37)

Free Space Management

Free Space Management

• Must know what blocks on disk are available • Bit Tables

– One bit per block on disk

– Still can be sizeable -- consider searching!

• Chained Free Portions • Chained Free Portions

– Chain together free blocks on disk – Disk will become fragmented

Indexing • Indexing

– Use an index table like file allocation

• Free Block List

– Each free block is numbered and stored in loc on disk – Doesn’t require search like bit table

References

Related documents

§ All pharmaceutical waste is collected in hazardous waste containers. § Mixed waste is removed to the central hazardous

When a block is moved from disk into main memory, change all the disk addresses that point to items in this block into main memory addresses. Need a bit for each address to

For added security, the Global Reporting and Account Management tool offers a secondary authentication process – Dual Authentication – that requires you to respond to a

I am very happy with my cell phone account that I can manage through the ATT Store in Argyle which has always provided me with outstanding service; However, problems that require the

Of view that surpasses the videos that is stolen there are two require existing wired chime that video doorbell require subscription offers, but offers cannot be combined with

[r]

•  The blocking factor for a file is the (average) number of file records stored in a disk block. •  The physical disk blocks that are allocated to hold the records of a file

• For a system with n disks, each file is split into n parts, one part stored on each disk. • Improves speed, but