Download File Systems: Concept, Structure, and Operations and more Slides Computer Science in PDF only on Docsity!
File-System Interface
Chapter 10
Objectives
• To explain the function of file systems
• To describe the interfaces to file systems
• To discuss file-system design tradeoffs,
including access methods, file sharing, file
locking, and directory structures
• To explore file-system protection
File Structure
• None - sequence of words, bytes (UNIX)
• Simple record structure
- Lines
- Fixed length
- Variable length
• Complex Structures
- Formatted document
- Relocatable load file
• Can simulate last two with first method by inserting
appropriate control characters
• Who decides:
File Attributes
- Files typically have the following attributes
- Name – only information kept in human-readable form.
- Identifier – Unique tag, usually a number, identifies the file within the 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 (Con’t)
- Most file operations require searching the directory
for the entry associated with the named file.
- To avoid constant searching, many systems require that an
open system call be used
- The operating system keeps a small table containing
information about all open files (open-file table)
- The file is specified via an index into the table, so no searching is required.
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
Access Methods
- Sequential Access: Simplest access method. Information in the file is processed in order, one record after the other
read next write next reset
- Direct Access: A file is made up of fixed-length logical records that allow rapid read/write access in no particular order read n write n position to n read next write next rewrite n n = relative block number
Simulation of Sequential Access on a Direct-
access File
- Not all operating systems support both sequential and direct
access file methods.
- Easy to simulate sequential access method on a direct-access file
- Extremely inefficient to simulate a direct-access file method on a sequential access file.
A Typical File-system Organization
Operations Performed on Directory
- Search for a file
- Create a file
- Delete a file
- List a directory
- Rename a file
- Traverse the file system
Single-Level Directory
• A single directory for all users
Naming problem
Grouping problem
Two-Level Directory
• Separate directory for each user
n Path name n Can have the same file name for different user n Efficient searching n No grouping capability
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
mail
prog copy prt exp count
Deleting “mail” ⇒ deleting the entire subtree rooted by “mail”
Acyclic-Graph Directories
• Have shared subdirectories and files