Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

25
Slide: 1 UNIX FILE SYSTEM By: Qing Yang ID: 103968 Operating System Research Topic December, 2000

Transcript of Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Page 1: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 1

UNIX FILE SYSTEM

By: Qing Yang

ID: 103968

Operating System Research Topic

December, 2000

Page 2: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 2

Outline

Major parts of the file system

Basic components of the file system

Structure of the file system

Access permissions

Page 3: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 3

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

Page 4: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 4

A Simplified Module

i-nodes data blocksboot block/superblock

Page 5: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 5

Boot Block

First block of every file system(block 0)

Reserve for boot or initialization program

Contain boot loader’s address and partition information

Page 6: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 6

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

Page 7: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 7

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

Page 8: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 8

Data Blocks

Contain user data or system files

Page 9: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 9

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

Page 10: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 10

a0

a10a11

a3a4

a2a1

a12

Page 11: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 11

I-Node (cont.)

Example:

type=ordinary perm=rwxr-xr-x links=1

user-id=2 group-id=2 size=3624

a0: 726 a1: 725 a2: 724 a3: 723 a4: 0 a5: 0 a6: 0 a7: 0 a8: 0 a9: 0 a10: 0 a11: 0 a12: 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

Page 12: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 12

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

Page 13: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 13

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

Page 14: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 14

Ordinary Files

Contain text, data, or program information

Cannot contain another file, or directory

One-dimensional array of bytes

Page 15: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 15

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

Page 16: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 16

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

Page 17: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 17

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

Page 18: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 18

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

Page 19: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 19

UNIX System Directories

/(root)

|-----------------------------------------------------------------------------

| | | | | | | |

/bin /dev /etc /home /lib /tmp /usr kernel file

Page 20: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 20

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

Page 21: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 21

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

Page 22: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 22

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

Page 23: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 23

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

r w x r w x r w x

Page 24: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 24

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

Page 25: Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID:103968 Operating System Research Topic December, 2000.

Slide: 25

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