chapter 10: file systems

31
10.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts Chapter 10: File Systems Chapter 10: File Systems File Concept Access Methods File System Structure Protection Efficiency and Performance

Upload: ray-petty

Post on 03-Jan-2016

24 views

Category:

Documents


0 download

DESCRIPTION

Chapter 10: File Systems. File Concept Access Methods File System Structure Protection Efficiency and Performance. The file system is the most visible aspect of an operating system. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 10:  File Systems

10.1 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Chapter 10: File SystemsChapter 10: File Systems

File Concept

Access Methods

File System Structure

Protection

Efficiency and Performance

Page 2: Chapter 10:  File Systems

10.2 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

The file system is the most visible aspect of an operating system.

It provides the mechanism for on-line storage of and access to both data and programs that belong to the operating system and to all the users of the computer system.

The file system consists of two distinct parts:

a collection of files, each storing related data

a directory structure, which organizes and provides information about all the files in the system.

Page 3: Chapter 10:  File Systems

10.3 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File ConceptFile Concept

A file is a named collection of related information that is recorded on secondary storage.

A file is a logical storage unit. Files are mapped by the OS onto physical devices.

These storage devices are usually nonvolatile.

The information in a file is defined by its creator.

Types: Data

numeric

character

binary

Program

Page 4: Chapter 10:  File Systems

10.4 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File StructureFile Structure

None - sequence of words, bytes Simple record structure

Lines Fixed length Variable length

Complex Structures Formatted document Relocatable load file

Can simulate last two with first method by inserting appropriate control characters.

Who decides: Operating system Program

Page 5: Chapter 10:  File Systems

10.5 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File AttributesFile Attributes

Name – 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 6: Chapter 10:  File Systems

10.6 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File OperationsFile Operations

Create

Write

Read

Reposition within file – file seek

Delete

Truncate

Open(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 7: Chapter 10:  File Systems

10.7 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File Types – Name, ExtensionFile Types – Name, Extension

Page 8: Chapter 10:  File Systems

10.8 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Access MethodsAccess Methods Sequential Access

read nextwrite next resetno read after last write

(rewrite) Direct Access

read nwrite nposition to n

read nextwrite next

rewrite n

n = relative block number

Page 9: Chapter 10:  File Systems

10.9 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Sequential-access FileSequential-access File

Page 10: Chapter 10:  File Systems

10.10 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Simulation of Sequential Access on a Direct-access FileSimulation of Sequential Access on a Direct-access File

Page 11: Chapter 10:  File Systems

10.11 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Example of Index and Relative FilesExample of Index and Relative Files

Page 12: Chapter 10:  File Systems

10.12 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Directory StructureDirectory Structure

A collection of nodes containing information about all files.

F 1 F 2F 3

F 4

F n

Directory

Files

Both the directory structure and the files reside on disk.Backups of these two structures are kept on tapes.

Page 13: Chapter 10:  File Systems

10.13 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

A Typical File-system OrganizationA Typical File-system Organization

Page 14: Chapter 10:  File Systems

10.14 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Information in a Device DirectoryInformation in a Device Directory

Name

Type

Address

Current length

Maximum length

Date last accessed (for archival)

Date last updated (for dump)

Owner ID

Protection information

Page 15: Chapter 10:  File Systems

10.15 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Operations Performed on DirectoryOperations Performed on Directory

Search for a file

Create a file

Delete a file

List a directory

Rename a file

Traverse the file system

Page 16: Chapter 10:  File Systems

10.16 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Organize the Directory (Logically) to ObtainOrganize the Directory (Logically) to Obtain

Efficiency – locating a file quickly.

Naming – convenient to users. Two users can have same name for different files.

The same file can have several different names.

Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …)

Page 17: Chapter 10:  File Systems

10.17 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Single-Level DirectorySingle-Level Directory

A single directory for all users.

Naming problem

Grouping problem

Page 18: Chapter 10:  File Systems

10.18 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Two-Level DirectoryTwo-Level Directory

Separate directory for each user.

•Path name•Can have the same file name for different user•Efficient searching•No grouping capability

Page 19: Chapter 10:  File Systems

10.19 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Tree-Structured DirectoriesTree-Structured Directories

Page 20: Chapter 10:  File Systems

10.20 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Tree-Structured Directories (Cont.)Tree-Structured Directories (Cont.)

Efficient searching

Grouping Capability

Current directory (working directory) cd /spell/mail/prog

type list

Page 21: Chapter 10:  File Systems

10.21 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Tree-Structured Directories (Cont.)Tree-Structured Directories (Cont.)

Absolute or relative path name Creating a new file is done in current directory. Delete a file

rm <file-name> Creating a new subdirectory is done in current directory.

mkdir <dir-name>

Example: if in current directory /mail

mkdir count

mail

prog copy prt exp count

Deleting “mail” deleting the entire subtree rooted by “mail”.

Page 22: Chapter 10:  File Systems

10.22 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Acyclic-Graph DirectoriesAcyclic-Graph Directories

Have shared subdirectories and files.

Page 23: Chapter 10:  File Systems

10.23 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Acyclic-Graph Directories (Cont.)Acyclic-Graph Directories (Cont.)

Two different names (aliasing)

If dict deletes list dangling pointer.

Solutions: Backpointers, so we can delete all pointers.

Variable size records a problem.

Backpointers using a daisy chain organization.

Entry-hold-count solution.

Page 24: Chapter 10:  File Systems

10.24 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

General Graph DirectoryGeneral Graph Directory

Page 25: Chapter 10:  File Systems

10.25 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

General Graph Directory (Cont.)General Graph Directory (Cont.)

How do we guarantee no cycles? Allow only links to file not subdirectories.

Garbage collection.

Every time a new link is added use a cycle detectionalgorithm to determine whether it is OK.

Page 26: Chapter 10:  File Systems

10.26 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File System MountingFile System Mounting

A file system must be mounted before it can be accessed.

A unmounted file system is mounted at a mount point.

Page 27: Chapter 10:  File Systems

10.27 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

(a) Existing. (b) Unmounted Partition(a) Existing. (b) Unmounted Partition

Page 28: Chapter 10:  File Systems

10.28 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Mount PointMount Point

Page 29: Chapter 10:  File Systems

10.29 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

File SharingFile Sharing

Sharing of files on multi-user systems is desirable.

Sharing may be done through a protection scheme.

On distributed systems, files may be shared across a network.

Network File System (NFS) is a common distributed file-sharing method.

Page 30: Chapter 10:  File Systems

10.30 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

ProtectionProtection

File owner/creator should be able to control: what can be done

by whom

Types of access Read

Write

Execute

Append

Delete

List

Page 31: Chapter 10:  File Systems

10.31 Silberschatz, Galvin and Gagne ©2003Operating System Concepts

Access Lists and GroupsAccess Lists and Groups Mode of access: read, write, execute (RWX)

e.g. RWX = 110 = 6 Three classes of users

a) owner access

b) group access

c) public access Ask manager to create a group (unique name), say G, and add

some users to the group. For a particular file (say game) or subdirectory, define an

appropriate access.

owner group public

chmod 761 game

Attach a group to a file chgrp G game