30
os11 1 Chapter 11 File-System Interface

Chapter 11 File-System Interface

  • Upload
    derick

  • View
    44

  • Download
    1

Embed Size (px)

DESCRIPTION

Chapter 11 File-System Interface. Outline. File Concept Access Methods Directory Structure File System Mounting File Sharing Protection. File Concept. Contiguous logical address space Types: Data numeric character binary Program. File Structure. None - sequence of words, bytes - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 11  File-System Interface

os11 1

Chapter 11 File-System Interface

Page 2: Chapter 11  File-System Interface

os11 2

Outline

File ConceptAccess MethodsDirectory StructureFile System MountingFile Sharing Protection

Page 3: Chapter 11  File-System Interface

os11 3

File Concept

Contiguous logical address spaceTypes: Data

numeric character binary

Program

Page 4: Chapter 11  File-System Interface

os11 4

File StructureNone - sequence of words, bytesSimple 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 11  File-System Interface

os11 5

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 6: Chapter 11  File-System Interface

os11 6

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 7: Chapter 11  File-System Interface

os11 7

File Types – Name, Extension

Page 8: Chapter 11  File-System Interface

os11 8

Open a FileA file is open when it is first used. No search on directory is required for later usage. Two levels of tables

A table for each process (information dependent on the process)

index to system table current position pointer

A system open-file table (information independent from a process)

open count (for shared files) disk location access date file size

Page 9: Chapter 11  File-System Interface

os11 9

OS and Disk I/OAdvantages for OS to know the file type avoid some mistakes (e.g., print a binary-obje

ct) TOPS-20: if source program has been modified,

running an old .obj file causes re-compiling automatically

Windows: doubling clicking a .doc file invokes MS Words

Disk I/O performs in units of one block logical records packing a physical block all file systems have internal fragmentation

larger block larger internal fragmentation

Page 10: Chapter 11  File-System Interface

os11 10

Access MethodsSequential access: records are processed in order, e.g., tapes read/write (next) reset to beginning, skip forward/backword

Direct access (disks) position (seek) to the n-th record read/write

Other (direct access+index) an index table (can be put into memory); the index,

like an index in the back of a book, contains pointers to the various blocks.

file in disk: reduce I/O for searching on a large file

Page 11: Chapter 11  File-System Interface

os11 11

Sequential-access

beginning endcurrent position

rewindread/write

Index and relative files

adams

asherarthur

smith

smith, john id age address

index filerelative file

Page 12: Chapter 11  File-System Interface

os11 12

Directory Structure (1)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 11  File-System Interface

os11 13

Directory Structure (2)

Typical file-system organization disk partitions (IBM: minidisk, PC: volume)

files (including directories)

directory

directory

partition A

partition B

disk 1

directory

partition C

disk 2

Page 14: Chapter 11  File-System Interface

os11 14

Directory Structure (3)Directory structures Single-level directory Two-level directory Tree-structured directory (more common) Acyclic-graph directory

(cycle-detection is expensive) General graph directory

(garbage collection is expensive)

flexible

complicated

Page 15: Chapter 11  File-System Interface

os11 15

Operations Performed on Directory

Search for a fileCreate a fileDelete a fileList a directoryRename a fileTraverse the file system

Page 16: Chapter 11  File-System Interface

os11 16

Organize 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 11  File-System Interface

os11 17

Single-Level Directory

A single directory for all users.

Naming problem:1. difficult to remember all names 2. not easy to give a new name 3. confusion between different usersGrouping problem

Page 18: Chapter 11  File-System Interface

os11 18

Two-Level DirectorySeparate directory for each user.

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

Page 19: Chapter 11  File-System Interface

os11 19

Tree-Structured Directories

Page 20: Chapter 11  File-System Interface

os11 20

Tree-structured directory each user has a current directory absolute path name vs. relative path name search path

stat mail dist test

root spell obj program

pe2 cc pas a

jaja ab cat bo a test

current

directory

mail\jaja, or

\spell\mail\jaja

Page 21: Chapter 11  File-System Interface

os11 21

Acyclic-graph directory: 1. share subdirectory (file): the same file or directory may be in two different directories.

2. relative simplicity of the algorithms to traverse the graph and to determine when there are no more reference to a file.

: 1. Search/traverse the file system should be careful2. Deletion is complicated:

Dangling pointers to a deleted file. Solution: Keep a count of the number of refere

nces3. Detection of cycles is expensive

Page 22: Chapter 11  File-System Interface

os11 22

cat mail dist pe2

root spell obj program

pe2 cc pasc a

cat bo a test

Acyclic-graph directory

Page 23: Chapter 11  File-System Interface

os11 23

General graph directory: How do we guarantee no cycle?

1. Searching/traversing is difficult search a directory twice limit # of directories that can be accessed infinite loop

2. Deletion is more complicated Self-reference: a set of files with nonzero

reference-count that are impossible to refer, the possibility of self-referencing (a cycle) in the directory structure.

Solution: garbage collection (very expensive)

Page 24: Chapter 11  File-System Interface

os11 24

cat mail dist pe2

root

spell obj program

pe2 cc pasc a

root bo a test

General graph directory

Page 25: Chapter 11  File-System Interface

os11 25

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.

Page 26: Chapter 11  File-System Interface

os11 26

(a) Existing. (b) Unmounted Partition

Page 27: Chapter 11  File-System Interface

os11 27

Mount Point

Page 28: Chapter 11  File-System Interface

os11 28

File SharingSharing 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 29: Chapter 11  File-System Interface

os11 29

ProtectionFile owner/creator should be able to control: what can be done by whom

Types of access Read Write Execute Append Delete List

Page 30: Chapter 11  File-System Interface

os11 30

Access Lists and GroupsMode of access: read, write, executeThree classes of users

RWXa) owner access 7 1 1 1

RWXb) group access 6 1 1 0

RWXc) public access 1 0 0 1

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