chapter 13

Post on 31-Jan-2016

32 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

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

File Systems

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

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.

Types of FilesSource programsObject programsExecutable programsNumeric dataGraphic imagesSound recording

File Types

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.

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.

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.

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.

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

File Structure

Access MethodsThe information in the file can be accessed in

several ways.Common access methods are:

Sequential accessDirect accessIndexed methods

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.

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.

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.

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.

Directory Structure

F 1 F 2 F 3 F 4

F n

Directory

Files

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)

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

Single-Level Directory

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

Two-Level Directory

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.

Tree-Structured or Hierarchical Directory Systems

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.

A UNIX directory tree

top related