Operating System
Operating System
Interface
Chapter 10: File-System Interface
• File Concept
• Access Methods
• Directory Structure
• File-System Mounting
• File Sharing
• Protection
Objectives
• To explain the function of file systems
• Create
• Write
• Read
• Delete
• Truncate( if you want to delete the content of the file but keep its attribute)
• Open(Fi) – search the directory structure on disk for entry Fi, and move the content
of entry to memory
• Close (Fi) – move the content of entry Fi in memory to directory structure on disk
Open Files
• Several pieces of data are needed to manage open files:
• File pointer: pointer to last read/write location, per process that has the file
open
• File-open count: counter of number of times a file is open – to allow removal
of data from open-file table when last processes closes it
• Disk location of the file: cache of data access information
• Access rights: per-process access mode information
File Types – Name, Extension
Access Methods
• Sequential Access
read next
write next
reset
no read after last write
(rewrite)
• Direct Access
read n
write n
position to n
read next
write next
rewrite n
Directory
Files
F1 F2 F4
F3
Fn
• Create a file
• Delete a file
• List a directory
• Rename a file
• Single-Level Directory
• Two-Level Directory
• Tree-Structured Directories
Single-Level Directory
• A single directory for all users
Naming problem
Grouping problem
Two-Level Directory
• Separate directory for each user
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
Tree-Structured Directories
Tree-Structured Directories (Cont.)
• Efficient searching
• Grouping Capability
• Current directory (working directory)
• cd/spell/mail/prog
• type list
Tree-Structured Directories (Cont.)
• Absolute or relative path name
• 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