Chapter 10: File-System Interface File Concept File Structure File ...

8 downloads 2460 Views 281KB Size Report
1. Chapter 10: File-System Interface. 10.2. Silberschatz, Galvin and Gagne © 2005. Operating System Concepts – 7th Edition, Jan 1, 2005. File Concept.
File Concept „ Contiguous logical address space „ Types: z

Data  numeric

Chapter 10: FileFile-System Interface

 character  binary z

Program

Operating System Concepts – 7th Edition, Jan 1, 2005

File Structure

10.2

Silberschatz, Galvin and Gagne ©2005

File Attributes

„ None - sequence of words, bytes

„ Name – only information kept in human-readable form

„ Simple record structure

„ Identifier – unique tag (number) identifies file within file system

z

Lines

„ Type – needed for systems that support different types

z

Fixed length

„ Location – pointer to file location on device

z

Variable length

„ Size – current file size

„ Complex Structures z

Formatted document

z

Relocatable load file

„ Protection – controls who can do reading, writing, executing „ Time, date, and user identification – data for protection, security,

and usage monitoring

„ Can simulate last two with first method by inserting appropriate

control characters

„ Information about files are kept in the directory structure, which is

maintained on the disk

„ Who decides: z

Operating system

z

Program

Operating System Concepts – 7th Edition, Jan 1, 2005

10.3

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts – 7th Edition, Jan 1, 2005

File Operations

10.4

Silberschatz, Galvin and Gagne ©2005

Open Files „ Several pieces of data are needed to manage open files:

„ File is an abstract data type „ Create

z

File pointer: pointer to last read/write location, per process that has the file open

z

File-open count: counter of number of times a file is open – to allow removal of data from open-file table when last processes closes it

„ Delete

z

Disk location of the file: cache of data access information

„ Truncate

z

Access rights: per-process access mode information

„ Write „ Read „ Reposition within file

„ 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

Operating System Concepts – 7th Edition, Jan 1, 2005

10.5

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts – 7th Edition, Jan 1, 2005

10.6

Silberschatz, Galvin and Gagne ©2005

1

File Types – Name, Extension

Access Methods „

Sequential Access read next write next reset no read after last write (rewrite)

„

Direct Access read n write n position to n read next write next rewrite n n = relative block number

Operating System Concepts – 7th Edition, Jan 1, 2005

10.7

Silberschatz, Galvin and Gagne ©2005

SequentialSequential-access File

Operating System Concepts – 7th Edition, Jan 1, 2005

10.9

Silberschatz, Galvin and Gagne ©2005

A Typical FileFile-system Organization

Operating System Concepts – 7th Edition, Jan 1, 2005

10.8

Silberschatz, Galvin and Gagne ©2005

Example of Index and Relative Files

Operating System Concepts – 7th Edition, Jan 1, 2005

10.10

Silberschatz, Galvin and Gagne ©2005

Operations Performed on Directory „ Search for a file „ Create a file „ Delete a file „ List a directory „ Rename a file „ Traverse the file system

Operating System Concepts – 7th Edition, Jan 1, 2005

10.11

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts – 7th Edition, Jan 1, 2005

10.12

Silberschatz, Galvin and Gagne ©2005

2

SingleSingle-Level Directory

TwoTwo-Level Directory „ Separate directory for each user

„ A single directory for all users

Naming problem „ Path name

Grouping problem

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

Operating System Concepts – 7th Edition, Jan 1, 2005

10.13

Silberschatz, Galvin and Gagne ©2005

TreeTree-Structured Directories

Operating System Concepts – 7th Edition, Jan 1, 2005

10.14

Silberschatz, Galvin and Gagne ©2005

TreeTree-Structured Directories (Cont) „ Efficient searching „ Grouping Capability „ Current directory (working directory)

Operating System Concepts – 7th Edition, Jan 1, 2005

10.15

Silberschatz, Galvin and Gagne ©2005

TreeTree-Structured Directories (Cont)

z

cd /spell/mail/prog

z

type list

Operating System Concepts – 7th Edition, Jan 1, 2005

10.16

Silberschatz, Galvin and Gagne ©2005

AcyclicAcyclic-Graph Directories „ Have shared subdirectories and files

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

rm „ Creating a new subdirectory is done in current directory

mkdir Example: if in current directory /mail mkdir count

mail prog

copy prt exp count

Deleting “mail” ⇒ deleting the entire subtree rooted by “mail” Operating System Concepts – 7th Edition, Jan 1, 2005

10.17

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts – 7th Edition, Jan 1, 2005

10.18

Silberschatz, Galvin and Gagne ©2005

3

General Graph Directory

File System Mounting „ A file system must be mounted before it can be

accessed „ A unmounted file system (i.e. Fig. 11-11(b)) is

mounted at a mount point

Operating System Concepts – 7th Edition, Jan 1, 2005

10.19

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts – 7th Edition, Jan 1, 2005

(a) Existing. (b) Unmounted Partition

Operating System Concepts – 7th Edition, Jan 1, 2005

10.21

Silberschatz, Galvin and Gagne ©2005

Mount Point

Operating System Concepts – 7th Edition, Jan 1, 2005

Protection what can be done

z

by whom

„

Mode of access: read, write, execute

„

Three classes of users

„ Types of access z

Read

z

Write

z

Execute

z

Append

z

Delete

z

List

Silberschatz, Galvin and Gagne ©2005

10.22

Access Lists and Groups

„ File owner/creator should be able to control: z

Silberschatz, Galvin and Gagne ©2005

10.20

a) owner access

7



b) group access

6



c) public access

1



RWX 111 RWX 110 RWX 001

„

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 chmod

group

public

761

game

Attach a group to a file chgrp Operating System Concepts –

7th

Edition, Jan 1, 2005

10.23

Silberschatz, Galvin and Gagne ©2005

Operating System Concepts –

7th

Edition, Jan 1, 2005

G

game

10.24

Silberschatz, Galvin and Gagne ©2005

4

Windows XP AccessAccess-control List Management

Operating System Concepts – 7th Edition, Jan 1, 2005

10.25

Silberschatz, Galvin and Gagne ©2005

A Sample UNIX Directory Listing

Operating System Concepts – 7th Edition, Jan 1, 2005

10.26

Silberschatz, Galvin and Gagne ©2005

End of Chapter 10

5