L15_FS - Web Services Overview

Download Report

Transcript L15_FS - Web Services Overview

Lecture 15
File Systems
File system overview

Provide non-volitale storage for programs
(the O.S. being the most important!)
Order of magnitude more storage than memory
Abstracts storage details from user
Application writers can use read, write, ...
Provide organizational operators

Issues:






File system structures
Disk management
Performance
File system architecture
User interface
OS structures
Open file structures
Interface to get data
What file system
file/directories look
like.
Extended disk
Buffer caching
Virtual file systems
Performance
Buffer cache policy
Disk structures
Disk layout
Blocks, sectors
File layout
Directories
Permissions
Files

Typically, the minimum accessible unit

File naming

Can be constrained
• Length (e.g. extensions in DOS)
• Characters (e.g. “.” or “..” in UNIX)

Only for the user
• Names typically signify meaning (.jpg, .gif, etc…)
– Convention/standards are used by machine
• The machine sorts out the data by checking the
validity of the byte stream
– Example: “P6…” for PPM files
File attributes

The baggage that goes along with the data
Typical file system operations

File access


File info


get attributes, get_stat
File management


open, close, set attributes, seek
mkdir, chdir, move, copy, rename, delete, link, etc..
Disk management

df, mount, umount, etc…
File naming mechanisms

Hierarchical naming



Attribute-based naming structures



All files are hierarchically arranged in a tree
structure
Users move within levels of the file system
Attempt to bring attributes to file names
Examples: picture of car, image type, etc..
Hierarchical with indexing


Windows XP uses hierarchical naming
File system also indexes information as it is stored
(some content indexed)
Path types

Relative

Starts from current directory
• Requires a current_directory to be stored
somewhere

Examples
• ../foo
• foo.c

Absolute


State entire path
Example
• C:/Program Files/Adobe
• /var/tmp
Disk allocation

Each file occupies contiguous blocks on disk

Advantages:
• Simple to implement - just find empty space
• Can randomly access file

Disadvantages:
• Wasteful of space (due to fragmentation)
• If files grow, a copy must be made
Linked allocation



Each file is a linked list of disk blocks
Method used in MS-DOS and Mac file systems
Allocate space from beginning and link together
segments of the file


Advantages – simple, better utilization of space
Disadvantages – no random access, overhead of linking
Indexed allocation



Break storage space into small fixed-size
pieces, or blocks
Allocate as many as needed to hold the file
Store the disk block addresses for each of the
blocks in the metadata record


Advantages – random access, no external frag.
Disadvantages – need index table, more seeks
UNIX file system

File systems structure
Boot block superblock i-nodes


data block
data block
…
The file system in UNIX is an integral part of the
operating system. Files are used for:
 Terminal handling
/dev/tty***
 Pipes
“ls | more”
 Directories
 Sockets (for networking)
The design of the UNIX file system allows the user to
write code that has a uniform interface.
UNIX file structures


Superblock - tells the UNIX O.S. what the
format of the disk is, the # of blocks, the
number of i-nodes, etc...
I-nodes - are the metadata data structures
for files and directories


Files - holds information such as owner, permissions,
date of modification, where the data is
Directories are just a special case of files that have
the pairs <file-name, i-node #> stored in the file
UNIX file system

UNIX files consist of i-node and data blocks

UNIX uses an indexed allocation scheme with




10 direct pointers to blocks
1 indirect pointer to blocks
i-node
1 double indirect
pointer to blocks
1 triple indirect
pointer to blocks
...
...
...
...
triple indirect pointer
...
UNIX file system


Several parameters determine how many (and of what
size) files can be represented
 No. of bits in a disk address
 No. of bits in a virtual memory reference
 Disk block size
Example:
 10 direct, 1 1x indirect, 1 2x indirect, 1 3xindirect
 No. bits in disk address --> 16-bits
 No. of bits in virtual memory reference --> 32-bits
 Disk block size --> 1024 kbytes

What is the maximum file size in this system?
File size worksheet
Some UNIX file system features

mounting - allows other file systems (disks),
whether local or remote to be “mounted into a
uniform file system space
/
usr
home
var
X11
bin
mnt
Connecting the file system to the O.S.

To provide uniform access to data, UNIX has a level of
indirection that is used for opening files
Files
Open File Table
...
... ...
...
...
process 1
...
...
...
... ...
...
...
process n
Each open file entry holds, permissions (R/W), file offset
More interesting features

All input and output in UNIX are handled
through the open file table structure


This is how UNIX can provide a single uniform
interface for local or remote data access
Pipes in UNIX are nothing more than


A writing process that has its “stdout” linked to a
“pipe” file (instead of a /dev/tty*** file)
A reading process that has its “stdin” linked to a
“pipe” file (instead of a /dev/tty*** file)
The power of UNIX pipes