chapter 10: file-system interface

14
CEG 433/633 - Operating Systems I Dr. T. Doom 10.1 Chapter 10: File-System Interface What is a file-system? An abstract representation of physical devices capable of storing and retrieving binary information (files) consists of partitions (volumes (NT), minidisks, etc), directories, and files “virtual” file-systems may be smaller or greater in size then the physical devices used to store the information What is a file? A file is an abstract data type, defined by the operations that can be performed on them A named collection of related information recorded on a secondary storage (non-volatile) device Uniform logical view of information storage A logical storage unit (mapped by the OS onto a physical device) Who decides how the meaning is encoded (structure)? Operating system Program

Upload: beck-head

Post on 01-Jan-2016

20 views

Category:

Documents


3 download

DESCRIPTION

Chapter 10: File-System Interface. What is a file-system? An abstract representation of physical devices capable of storing and retrieving binary information (files) consists of partitions (volumes (NT), minidisks, etc), directories, and files - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.1

Chapter 10: File-System Interface

• What is a file-system?– An abstract representation of physical devices capable of storing

and retrieving binary information (files)– consists of partitions (volumes (NT), minidisks, etc), directories,

and files– “virtual” file-systems may be smaller or greater in size then the

physical devices used to store the information

• What is a file?– A file is an abstract data type, defined by the operations that can

be performed on them– A named collection of related information recorded on a secondary

storage (non-volatile) device– Uniform logical view of information storage– A logical storage unit (mapped by the OS onto a physical device)

• Who decides how the meaning is encoded (structure)?– Operating system– Program

Page 2: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.2

File Attributes

• A file is a sequence of bits, bytes, lines or records whose format encodes meaning as defined by the file’s creator or user:

– “Freeform” structure: sequence of words, bytes– Simple regular structure: fixed or variable length records– Complex structures: formatted document, relocatable load file

• File types:– Data (numeric, character, binary)– Executable (loader can bring into memory and execute)– Directory (keeps information about other files)

• 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.

Page 3: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.3

File Types – name, extension

Executable exe, com, bin ornone

ready-to-run machine-language program

Object obj, o complied, machinelanguage, not linked

Source code c, p, pas, 177,asm, a

source code in variouslanguages

Batch bat, sh commands to thecommand interpreter

Text txt, doc textual data documents

Word processor wp, tex, rrf, etc. various word-processorformats

Library lib, a libraries of routines

Print or view ps, dvi, gif ASCII or binary file

Archive arc, zip, tar related files groupedinto one file, sometimescompressed.

File Type Usual extension Function

Page 4: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.4

Access Methods

• Sequential Accessread nextwrite next resetno read after last write

(rewrite)

• Direct Accessread nwrite nposition to n

read nextwrite next

rewrite n

n = relative block number

Page 5: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.5

File Operations

• Files are an abstract data type, defined by the operations that can be performed on the. The OS must provide system calls for the following types of operations:

– create: find space, write to file, update directory– write: name and position, update size, update file pointer– read: name and position, update file pointer– seek: reposition within file, update file pointer– delete: deallocate space, erase directory entry– 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.

• Files must be explicitly opened via open() to create a entry in the open-file table. The index to the entry in the open-file table is the “file handle”.

– # of processes w/ current-file position pointer (offset) for each– Information regarding physical location of file on disk

Page 6: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.6

Directory Structure

• A collection of nodes containing information about all files.

• Operations:

– Search for a file

– Create a file

– Delete a file

– List a directory

– Rename a file

– Traverse the file system

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

CEG 433/633 - Operating Systems I Dr. T. Doom 10.7

Single-Level Directory

• A single directory for all files (all users).

• Naming problem– Each file must have a unique name -

it may be difficult to keep track of “used” names What if two users want to use the same filename? What if two users have the _same_ file under two different names?

• Grouping problem– files are not grouped by logical properties (C programs, games, etc.)

• Efficiency – how can you locate a file quickly (if you don’t know the name…)

Page 8: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.8

Two-Level Directory

• Separate directory for each user.

• Path name

• Can have the same file name for different user

• Efficient searching

• No grouping capability

Page 9: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.9

Tree-Structured Directories

• Efficient searching

• Grouping Capability

• Current directory (working directory)

– cd /spell/mail/prog

– type list

Page 10: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.10

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 /spell/mail

mkdir count

mail

prog copy prt exp count

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

Page 11: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.11

Acyclic-Graph Directories

• Have shared subdirectories and files.

• Different names (aliasing)

• Solutions:

– Backpointers, so we can delete all pointers.Variable size records a problem.

– Backpointers using a daisy chain organization.

– Entry-hold-count solution.

Page 12: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.12

General Graph Directory

• 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 13: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.13

Protection

• File owner/creator should be able to control:

– what can be done

– by whom

• Types of access

– Read

– Write

– Execute

– Append

– Delete

– List

• Access Lists

• Access Control Lists (ACLs)

Page 14: Chapter 10:  File-System Interface

CEG 433/633 - Operating Systems I Dr. T. Doom 10.14

Access Lists and Groups in UNIX

• Mode of access: read, write, execute

• Three classes of usersRWX

a) owner access 7 1 1 1RWX

b) groups access 6 1 1 0RWX

c) 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

• Attach a group to a file

chgrp G game