Module 4.0: File Systems - PowerPoint PPT Presentation

About This Presentation
Title:

Module 4.0: File Systems

Description:

Module 4.0: File Systems File is a contiguous logical address space (of related records) Access Methods Directory Structure Protection File System implementation – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 25
Provided by: MarilynT78
Category:

less

Transcript and Presenter's Notes

Title: Module 4.0: File Systems


1
Module 4.0 File Systems
  • File is a contiguous logical address space (of
    related records)
  • Access Methods
  • Directory Structure
  • Protection
  • File System implementation
  • File-system structure
  • Allocation Methods
  • Free-space Management
  • Directory Implementation
  • Recovery, Efficiency, and Performance

2
File Attributes
  • Name only information kept in human-readable
    form.
  • 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.

3
File Operations
  • create
  • write
  • read
  • reposition within file file seek
  • delete
  • truncate
  • open(Fi) search the directory
    structure/descriptor 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/descriptor on disk.

4
File Types name, extension
5
File Structure of Data within Data Blocks
  • None - sequence of words, bytes
  • Simple record structure
  • Lines
  • Fixed length
  • Variable length
  • Tree of fixed or variable records with a key for
    each record.
  • Who decides
  • Operating system
  • Program

6
Access Methods
  • Sequential Access Tape Model. Reading records
    in order.
  • read next
  • write next
  • reset
  • Direct or Random Access Disk Model. Reading
    records in order and out of order.
  • read n
  • write n
  • position to n
  • read next
  • write next
  • Most files in modern OS are direct access.

7
Memory-Mapped Files
  • Some OS provides map and unmap system calls.
  • map will map the file into the address space at
    the virtual address. System calls like open,
    read, seek are not applicable.
  • Eliminates the need for I/O, thus making it
    easier to program.
  • Problems
  • Hard to know the size of the file in advance
  • Conflicts arise when sharing files between
    processes
  • Example one process uses map and another uses
    open, read, write.
  • How to deal with huge files that are bigger than
    a segment or the whole virtual address space.

8
Directory Structure
  • A collection of nodes containing information
    about all files.
  • Both the directory structure and the files reside
    on disk.

Directory
Files
F 1
F 2
F 3
F 4
F n
9
Information in a Device Directory
  • Name
  • Type
  • Address
  • Current length
  • Maximum length
  • Date last accessed (for archival)
  • Date last updated (for dump)
  • Owner ID (who pays)
  • Protection information (discuss later)

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
Actual File Size
  • In Windows, disk block is 4KB
  • In Unix, disk block is 512B
  • Size of file reflects the actual size of data.
  • Size on disk which is multiple of data blocks.
  • Ex, if you create a text file with xyz with
    notepad, size of file will show 3, while Size on
    disk will show 4KB.

12
Organize the Directory (Logically) 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 Pascal programs, all
    games, )
  • Directory structure
  • Single-level A single directory of all users
  • Two-level Separate directory for each user
  • Tree-structured Most common

13
Tree-Structured Directories
  • Efficient searching
  • Grouping Capability
  • Absolute or relative path name
  • Current directory (working directory)
  • cd /spell/mail/prog
  • type list
  • Deleting mail ? deleting the entire subtree
    rooted by mail.

14
Shared Files/Directories
  • Symbolic or soft link
  • A file/directory is a pointer (contains the
    pathname) to another file/directory,
  • e.g., ln s /etc/classes/ics431/class softclass
  • A new i-node is created for softclass
  • Takes longer to lookup as the path is traversed
  • The file pointed to can be deleted or changed
  • Backup might do multiple copies
  • Good for linking files on other machines
  • Hard link
  • The file/directory points to the same
    file/directory-structure or I-node of the other
    file/directory.
  • e.g., ln /etc/classes/ics431/class hardclass
  • No i-node is created. Only entry in the i-node
    of directory which hardclass is under
  • Faster for lookup
  • Has an owner issue
  • Need to keep a count in the structure for file
    deletion

15
Protection
  • File owner/creator should be able to control
  • what can be done
  • by whom
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

16
Access Lists and Groups
  • Mode of access read, write, execute
  • Three classes of users
  • RWX
  • a) owner access 7 ? 1 1 1 RWX
  • b) groups 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

17
File-System Implementation
  • Contiguous Allocation
  • Each file occupies a set of contiguous blocks on
    the disk.
  • Simple only starting location (block ) and
    length (number of blocks) are required.
  • Random access.
  • Wasteful of space (dynamic allocation problem).
  • Files cannot grow.
  • Linked Allocation
  • Indexed Allocation

18
Linked Allocation
  • Each file is a linked list of disk blocks blocks
    may be scattered anywhere on the disk.
  • Simple need only starting address
  • Free-space management system no waste of space
    except for pointers
  • No random access
  • File-allocation table (FAT) disk-space
    allocation used by MS-DOS and OS/2.
  • A table used as a linked list keeping track of
    all available and used blocks. See Fig. 12-6.

19
Indexed Allocation
  • Brings all pointers together into the index
    block. In Unix called (i-node).
  • Random access
  • Dynamic allocation without external
    fragmentation, but have overhead of index block.
  • Wasted space for index block. Worse than linked
    allocation.
  • How big should the index block be?

20
Use of Multi-level Index Unix i-node
21
  • Where is the path stored in the inode of a
    softlink file?
  • Where is list of file names in a directory inode
    is stored?

22
Directory Implementation
  • Linear list of file names with pointer to the
    data blocks.
  • simple to program
  • time-consuming to execute
  • Hash Table linear list with hash data
    structure.
  • decreases directory search time
  • collisions situations where two file names hash
    to the same location
  • fixed size

23
Efficiency and Performance
  • Efficiency dependent on
  • disk allocation and directory algorithms
  • types of data kept in files directory entry
  • Performance
  • disk cache separate section of main memory for
    frequently used blocks
  • free-behind and read-ahead techniques to
    optimize sequential access
  • improve PC performance by dedicating section of
    memory as virtual disk, or RAM disk.

24
Caching and Recovery
Various Disk-Caching Locations
  • Consistency checker compares data in directory
    structure with data blocks on disk, and tries to
    fix inconsistencies.
  • Use system programs to back up data from disk to
    another storage device (USB disks, tapes, or
    Cloud Computing dropbox).
  • Recover lost file or disk by restoring data from
    backup.
  • NTFS Features Logging or journaling, Encryption,
    Compression, Larger sizes than FAT, but more
    overhead (space and time).
Write a Comment
User Comments (0)
About PowerShow.com