chapter 13

26
File Systems

Upload: tuyen

Post on 31-Jan-2016

32 views

Category:

Documents


0 download

DESCRIPTION

Chapter 13. File Systems. Long Term Information Storage. Three essential requirements for long-term information storage: Must store large amounts of data Information stored must survive the termination of the process using it - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 13

File Systems

Page 2: Chapter 13

Long Term Information StorageThree essential requirements for long-

term information storage:Must store large amounts of dataInformation stored must survive the

termination of the process using itMultiple processes must be able to access the

information concurrently

Page 3: Chapter 13

What is a File?To abstract away the properties of the

storage device, the operating system defines a logical storage unit, called a file.

From the user point of view, a file is the smallest allotment logical secondary storage – that is, data cannot be written to secondary storage unless they are within a file.

Page 4: Chapter 13

Types of FilesSource programsObject programsExecutable programsNumeric dataGraphic imagesSound recording

Page 5: Chapter 13

File Types

Page 6: Chapter 13

File StructureA file has a certain defined structure

according to its type:A text file is a sequence of characters organized

into lineA source file is a sequence of functions each of

which is organized as declaration and executable statements

An object file is a sequence of bytes organized into blocks understandable by the system’s linker

An executable file is a series of code sections that the loader can bring into memory and execute.

Page 7: Chapter 13

File SystemFiles are managed by the operating system

(how they are named, structured, used etc).The part of the operating system dealing with

files is known is the file system.

Page 8: Chapter 13

File AttributesName – only information kept in human-readable

form.Type – needed for systems that support different

types.Location – pointer to file location on device.Size – current file size.Protection – controls who can do reading, writing,

executing.Time, date, and user identification – data for

protection, security, and usage monitoring.Information about files are kept in the directory

structure, which is maintained on the disk.

Page 9: Chapter 13

File OperationsCreateWriteReadReposition within file – file seekDeleteTruncateOpen(Fi) – search the directory structure on disk

for entry Fi, and move the content of entry to memory.

Close (Fi) – move the content of entry Fi in memory to directory structure on disk.

Page 10: Chapter 13

File StructureFile types may also be used to indicate the

internal structure of the file.Files can be structured in any of the several

ways.Three common possibilities are:

Byte sequenceRecord sequenceTree

Page 11: Chapter 13

File Structure

Page 12: Chapter 13

Access MethodsThe information in the file can be accessed in

several ways.Common access methods are:

Sequential accessDirect accessIndexed methods

Page 13: Chapter 13

Sequential AccessThe information is processed in order, one record

after the other.Read operation reads the next portion of the file and

advances the file pointer automatically.A write operation appends at the end of the file and

EOF is advanced.A rewind operation brings the file pointer to the

beginning of the file.

Page 14: Chapter 13

Direct or Relative AccessThe file is made up of fixed length logical

records.It allows arbitrary blocks to be read or

written. The read operation includes block number as

a parameter. The block number provided to the operating system is relative to the beginning/end of file or the current position of the file.

Page 15: Chapter 13

Indexed MethodsCan be built on the top of a direct-access method.Involve construction of an index which contains

pointers to the various blocks.To find a record, we first search the index, and then

use the pointer to access the file directly and find the desired record.

Page 16: Chapter 13

Directory StructureThe files on a secondary storage need to be organized

because a huge number of files which might be stored on it.

This is generally done in two steps:Disks are split into partitions (also called minidisk

or volumes). Each disk typically contains at least one partition.

Each partition contains information about files within it. This information is kept in entries in a device

directory (or simply a directory) or volume table of contents.

Page 17: Chapter 13

Directory Structure

F 1 F 2 F 3 F 4

F n

Directory

Files

Page 18: Chapter 13

Information in a Device DirectoryName TypeAddress Current lengthMaximum lengthDate last accessed (for archival)Date last updated (for dump)Owner ID (who pays)Protection information (discuss later)

Page 19: Chapter 13

Operation Performed on DirectorySearch for a fileCreate a fileDelete a fileList a directoryRename a fileTraverse the file system

Page 20: Chapter 13

Single-Level Directory

Page 21: Chapter 13

Two-Level DirectoryEach user has his own user file directory (UFD).Each UFD has a similar structure but lists only the

files of a single user.When a user job starts or user logs in, the system’s

master file directory (MFD) is searched.The MFD is indexed by user name or account number,

and each entry points to the UFD for that user.User directories can be created and deleted.

Path nameCan have the same file name for different userEfficient searchingNo grouping capability

Page 22: Chapter 13

Two-Level Directory

Page 23: Chapter 13

Tree-Structured or Hierarchical Directory SystemsA natural extension of two-level directory

system.It allows a user to create his own sub-

directories.A directory is simply another file but is

treated in a special way.A (sub)directory contains a list of files or sub-

directories.Special system calls are used to create and

delete sub-directories.

Page 24: Chapter 13

Tree-Structured or Hierarchical Directory Systems

Page 25: Chapter 13

Path NamesWhen file system is organized as a directory tree,

some way is needed for specifying file names.Two different methods are commonly used.Each file is given an absolute path name consisting

of the path from the root directory to the file (e.g. /usr/bin/cc).

The relative path name id used in conjunction with the concept of the working directory (or current working directory) and all path names are taken relative to the current working directory.

Tree structure prohibits the sharing of files or directories.

Page 26: Chapter 13

A UNIX directory tree