CHAPTER 11: FILE-SYSTEM INTERFACE - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

CHAPTER 11: FILE-SYSTEM INTERFACE

Description:

Name: The symbolic file name in human-readable form ... inconvenient, whereas too many cause OS bloat and programmer confusion. ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 43
Provided by: zkg4
Category:

less

Transcript and Presenter's Notes

Title: CHAPTER 11: FILE-SYSTEM INTERFACE


1
CHAPTER 11 FILE-SYSTEM INTERFACE
  • File Concept
  • File Access
  • Directory Structure
  • File System Mounting
  • File Sharing
  • File Protection

2
FILE CONCEPT
  • Introduction
  • File attributes
  • File types
  • File structures
  • File operations

3
File concept
  • What is a file
  • A file is named collection of related information
    that is recorded on secondary storage.
  • Content types
  • Data
  • numeric
  • alphabetic
  • alphanumeric
  • binary
  • Program
  • source programs
  • Object forms

4
File concept Attributes
  • File attributes
  • Name The symbolic file name in human-readable
    form
  • Identifier to identify the file within the file
    system (Internal)
  • Type to support different types.
  • Location the location on the secondary storage
    device.
  • Size the current size (and/or its maximum size)
  • Protection who can do reading, writing,
    executing, and so on.
  • Time, date, and user identification This
    information may be kept for creation, last
    modification, and usage monitoring.
  • Typically, the directory entry consists of the
    files name and its unique identifier. The
    identifier in turn locates the other file
    attributes. One of the file attributes is the
    location of file.

5
File concept Types
  • If an OS recognizes the type of a file, it can
    then operate on the file in reasonable ways.
  • Some common file types (See the next slide)
  • The TOPS-20 OS If the user tries to execute an
    object program whose source file has been
    modified (or edited) since the object file was
    produced, the source file will be recompiled
    automatically.
  • The Apple Macintosh OS Each file has a type and
    also has a creator attribute containing the name
    of the program that created it.
  • The Linux File types are just hints. How to
    determine a file type on the Linux.

6
File concept Types
7
File concept Structure
  • File structures
  • None - sequence of words, bytes
  • Simple record structure
  • Lines, Fixed length, Variable length
  • Complex Structures
  • Formatted document
  • Relocatable load file
  • Can be implemented by inserting appropriate
    control characters.
  • Who decides Operating system and Program
  • Conclusion Too few structures make programming
    inconvenient, whereas too many cause OS bloat and
    programmer confusion.

8
File concept Operations
  • Create to allocate the file space and allocate
    the directory entry
  • Read/Write/Seek to find the directory entry and
    keep a read/write pointer or seek to a new
    position.
  • Delete to find the directory entry and release
    all file space and erase the directory entry
  • Truncate to find the directory entry and release
    some file space
  • Open(F) to search the directory structure on
    disk for entry F, and copy the directory entry
    into the open-file table and allocate a file
    descriptor.
  • Close (F) to copy the directory entry in the
    open-file table to the directory structure on
    disk and free the file descriptor

9
File concept Operations
  • File tables
  • Single user Per-process file table ? secondary
    storage
  • Multiple-users Per-process file table ?
    system-wide table ? secondary storage
  • Several pieces of information are associated with
    an open file
  • File pointer
  • File open count
  • Disk location of the file
  • Access rights

10
FILE ACCESS
  • Sequential Access
  • read next
  • write next
  • reset
  • Direct Access
  • read n
  • write/rewrite n
  • position to n
  • read next
  • write next
  • n relative block number
  • To simulate sequential access by direct access is
    easy
  • (To simulate direct access by sequential access
    is NOT easy)

11
File access Sequential-access
12
File access Direct-access
13
File access Other access
  • Index file
  • Master index
  • ? index file
  • ? file data
  • (ISAM Indexed Sequential-Access Method from IBM)

14
File access Other access
15
DIRECTORY STRUCTURE
  • Disks ? partitions/minidisks/volumes ?FS ?
    Directories ?Files
  • The directory is used to organize files (and
    directories)
  • The directory can be viewed as a symbol table
    that translates file names into their directory
    entries.
  • The operations on directories
  • Search a file
  • Create a file
  • Delete a file
  • List a directory
  • Rename a file
  • Traverse the file system

16
Directory structure
A Typical File-system Organization
17
Directory structure Criteria
  • 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
  • all Java programs
  • all games

18
Directory structures
  • Single-level directory
  • Two-level directory
  • Tree-structured directory
  • Acyclic graph directory
  • General graph directory

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

20
Directory structure Two-Level Directory
  • Separate directory for each user.
  • MFD/UFD/FileName (Path name)
  • Can have the same file name for different user
  • Efficient searching
  • No grouping capability

21
Directory structure Tree-Structured Directories
22
Directory structure Tree-Structured Directories
  • Efficient searching
  • Grouping Capability
  • Current directory (working directory)
  • cd /spell/mail/prog
  • type list
  • Absolute or relative path name
  • Creating a new file is done in current directory.
  • Delete a file
  • rm ltfile-namegt
  • Creating a new subdirectory is done in current
    directory.
  • mkdir ltdir-namegt
  • Example if in current directory /mail
  • mkdir count

23
Directory structure Acyclic-graph directories
24
Directory structure Acyclic-graph directories
  • Tree-structured directory sharing ?
    Acyclic-Graph Directories
  • Linux ln
  • hard link
  • soft link
  • Potential problems
  • To traverse the FS
  • To delete a file (for symbolic link and hard link)

25
Directory structure General graph directory
26
Directory structure General graph directory
  • Potential problems
  • To traverse the FS (maybe looping forever)
  • To determine when a file can be deleted.
  • Garbage collection

27
FILE SYSTEM MOUNTING
  • A file system must be mounted before it can be
    accessed.
  • A unmounted file system (I.e. Fig. 11-11(b)) is
    mounted at a mount point.

28
(a) Existing. (b) Unmounted Partition
29
File System Mounting
  • /etc/fstab
  • Device
  • Mount point
  • File system type
  • Mount options
  • For dump
  • For fsck
  • Mount/umount, swapon/swapoff
  • /proc

30
FILE SHARING
  • For multi-user OS
  • Sharing of files on multi-user systems is
    desirable.
  • Sharing may be done through a protection scheme.
  • File sharing over the network
  • FTP
  • WWW
  • NFS

31
File Sharing Remote file systems
  • The C/S Model
  • The server
  • To declare that a resource is available to
    clients
  • To specify exactly which resource and exactly
    which clients.
  • The client
  • To access the remote files.
  • The protocol
  • Authentication
  • Operations.

32
File Sharing Remote file systems
  • How to use NFS
  • Startup nfs
  • /etc/rc.d/init.d/nfs
  • setup or ntsysv
  • /etc/exports
  • Mount NFS
  • mount server_machine/exported_fs mount_point
  • /etc/fstab

33
File Sharing Remote file systems
  • Distributed Information Systems
  • To provide a unified access to the information
    needed for remote computing.
  • DNS domain name to IP address
  • Yellow pages to centralize storage of user name,
    hostnames, printer information, and the like.
  • Yellow pages ? NIS ? NIS (Sun Microsystems)
  • Domains ? Active directory (Microsoft)
  • ?LDAP (Lightweight directory-access protocol)

34
File Sharing Remote file systems
  • Failure Modes
  • For one machine, to use RAID (Redundant Arrays of
    Inexpensive Disks) to prevent data loss
  • For networked machines,
  • Stateful mode
  • Too many problems can cause operation to fail.
  • not good enough.
  • Stateless
  • The protocol carries all the information needed
    to locate the appropriate file and perform the
    requested operation on a file.

35
File Sharing Consistency semantics
  • Consistency semantics
  • specifies the the semantics of multiple users
    accessing a shared file simultaneously.
  • In particular, these semantics should specify
    when modifications of data by one user are
    observable by other users.
  • UNIX semantics
  • Writes to an open file by a user are visible
    immediately to other users that have this file
    open at the same time
  • One mode of sharing allows users to share the
    pointer of current location into the file

36
File Sharing Consistency semantics
  • AFS (Andrew File System) Semantics
  • Writes to an open file by a user are not visible
    immediately to other users that have the same
    file open simultaneously.
  • Once a file is closed, the changes made to it are
    visible only in sessions starting later. Already
    open instances of the file do not reflect these
    changes.
  • Immutable-shared file semantics
  • Once a file is declared as shared by its creator,
    it cannot be modified.
  • An immutable file has two key properties. Its
    name may not be reused and its contents may not
    be altered.

37
FILE PROTECTION
  • File owner/creator should be able to control
  • what can be done
  • by whom
  • No access ? some controlled access ? full access
  • Types of access
  • Read
  • Write
  • Execute
  • Append
  • Delete
  • List

38
File protection
  • Access control lists
  • Mode of access read, write, execute
  • Three classes of users
  • RWX
  • a) owner access 7 ? 1 1 1 RWX
  • b) group 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.

39
File protection
  • Chmod
  • Find
  • Ls, cd, mkdir, cat, more, less, cmp, diff, sort,
    merge, tee, touch,

40
Homework
  • 3, 6, 7, 10, 11

41
(No Transcript)
42
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com