Download presentation
Presentation is loading. Please wait.
Published byCorey Fields Modified over 9 years ago
1
File System Interface CSCI 444/544 Operating Systems Fall 2008
2
Agenda File system abstraction Directory structure File operations File system mounting
3
File System Abstraction File system is the OS abstraction for storage resources (especially, disk) Track/sector files Provides a uniform logical view of information storage File is a logical storage unit in the OS abstract interface for storage resources Directory is a logical “container” for a group of files
4
File Concept To a user process, a file is a contiguous block of bytes User view: named collection of bytes OS view: collection of blocks on physical non-volatile storage device Types: Data –numeric –character –binary Program (source and object)
5
File Structure Sequence of words, bytes Simple record structure Lines Fixed length Variable length Complex Structures Formatted document
6
File Attributes (Meta-data) Name – a string used to uniquely identify a file 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 These meta-data (Information about files) are kept in the directory structure, which is maintained on the disk but cached in memory if the file is open.
7
File Systems OK, we have files How can we name them? How can we organize them?
8
File Naming Each file has an associated human-readable name e.g., usr, bin, mid-term.pdf, design.pdf OS must maintain a mapping between file names and the set of blocks belong to that file In Unix, this is a mapping between names and i-nodes Mappings are kept in directories
9
Directory Structure A collection of nodes containing information about all files F 1 F 2 F 3 F 4 F n Directory Files Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes
10
Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system
11
Organize the Directory to Obtain Efficiency – locating a file quickly Naming – convenient to users Two users can have same name for different files The same file can have several different names Grouping – logical grouping of files by properties, (e.g., all Java programs, all games, …)
12
Single-Level Directory A single directory for all users Naming problem Grouping problem
13
Two-Level Directory Separate directory for each user Path name Can have the same file name for different user Efficient searching No grouping capability
14
Tree-Structured Directories
15
Tree-Structured Directories (Cont) Efficient searching Grouping Capability Current directory (working directory) cd /spell/mail/prog type list
16
Tree-Structured Directories (Cont) Absolute or relative path name Creating a new file is done in current directory Delete a file rm Creating a new subdirectory is done in current directory mkdir Example: if in current directory /mail mkdir count mail progcopyprtexpcount Deleting “mail” deleting the entire subtree rooted by “mail”
17
Acyclic-Graph Directories Have shared subdirectories and files
18
Acyclic-Graph Directories (Cont.) More general than tree structure Add connections across the tree (no cycles) Create links from one file (or directory) to another Two different names (aliasing) New directory entry type Link – another name (pointer) to an existing file Resolve the link – follow pointer to locate the file
19
File Operations Create Write Read Reposition within file Delete Truncate Open(F i ) – search the directory structure on disk for entry F i, and move the content of entry to memory Close (F i ) – move the content of entry F i in memory to directory structure on disk
20
Open Files Open() file before first access User specifies mode: read and/or write Search directories for filename and check permissions Copy relevant information to open file table in memory Return index in open file table to process (file descriptor) Process uses file descriptor to read/write to file Two levels of open file tables Per-process open file table –Track all files that a process has open –Current file pointer indicating the current read or write position System-wide open-file table –Contains process-independent file information Location of the file on disk, file size, etc.
21
Related Information to an Open File 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 Access rights: per-process access mode information File-open count: counter of number of times a file is open – to allow removal of data from system-wide open-file table when last processes closes it Disk location of the file: cache of data access information
22
5/18/201522 Data Structures for a File Process control block...... Open file pointer array Open file table (system-wide) i-node table File i-node
23
Access Methods Sequential Access read next write next reset no read after last write Direct Access read n write n position to n read next write next rewrite n n = relative block number
24
File System Mounting A file system must be mounted before it can be accessed A unmounted file system is mounted at a mount point Mount point is typical an empty directory
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.