Post on 20-Jul-2020
transcript
~FILE SYSTEM~SUNU WIBIRAMA
OUTLINE
FILE SYSTEM
ACCESS METHODS
DIRECTORY STRUCTURE
FILE SYSTEM MOUNTING
PROTECTION
EXTERNAL VIEW OF THE FILE MANAGER
FILE MANAGEMENT
FILE, IS A NAMED AND ORDERED COLLECTION OF INFORMATION
COMPUTER SHOULD BE CONVENIENT TO BE USED
OPERATING SYSTEM HANDLES IT WITH ITS FILE MANAGEMENT FUNCTION
FILE MANAGER’S JOB:- STORING THE INFORMATION ON A DEVICE- MAPPING THE BLOCK STORAGE TO LOGICAL VIEW- ALLOCATING /DEALLOCATING STORAGE- ORGANIZING FILE EFFICIENTLY
FILE STRUCTURE
File represents program (source and object forms) and data
General file structure: sequence of bits, bytes, lines, or records
Simple record structure:
Lines
Fixed length
Variable length
Complex Structures:
Formatted document
Relocatable load file!
Who decides:
Operating system
Program
FILE ATTRIBUTES
NAME – ONLY INFORMATION KEPT IN HUMAN-READABLE FORM
IDENTIFIER – UNIQUE TAG (NUMBER) IDENTIFIES FILE WITHIN FILE SYSTEM
TYPE – NEEDED FOR SYSTEMS THAT SUPPORT DIFFERENT TYPES
LOCATION – POINTER TO FILE LOCATION ON DEVICE
SIZE – CURRENT FILE SIZE
PROTECTION – CONTROLS WHO CAN DO READING, WRITING, EXECUTING
TIME, DATE, AND USER IDENTIFICATION – DATA FOR PROTECTION, SECURITY, AND USAGE MONITORING
INFORMATION ABOUT FILES ARE KEPT IN THE DIRECTORY STRUCTURE, WHICH IS MAINTAINED ON THE DISK
FILE OPERATIONS
File is an abstract data type
Create
Write
Read
Reposition within file (FILE SEEK)
Delete
Truncate
OPEN AND CLOSE FILE
Open(Fi) – search the directory structure on disk for entry Fi,
and move the content of entry to memory. OS provides open-file table to containing information about all open files (no need to search directory structures when a file operation is requested)
Close (Fi) – move the content of entry Fi in memory to directory
structure on disk. Erase the entry in open-file table related to the closed file.
FILE TYPES
Operating System must recognize the file type in order to operate on the file in reasonable ways.
File types are recognized as an extension : *.exe, *.doc, *.psd, etc.
ACCESS METHOD (1)
Sequential Access:! - read next! - write next ! - reset! - no read after last write! - rewrite
ACCESS METHOD (2)
Direct Access (Relative Access):! - no restrictions on the order of read or write
- read n! - write n! - position to n! - read next! - write next ! - rewrite n
! n = relative block number
HOW TO TRANSLATE SEQUENTIAL-ACCESS
ON A DIRECT-ACCESS FILE
BASIC DISK STRUCTURES
DISK CAN BE SUBDIVIDED INTO PARTITIONS
ENTITY CONTAINING FILE SYSTEM ALSO KNOWN AS VOLUME
DIRECTORY IS LIKE A TABLE OF CONTENTS - RECORDS INFORMATION, SUCH AS NAME, LOCATION, SIZE, TYPE OF ALL FILES IN A VOLUME
DIRECTORY
SET OF FILES
USED TO ORGANIZE FILES
TREATED AS A FILE, BUT WITH SPECIAL OPERATIONS ON IT:- CREATE A FILE- DELETE A FILE- SEARCH A FILE- LIST A DIRECTORY- RENAME A FILE
SINGLE-LEVEL DIRECTORY
SINGLE DIRECTORY FOR ALL USERS
IF THE NUMBER OF FILES INCREASES OR MORE THAN ONE USERS --> PROBLEM OCCURES
LENGTH OF FILE NAME LIMITATION: MS-DOS (11) DIFFERS WITH UNIX (255)
TWO-LEVEL DIRECTORY
SEPARATE DIRECTORY FOR EACH USER
CAN HAVE THE SAME FILE NAME FOR DIFFERENT USER
ISOLATES ONE USER TO THE OTHERS
TREE-STRUCTURED DIRECTORY
TREE: THE MOST COMMON STRUCTURES
TREE-STRUCTURED DIRECTORY
Efficient searching
Grouping Capability
Current directory (working directory)
Absolute or relative path name
CURRENT DIRECTORY
ABSOLUTE PATH
RELATIVE PATH
TREE-STRUCTURED DIRECTORY
Creating a new file is done in current directory
Delete a file
! ! rm <file-name>
Creating a new subdirectory is done in current directory
! ! mkdir <dir-name>
! Example: if in current directory /mail
! ! mkdir count mail
copy prt exp count
TREE-STRUCTURED DIRECTORY
Creating a new file is done in current directory
Delete a file
! ! rm <file-name>
Creating a new subdirectory is done in current directory
! ! mkdir <dir-name>
! Example: if in current directory /mail
! ! mkdir count mail
copy prt exp count
what’s happened, if i execute rm -rf /home?
ACYCLIC-GRAPH DIRECTORIES
HAVE SHARED SUBDIRECTORIES AND FILES
SHARED FILE
SHAREDSUBDIRECTORY
ACYCLIC-GRAPH DIRECTORIES
ALIASING: DIFFERENT FILE NAMES FOR SAME FILE
A POINTER TO SHARED FILE IS NAMED LINK
DELETION PROBLEM, IF THE SHARED SUBDIRECTORY “LIST” IS DELETED, WE HAVE DANGLING POINTER
SYMBOLIC LINKS: - IF LINK IS DELETED, PRESERVE THE ORIGINAL FILE- IF ORIGINAL FILE IS DELETED, ACCESS TO THE DELETED FILE USING LINKS IS TREATED AS ILLEGAL ACCESS.
NON-SYMBOLIC LINKS (HARD LINKS):- PRESERVE THE FILE UNTIL ALL REFERENCES TO IT ARE DELETED- KEEP ONLY A COUNT OF THE NUMBER OF REFERENCES. WHEN THE COUNT = 0, FILE CAN BE DELETED BECAUSE NO REFERENCE TO IT.
GENERAL GRAPH DIRECTORY
How do we guarantee no cycles?
Allow only links to file not subdirectories
Garbage collection: detect when the last reference has been deleted
Every time a new link is added use a cycle detection algorithm to determine whether it is OK, but it’s computationally expensive
ACYCLIC-GRAPH DIRECTORIES
LINK IN UBUNTU LINUX 10.10
FILE SYSTEM MOUNTING
(A) MOUNTED (B) UNMOUNTED MOUNTED
you can see how it works on unix, instead of windows
FILE SYSTEM MOUNTING
SOMETIMEYOU SHOULD
DEFINE THE TYPE OF YOUR MOUNTED FILE SYSTEM
BEFORE MOUNTING
Mount point: /mnt/public
AFTERMOUNTING
FILE SYSTEM MOUNTING
Automatic mounting on booting: /etc/fstab
mounted file mount point file system type
FILE SHARING
Multiple users: problem arises on file sharing, file naming, and file protection
Add more attributes to file and directory
Most systems use concept of OWNER and GROUP
User IDs identify users, allowing permissions and protections to be per-user
Group IDs allow users to be in groups, permitting group access rights
We will elaborate on the last section : PROTECTION
REMOTE FILE SHARING
Uses networking to allow file system access between systems
Manually via programs like FTP
Automatically, seamlessly using distributed file systems
Semi automatically via the world wide web
Client-server model allows clients to mount remote file systems from servers
Server can serve multiple clients
Client and user-on-client identification is insecure or complicated
NFS is standard UNIX client-server file sharing protocol
CIFS is standard Windows protocol
Standard operating system file calls are translated into remote calls
Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing
PROTECTION
Keep the file safe from physical damage (reliability) and improper access (protection)
File owner/creator should be able to control:
what can be done
by whom
Types of access
Read
Write
Execute
Append
Delete
List
PROTECTION
Field Meaning
- File type / directory
rw-r--r-- Permission
1 Hard link number to file
sunu owner of file
sunu group of file
323 file size in byte
2010-11-18 13:55 modification date
execute.txt file name
Owner (o)Group (g)
Public/Universe (p)
-rwxr-x---
file [o] [g] [p]
PROTECTION
Mode of access and octal: read (r = 4), write (w = 2), execute (x = 1)
Three classes of users! ! ! ! ! RWX! ! a) owner access ! 7! ⇒! 1 1 1
! ! ! ! RWX! ! b) group access ! 6! ⇒! 1 1 0! ! ! ! ! RWX! ! c) public access ! 1! ⇒! 0 0 1
Ask manager to create a group (unique name), say G, and add some users to the group.
For a particular file (say game) or subdirectory, define an appropriate access.
owner group public
chmod 761 game
Attach a group to a file: chgrp G game
PROTECTION
ACCESS CONTROL LIST IN WINDOWS XP
ADMIN USERS
/EOFend of file