File Management - Texas A&M University

嚜澧PSC 410 / 611 : Operating Systems

File Management

File Management

? What is a file?

? Elements of file management

? File organization

? Directories

? File allocation

What is a File?

A file is a collection of data elements, grouped together for

purpose of access control, retrieval, and modification

Persistence: Often, files are mapped onto physical storage devices,

usually nonvolatile.

Some modern systems define a file simply as a sequence, or stream

of data units.

A file system is the software responsible for

每 creating, destroying, reading, writing, modifying, moving files

每 controlling access to files

每 management of resources used by files.

1

CPSC 410 / 611 : Operating Systems

File Management

The Logical View of File Management

user

? directory management

? access control

file structure

? access method

records

? blocking

physical blocks in memory

? disk scheduling

? file allocation

physical blocks on disk

File Management

?

?

?

?

?

?

What is a file?

Elements of file management

File organization

Directories

file structure

File allocation

UNIX file system

user

records

? directory management

? access control

? access method

physical blocks in memory

? blocking

physical blocks on disk

? disk scheduling

? file allocation

2

CPSC 410 / 611 : Operating Systems

File Management

Logical Organization of a File

? A file is perceived as an ordered collection of records,

R0, R1, ..., Rn.

? A record is a contiguous block of information transferred during

a logical read/write operation.

? Records can be of fixed or variable length.

? Organizations:

每 Pile

每 Sequential File

每 Indexed Sequential File

每 Indexed File

每 Direct/Hashed File

Pile

? Variable-length records

? Chronological order

? Random access to record by

search of whole file.

? What about modifying

records?

Pile File

3

CPSC 410 / 611 : Operating Systems

File Management

Sequential File

? Fixed-format records

? Records often stored in

key field

order of key field.

? Good for applications that

process all records.

? No adequate support for

random access.

? Q: What about adding new

record?

? A: Separate pile file keeps

Sequential File

log file or transaction file.

Indexed Sequential File

? Similar to sequential file,

with two additions.

每 Index to file supports

random access.

每 Overflow file indexed

from main file.

? Record is added by

appending it to overflow file

and providing link from

predecessor.

index

main file

overflow file

Indexed Sequential File

4

CPSC 410 / 611 : Operating Systems

File Management

Indexed File

? Variable-length

records

? Multiple Indices

index

index

partial

index

? Exhaustive index vs.

partial index

File Representation to User (Unix)

file descriptor

table

system file

table

in-memory

inode table

[0]

UNIX File Descriptors:

int myfd;

[1]

myfd = open(※myfile.txt§, O_RDONLY);

[2]

[3]

[4]

file structure

file descriptor

table

[0]

myfd

[1]

3

[2]

[3]

user space

kernel space

[4]

3

ISO C File Pointers:

FILE *myfp;

myfp = fopen(※myfile.txt§, ※w§);

myfp

user space

kernel space

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download