Chapter 10: FileSystem Interface - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Chapter 10: FileSystem Interface

Description:

Name for human identification. Identifier unique tag ... Truncate (=erasing the contents) Implementing File Operations. Open Files. Necessary information ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 49
Provided by: luce169
Category:

less

Transcript and Presenter's Notes

Title: Chapter 10: FileSystem Interface


1
Chapter 10 File-System Interface
2
Motivation
  • What is a file system?
  • Why necessary?
  • How to unify multiple file systems?

3
What is a file system?
4
File Concept
  • Contiguous logical storage space
  • With structure defined by OS/application
  • Simple record structure
  • Lines
  • Fixed length
  • Variable length
  • Complex Structures
  • Formatted document

5
File Attributes
  • Name for human identification
  • Identifier unique tag (number) within file
    system
  • Type
  • Location
  • Size
  • Protection controls who can do reading,
    writing, executing
  • Time, date, and owner data for protection,
    security, and usage monitoring
  • File information kept in directory structure

6
File Operations
  • Create
  • Write
  • Read
  • Reposition within file (eg., file seek)
  • Delete
  • Truncate (erasing the contents)

7
Implementing File Operations
8
Open Files
  • Necessary information
  • 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 (eg., multiple processes)
  • Disk location of the file cache of data access
    information
  • Access rights per-process access mode information

9
Open File Locking
  • Provided by OS/file system
  • Mediates access to a file
  • Mandatory or advisory
  • Mandatory access is denied depending on locks
  • Advisory processes can find status of locks and
    decide what to do (eg., readonly)

10
File Locking Example
  • public class LockingExample
  • public static final boolean EXCLUSIVE false
  • public static final boolean SHARED true
  • public static void main(String arsg) throws
    IOException
  • FileLock sharedLock null
  • FileLock exclusiveLock null
  • try
  • RandomAccessFile raf new RandomAccessFile("fi
    le.txt", "rw")
  • // get the channel for the file
  • FileChannel ch raf.getChannel()
  • // this locks the first half of the file -
    exclusive
  • exclusiveLock ch.lock(0, raf.length()/2,
    EXCLUSIVE)
  • / Now modify the data . . . /
  • // release the lock
  • exclusiveLock.release()

11
File Locking Example
  • // this locks the second half of the file -
    shared
  • sharedLock ch.lock(raf.length()/21,
    raf.length(), SHARED)
  • / Now read the data . . . /
  • // release the lock
  • sharedLock.release()
  • catch (java.io.IOException ioe)
  • System.err.println(ioe)
  • finally
  • if (exclusiveLock ! null)
  • exclusiveLock.release()
  • if (sharedLock ! null)
  • sharedLock.release()

12
File Types Name, Extension
13
Access Methods?
  • File Attribute/Operation/Type
  • Access?

14
Access Methods
  • Sequential Access
  • read next
  • write next
  • reset
  • Direct Access
  • read n
  • write n
  • position to n
  • n relative block address
  • Indexed Access
  • read (smith)

15
Remote Control Analogy
16
Sequential vs. Direct Access
17
Brainstorming
  • What does it take to support a direct access?
  • Contiguous
  • Otherwise
  • What does it take to support an indexed access?

18
Indexed Access
19
Directory
  • File
  • Directory
  • Why? What? How?

20
Why Necessary?
  • Efficiency locating a file quickly
  • Convenience
  • Naming convenient to users
  • Files w/ same name can exist for different
    directories
  • Grouping logical grouping of files by
    properties, (e.g., all Java programs, all games,
    )

21
Directory Structure
  • A collection of nodes containing information
    about files within

Directory
Files
F 1
F 2
F 3
F 4
F n
22
Directory Operations
  • Create/delete/rename directories
  • List a directory
  • Search for a file
  • Create a file
  • Delete a file
  • Rename a file
  • Traverse the file system (eg., backup)

23
What is an ideal structure?
24
Single-Level Directory
  • A single directory for all users

25
Two-Level Directory
  • Separate directory for each user
  • Can have the same file name (if by different
    user)
  • Inefficient search
  • No grouping capability

26
Then what?
27
Tree-Structured Directories
28
Tree-Structured Directories (Contd)
  • Efficient searching
  • Grouping capability
  • Locating files
  • Absolute path (from root)
  • Relative path (from current)

29
Is the structure always a tree?
30
Acyclic-Graph Directory Structure
  • May have shared subdirectories and files

31
Pros and Cons
  • Avoid inconsistent copies
  • Complication

32
Acyclic-Graph Complications
  • dangling pointer
  • Solutions
  • Whenever file is deleted (soft link)
  • Wait until all refs deleted (hard link)
  • How can you implement these solutions?

33
Now, General Graph Directory
34
Brainstorming
  • What are new complications?
  • What are the solutions?

35
General Graph Directory
  • New complications
  • Traversal may take forever
  • ? possibly infinite paths
  • Deciding whether to delete
  • ? Reference count is infinite

36
Unified file system structure
  • Multiple disks
  • Multiple machines

37
NN mapping
38
File System Mounting
  • A remote file system can be mounted

39
Do you see potential problems?
40
Case Study Remote Failures
  • Remote file systems add new failure modes, (e.g.,
    network failure, server failure
  • Recovery from failure can involve state
    information
  • Stateless protocols such as NFS include all
    information in each request, allowing easy
    recovery but less security

41
File Consistency
42
Consistency Unix vs. AFS
  • Consistency semantics specify how multiple users
    are to access a shared file
  • Unix file system implements
  • Writes to an open file visible immediately to
    other users of the same open file (modified,
    reload?)
  • AFS has session semantics
  • Writes only visible to sessions starting after
    the file is closed

43
File Protection
44
A Sample UNIX Directory Listing
45
Access Lists and Groups
  • Mode of access read, write, execute
  • RWX
  • a) owner access 7 ? 1 1 1 RWX
  • b) group access 6 ? 1 1 0
  • RWX
  • c) public access 1 ? 0 0 1
  • For a particular file (say exam_solution) or
    subdirectory, define an appropriate access.

owner
group
public
exam_solution
chmod
761
Attach a group to a file chgrp
staff exam_solution
46
Protection
  • File owner/creator should be able to control
  • what can be done
  • by whom
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

47
Windows Example
48
End of Chapter 10
Write a Comment
User Comments (0)
About PowerShow.com