26
1 1 Silberschatz, Galvin and Gagne 2002 11. 1 Operating System Concepts Chapter 11: File-System Interface n File Concept n Access Methods n Directory Structure n File System Mounting n File Sharing n Protection

Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

11

Silberschatz, Galvin and Gagne 200211.1Operating System Concepts

Chapter 11: File-System Interface

n File Concept

n Access Methods

n Directory Structure

n File System Mounting

n File Sharing

n Protection

Page 2: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

22

Silberschatz, Galvin and Gagne 200211.2Operating System Concepts

File Concept

n Contiguous logical address space

n Types: F Data

4 numeric4 character4 binary

F Program

Page 3: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

33

Silberschatz, Galvin and Gagne 200211.3Operating System Concepts

File Structure

n None - sequence of words, bytesn Simple record structure

F Lines F Fixed lengthF Variable length

n Complex StructuresF Formatted documentF Relocatable load file

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

n Who decides:F Operating systemF Program

Page 4: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

44

Silberschatz, Galvin and Gagne 200211.4Operating System Concepts

File Attributes

n Name – only information kept in human-readable form.n Type – needed for systems that support different types.n Location – pointer to file location on device.n Size – current file size.n Protection – controls who can do reading, writing,

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

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

which is maintained on the disk.

Page 5: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

55

Silberschatz, Galvin and Gagne 200211.5Operating System Concepts

File Operations

n Createn Writen Readn Reposition within file – file seekn Deleten Truncate – set to zero lengthn Open(Fi) – search the directory structure on disk for entry

Fi, and move the content of entry to memory.n Close (Fi) – move the content of entry Fi in memory to

directory structure on disk.

Page 6: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

66

Silberschatz, Galvin and Gagne 200211.6Operating System Concepts

File Types – Name, Extension

Page 7: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

77

Silberschatz, Galvin and Gagne 200211.7Operating System Concepts

Access Methods

n Sequential Accessread nextwrite next reset

n Direct Accessread nwrite nposition to n

read nextwrite next

n = relative block number

Page 8: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

88

Silberschatz, Galvin and Gagne 200211.8Operating System Concepts

Sequential-access File

Page 9: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

99

Silberschatz, Galvin and Gagne 200211.9Operating System Concepts

Simulation of Sequential Access on a Direct -access File

Page 10: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1010

Silberschatz, Galvin and Gagne 200211.11Operating System Concepts

Directory Structure

n 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 11: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1111

Silberschatz, Galvin and Gagne 200211.12Operating System Concepts

A Typical File-system Organization

Page 12: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1212

Silberschatz, Galvin and Gagne 200211.13Operating System Concepts

Information in a Device Directory

n Name n Typen Address n Current lengthn Maximum lengthn Date last accessed (for archival)n Date last updated (for dump)n Owner ID (who pays)n Protection information (discuss later)

Page 13: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1313

Silberschatz, Galvin and Gagne 200211.14Operating System Concepts

Operations Performed on Directory

n Search for a filen Create a filen Delete a filen List a directoryn Rename a filen Traverse the file system

Page 14: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1414

Silberschatz, Galvin and Gagne 200211.15Operating System Concepts

Organize the Directory (Logically) to Obtain

n Efficiency – locating a file quickly.n Naming – convenient to users.

F Two users can have same name for different files.F The same file can have several different names.

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

Page 15: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1515

Silberschatz, Galvin and Gagne 200211.16Operating System Concepts

Single-Level Directory

n A single directory for all users.

Naming problem

Grouping problem

Page 16: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1616

Silberschatz, Galvin and Gagne 200211.17Operating System Concepts

Two-Level Directory

n Separate directory for each user.

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

Page 17: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1717

Silberschatz, Galvin and Gagne 200211.18Operating System Concepts

Tree-Structured Directories

Page 18: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1818

Silberschatz, Galvin and Gagne 200211.19Operating System Concepts

Tree-Structured Directories (Cont.)

n Efficient searching

n Grouping Capability

n Path names – absolute, relative

n Current directory (working directory)F cd /spell/mail/progF cat listF cd ../prtF cat first

Page 19: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

1919

Silberschatz, Galvin and Gagne 200211.20Operating System Concepts

Tree-Structured Directories (Cont.)

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

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

mkdir <dir-name>

Example: if in current directory /mailmkdir count

mail

prog copy prt exp count

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

Page 20: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2020

Silberschatz, Galvin and Gagne 200211.21Operating System Concepts

Acyclic-Graph Directories

n Have shared subdirectories and files.

Page 21: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2121

Silberschatz, Galvin and Gagne 200211.22Operating System Concepts

Acyclic-Graph Directories (Cont.)

n Two different names (aliasing)

n Hard links (location) or symbolic links (pathname)

n Deletion of shared files like /dict/all.Solutions:F Backpointers, so we can delete all pointers.

Variable size records a problem.F Backpointers using a daisy chain organization.F Hard: Entry-hold-count solution.F Symbolic: accept dangling pointers

Page 22: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2222

Silberschatz, Galvin and Gagne 200211.25Operating System Concepts

File System Mounting

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

n A unmounted file system (I.e. Fig. 11-11(b)) is mounted at a mount point.

Page 23: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2323

Silberschatz, Galvin and Gagne 200211.26Operating System Concepts

(a) Existing. (b) Unmounted Partition

Page 24: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2424

Silberschatz, Galvin and Gagne 200211.27Operating System Concepts

Mount Point

Page 25: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2525

Silberschatz, Galvin and Gagne 200211.29Operating System Concepts

Protection

n File owner/creator should be able to control:F what can be doneF by whom

n Types of accessF ReadF WriteF ExecuteF AppendF DeleteF List

Page 26: Chapter 11: File-System Interface - Kentfarrell/osf03/lectures/ch11-1up.pdf · 44 Operating System Concepts 11.4 Silberschatz, Galvin and Gagne 2002 File Attributes n Name – only

2626

Silberschatz, Galvin and Gagne 200211.30Operating System Concepts

Access Lists and Groupsn Mode of access: read, write, executen Three classes of users

RWXa) owner access 7 ⇒ 1 1 1

RWXb) group access 6 ⇒ 1 1 0

RWXc) public access 1 ⇒ 0 0 1

n Ask manager to create a group (unique name), say G, and add some users to the group.

n For a particular file (say game) or subdirectory, define an appropriate access.

owner group public

chmod 761 game

Attach a group to a filechgrp G game