Unix File System

Download Report

Transcript Unix File System

Operating System Research Topic
UNIX FILE SYSTEM
December, 2000
By:
Qing Yang
ID:
103968
Slide: 1
Outline
Major parts of the file system
Basic components of the file system
Structure of the file system
Access permissions
Slide: 2
Major Parts of UFS
Logical method for organizing and storing
information in a way which is easy to
manage
A UNIX file system(UFS) has four major
parts:




boot block
superblock
i-node blocks
data blocks
Slide: 3
A Simplified Module
boot block/
superblock
i-nodes
data blocks
Slide: 4
Boot Block
First block of every file system(block 0)
Reserve for boot or initialization program
Contain boot loader’s address and partition
information
Slide: 5
Superblock
Block 1 of every file system
Contains following information:







total size of the file system
number of blocks reserved for i-nodes
name of file system
device identification
date of last update
head of the free-block list
list of free i-nodes
Slide: 6
I-Node Blocks
Group of blocks follow the superblock
Each block contains a number of i-nodes
An i-node describes an individual file
A max. number of i-nodes in a file system
 a max. number of files
Slide: 7
Data Blocks
Contain user data or system files
Slide: 8
I-Node
Contain the key information needed by the
operating system for a particular file
Contain 10 direct pointers, 1 indirect pointer,
1 double indirect pointer, and 1 triple indirect
pointer
By structuring the pointers in a geometric
fashion, a single i-node can represent a very
large file
Slide: 9
a0
a1
a2
a3
a4
a10
a11
a12
Slide: 10
I-Node (cont.)
Example:
type=ordinary
perm=rwxr-xr-x
links=1
user-id=2
group-id=2
size=3624
a0: 726
a4: 0
a9: 0
a1: 725
a5: 0
a10: 0
a2: 724
a6: 0
a11: 0
a3: 723
a7: 0
a12: 0
a8: 0
Time of last access: Fri May17 17:41:03 1989
Time of last modification: Sun Mar3 13:40:49 1989
Time of last i-node change: Sun Mar3 13:40:49 1989
Slide: 11
Files and Directories
Two basic components: files and directories
File - collection of information kept on a disk
or tape
Directory - list of filenames and i-node
numbers
Slide: 12
Different Types of File
Every item in a UNIX system can be defined
as belonging to one of the four possible
types:




Ordinary files
Directories
Special files
Pipes
Slide: 13
Ordinary Files
Contain text, data, or program information
Cannot contain another file, or directory
One-dimensional array of bytes
Slide: 14
Directories
A file that holds files and other directories
Contain two pieces of information for each
file:


filename
an i-node number - a numerical reference to
the location of the file
Slide: 15
Special Files
Represent input/output (i/o) devices
Compatibility can be achieved between
device i/o and ordinary file i/o, allowing for
more efficient use of software
Special files can be:


character special files - deal with streams of
characters
block special files - operate on larger blocks
of data
Slide: 16
Pipes
UNIX allows user to link commands together
using a pipe
Pipe acts as a temporary file which only
exists to hold data from one command until
it is read by another
Slide: 17
Structure of the UFS
Organized as a hierarchy tree-like directory
Start from a single directory - root directory
represented by a / (slash)
Below the root directory are several system
directories - contain information required by
the operating system
Slide: 18
UNIX System Directories
/(root)
|
-----------------------------------------------------------------------------
|
|
|
|
|
/bin /dev /etc /home /lib
|
/tmp
|
|
/usr kernel file
Slide: 19
A Brief Tour of UFS
root - locate at top of UNIX file system
bin - executable system utilities
dev - contain special files
etc - system configuration files and
databases
home - contains home directory for each
user
Slide: 20
A Brief Tour of UFS (cont.)
lib - operating system and programming
libraries
tmp - system scratch files (all user can write
here)
usr - contains system files and directories
sharing with other users
Kernel file - contains the kernel for the
system
Slide: 21
Pathnames
Identifies a file by specifying a path through
the directory structure to the file


Absolute path names

start at root of the file system

eg: /home/sunserv1_b/lnp5jb/bin/hello
Relative path names

start at the current directory

eg: bin/hello
Slide: 22
Access Permissions
Three types of permissions:



r read the file or directory
w write to the file or directory
x execute the file or search the directory
Three types of user:



u the user who owns the file
g members of the group to which the owner belongs
o all other users
The access permissions for all three types of user
can be given as a string of nine characters:

user group other
rwx rwx rwx
Slide: 23
Access Control
File and directory in user account can be protected
from or made accessible to other users by changing
its access permissions
User can only change the permissions for files and
directories that he owns
Default value when create a file or directory:
rw------- for file vs rwx------ for directory
Access permissions for user home directory are
usually set to rwx--x--x or rwxr-xr-x
Slide: 24
Summary
UNIX considers any device attached to the
system to be a file
Files are organized in tree-structured
directories
Directories are files containing pair of i-node
numbers and filenames
File and directory can be protected by
setting its access permissions
Slide: 25