320 likes | 400 Views
Operating System Research Topic. UNIX FILE SYSTEM. By: Qing Yang ID: 103968. December, 2000. Outline. Major parts of the file system Basic components of the file system Structure of the file system Access permissions. Major Parts of UFS.
E N D
Operating System Research Topic UNIX FILE SYSTEM By: Qing Yang ID: 103968 December, 2000
Outline • Major parts of the file system • Basic components of the file system • Structure of the file system • Access permissions
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
A Simplified Module boot block/ superblock i-nodes data blocks
Boot Block • First block of every file system(block 0) • Reserve for boot or initialization program • Contain boot loader’s address and partition information
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
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
Data Blocks • Contain user data or system files
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
a0 a1 a2 a3 a4 a10 a11 a12
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
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
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
Ordinary Files • Contain text, data, or program information • Cannot contain another file, or directory • One-dimensional array of bytes
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
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
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
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
UNIX System Directories /(root) | ----------------------------------------------------------------------------- | | | | | | | | /bin /dev /etc /home /lib /tmp /usr kernel file
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
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
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
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
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
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