Chapter 11 FileSystem Interface - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Chapter 11 FileSystem Interface

Description:

Data: numeric, alphabetic, alphanumeric, binary. Program: source and object form. 5 ... Name only information kept in human-readable form ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 43
Provided by: ccNct
Category:

less

Transcript and Presenter's Notes

Title: Chapter 11 FileSystem Interface


1
Chapter 11 File-System Interface
2
Outline
  • File Concept
  • Access Methods
  • Directory Structure
  • File-System Mounting
  • File Sharing
  • Protection

3
11.1 File Concept
4
Introduction
  • OS abstracts from the physical storage devices to
    define a logical storage unit File
  • Types
  • Data numeric, alphabetic, alphanumeric, binary
  • Program source and object form

5
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 (and the maximum allowable)
    size
  • Protection controls who can read, write,
    execute
  • 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 physical
    storage device.

6
File Operations
  • Delete
  • Search the directory
  • Release all file space
  • Truncate --
  • All attributes to remain unchanged, but for the
    file to be reset to length zero
  • Open(Fi)
  • Search the directory structure on disk for Fi
  • Move the content of the directory entry to memory
  • Close(Fi)
  • move the content of entry Fi in memory to
    directory structure on disk
  • Create
  • Allocate space
  • Make an entry in the directory
  • Write
  • Search the directory
  • Write is to take place at the location of the
    write pointer
  • Read
  • Search the directory
  • Read is to take place at the location of the read
    pointer
  • Reposition within file file seek
  • Set the current file pointer to a given value

7
Open-File Table
  • OS keeps a small table containing information
    about all open files
  • Each time a file is opened, the content of the
    directory entry of the file is moved into the
    table
  • File Handle (file descriptor, file control
    block) an index into the table for a file
  • Two levels of internal tables in multi-user OS
  • Per-process table All the files opened by a
    process
  • Current file pointer
  • System-wide open-file table Process independent
    information
  • Location of file on disk, access dates, file size
  • File open count

8
A Typical Open-File Table
9
Two-Level Open-File Table
Open File Table for Proc. A
System-Wide Open File Table
Open File Table for Proc. B
10
File Types Name, Extension
If OS recognizes the type of a file, it can
operate on the file in a reasonable way
11
File Structure
  • None - sequence of words, bytes
  • Simple record structure
  • Lines
  • Fixed length
  • Variable length
  • Complex Structures
  • Formatted document
  • Relocatable load file
  • All operating systems must support at least one
    structure that of an executable file
  • Who decides
  • Operating system
  • Program

12
11.2 Access Methods
13
Access Methods
  • Sequential Access information is processed in
    order
  • read next
  • write next (append to the end of the file)
  • reset to the beginning of file
  • skip forward or backward n records
  • Direct Access a file is made up of fixed length
    logical blocks or records
  • read n
  • write n
  • position to n
  • read next
  • write next
  • rewrite n

Sequential-access file
14
Access Methods Index and Relative File
15
11.3 Directory Structure
16
Directory Structure
  • A collection of nodes containing information
    about all files.
  • Both the directory structure and the files reside
    on disk.
  • Backups of these two structures are kept on
    tapes.

17
A Typical File-System Organization
18
Information in a Device Directory
  • Name
  • Type file, directory, symbolic link, special
    file
  • Address device blocks to store a file
  • Current length
  • Maximum length
  • Date last accessed (for archival)
  • Date last updated (for dump)
  • Owner ID (who pays)
  • Protection information (discuss later)

19
Operations Performed on Directory
  • Search for a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a file
  • Traverse the file system

20
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, )

21
Single-Level Directory
  • A single directory for all users.
  • Naming problem
  • Grouping problem

22
Two-Level Directory
  • Separate directory for each user.
  • Path name
  • Can have the same file name for different user
  • Efficient searching
  • No grouping capability

23
Tree-Structured Directories
Subdirectory is just a special type of file
24
Tree-Structured Directories (Cont.)
  • Efficient searching
  • Grouping Capability
  • Current directory (working directory)
  • cd /spell/mail/prog
  • cat list
  • Create a new file/subdirectory is done in current
    directory
  • Absolute path name relative path name
  • How to handle the deletion of a directory

25
Acyclic-Graph Directories
  • Can have shared subdirectories and files.
  • A shared file can have different names (aliasing)
  • Shared file implementation
  • Symbolic link a pointer to another file or
    directory
  • ln -s /spell/count /dict/count
  • Hard link duplicate all information (especially
    device address) in shared directory

/spell/count
26
Symbolic VS. Hard Link
27
Acyclic-Graph Directories (Cont.)
  • If /dict/w/list is deleted ? dangling pointer.
  • Solutions Preserve the file until all references
    to it are deleted
  • Backpointers a list of all references to a file
    (directory entries or symbolic links)
  • Variable size records a problem
  • Entry-hold-count solution a count
  • A count of the number of references
  • Used in UNIX for hard links

28
General Graph Directory
29
General Graph Directory (Cont.)
  • How do we guarantee no cycles?
  • Allow only links to file not subdirectories
  • Garbage collection
  • Every time a new link is added use a cycle
    detectionalgorithm to determine whether it is OK
  • Traversal problem
  • Dont traverse the same directory or file twice

30
11.4 File-System Mounting
31
File-System Mounting
  • A file system must be mounted before it can be
    accessed
  • A file system is mounted at a directory called
    the mount point
  • Mounting steps mount /device/dsk /users
  • Give the device name and the mount point
  • Verify that the device contains a valid file
    system
  • Check if the device directory has a valid format
  • OS notes that a file system is mounted at the
    specified mount point
  • What if the mount-point contains files?
  • The original files are not available, until the
    file system is un-mounted
  • Same file system can be mounted repeatedly, at
    different mount points

32
File-System Mounting
Existing
Mount Point
Un-mounted Partition(/device/disk)
33
11.5 File Sharing
34
File Sharing
  • Sharing of files on multi-user systems is
    desirable
  • Sharing may be done through a protection scheme
  • On distributed systems, files may be shared
    across a network
  • Network File System (NFS) is a common distributed
    file-sharing method
  • A remote file system must be mounted before using
  • mount claven.lib.nctu.edu.tw/OS /chow/book
  • Once files are mounted, they are accessed by
    using the concatenated logical path names without
    referencing either the remote hosts or local
    devices

35
Remote File-System Mounting Example
root
root
Export
chow
OS
Mount
paper
book
DFS
DSM
/OS/DSM
Local Client
Remote Server
36
Remote File-System Mounting
  • Different clients may perceive a different FS
    view
  • To achieve a global FS view SA enforces
    mounting rules
  • Export a file server restricts/allows the
    mounting of all or parts of its file system to a
    predefined set of hosts
  • The information is kept in the servers export
    file
  • File system mounting
  • Explicit mounting clients make explicit mounting
    system calls whenever one is desired
  • Boot mounting a set of file servers is
    prescribed and all mountings are performed the
    clients boot time
  • Auto-mounting mounting of the servers is
    implicitly done on demand when a file is first
    opened by a client

37
No Global Naming in NFS
38
A Simple Automounter for NFS
39
11.6 Protection
40
Protection
  • File owner/creator should be able to control
  • What can be done
  • By whom
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

41
Access Lists and Groups
  • Mode of access read, write, execute
  • Three classes of users owner, group, universe
  • User name and user identifier
  • Group name and group identifier
  • 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
  • In UNIX three field of 3 bits each
  • field read, write, execute
  • Bits r(4), w(2), x(1)

42
Access Lists and Groups (Cont.)
Write a Comment
User Comments (0)
About PowerShow.com