file systems (1). readings r reading: disks, disk scheduling (3.7 of textbook; “how stuff...

22
File Systems (1)

Upload: piers-baker

Post on 02-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

File Systems (1)

Readings

Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”)

Reading: File System Implementation (5.1-5.3 of textbook)

File Concept

Computers store information on various storage media Disks, tapes

The OS provides a logical view of information storage Define a logical storage unit: file

Files are mapped by the operating system to physical devices

Files Named collection of related information

recorded on secondary storage Logical unit of storage on a device e.g., helloworld.c, resume.doc

Can contain programs (source, binary) or data

Files have attributes: Name, type, location, size, protection,

creation time etc

File Naming

Files are named Even though files are just a sequence of

bytes, programs can impose structure on them Files with a certain standard structure imposed

can be identified using an extension to their name

Application programs may look for specific file extensions to indicate the file’s type

But as far as the operating system is concerned its just a sequence of bytes

File Naming

Typical file extensions

File Types Many operating systems support

several types of files UNIX, Windows have regular files and

directories Regular files:

Contain user information Can be ASCII (e.g., source code) or binary

(executable) Directories

Maintain information on the structure of the file system

File Types A file is a sequence of bytes

How does the OS know if a file can be executed? Executable must have a specific format

In Unix the format of an executable is the following: Header, text, data, relocation bits and symbol table

Header Starts with the magic number identifying the file as

executable Followed by sizes of the various pieces of information Followed by the address at which execution starts

(entry point) Followed by the text and data itself

File Types

(a) An executable file (b) An archive

File Access

Sequential access Read all bytes/records from the beginning Cannot jump around, could rewind or back up Convenient when medium was magnetic tape

Random access Bytes/records read in any order Essential for database systems

File Attributes Various meta-data needs to be associated with

files Owner Creation time Access permissions / protection Size etc

This meta-data is referred to as the file attributes Maintained in file system data structures for

each file

File Attributes

Possible file attributes

File Operations

1. Create2. Delete3. Open4. Close5. Read6. Write

7. Append8. Seek9. Get

attributes10.Set

Attributes11.Rename

Directories

File systems use directories to keep track of files

Directory operations File search File creation File deletion Directory listing File renaming File system traversal

Single Level Directories

All files are contained in the same directory

Limitations File names must be unique Must ensure enough characters to make it

easier to have unique file names.

Simple Directories

When a file is opened, the OS searches its directory until it finds the name of the file to be opened.

It then extracts the attributes and disk addresses

The OS now has all the information needed to access the file

The number of directories varies from system to system.

DirectoriesSingle-Level Directory Systems

A single level directory system contains 4 files owned by 3 different people, A, B, and C

Two-level Directory Systems

Letters indicate owners of the directories and files There is a directory associated with each user

Hierarchical Directory Systems

A hierarchical directory system

Path Names

Need to specify file names Two methods:

Absolute path name: Consisting of the path from the root directory to the file

Relative path name• User designates one directory as the current

working directory • The path name of the current working directory is

implicit in the relative path name

A UNIX directory tree

Path Names

Summary

This section briefly described the user interface to files and directories