File - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

File

Description:

Operations: create, write-next, read-next, reposition 'next' pointer, delete, truncate. Provides ... No links - tree; hard - DAG; symbolic - arbitrary graph ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 12
Provided by: quynh6
Category:
Tags: dag | file

less

Transcript and Presenter's Notes

Title: File


1
File
  • File
  • named unit of storage defined by OS (storage unit
    is the same regardless of underlying hardware)
  • Defined as a sequence of bits, bytes, or records
  • Sequential or random access to file contents
  • Operations create, write-next, read-next,
    reposition next pointer, delete, truncate
  • Provides access on permanent media to named files
  • OS keeps track of which sectors comprise the file
  • Storage media
  • Hard disks
  • Removable floppy, zip
  • Read-only CDROM
  • Linear Tape

2
File Structure
  • Unstructured sequence of bytes
  • Most flexible
  • Any meaning can be imposed by user program
  • Used by Unix and Windows
  • Sequence of fixed-length records with internal
    structure
  • One entire record is read/written at a time
  • This structure is not currently used
  • Tree of records
  • Records may be of varying lengths
  • Each record has key in fixed position in record
  • Records sorted by key for easy search and
    retrieval
  • Used with large mainframe systems

3
Aspects of a File System
  • Comprised of 3 parts
  • Model of operation naming, access, type system,
    API, attributes
  • Storage subsystem how bits are stored on medium
    (file structure)
  • Distributed access definition of consistency
    and how caching/replication work to satisfy this
    definition (handle sharing of files)

4
File System Model
  • Model is what user sees in the file system
  • Naming
  • Syntax, such as case sensitivity
  • Restrictions on name length
  • Types of links
  • Attributes metadata characterizing files data
  • Typed vs. untyped entities
  • Access mounting, sharing, memory-mapped access
  • Entities in file system name space devices
    (special files), sockets, pipes, other hosts and
    domains
  • System calls and semantics
  • Is data really on disk when write() call returns?
  • What is atomic?
  • Which data are read during concurrent operations?
  • Meaning of ambiguous operations seek beyond end
    of file unlinking an open file cd .. after
    following a symbolic link

5
Model Naming
  • Individual names
  • Length restrictions (exp. MS DOS required 8.3
    file names)
  • Relative importance of extension for typing
  • Windows use extensions to associate files with
    programs
  • Unix use extensions just as convention and not
    enforced by OS
  • Directory
  • Name space organizing concept
  • hard vs. symbolic link
  • No links -gt tree hard -gt DAG symbolic -gt
    arbitrary graph
  • In Unix, directory concept is built into process
    concept current root vs. current directory

6
Model Naming
  • Symbolic links
  • Indicated by file attribute
  • During name interpretation, symbolic link is read
    and interposed into name
  • File listing with symbolic links can cause
    infinite loops (ls lR vs ls LR)
  • OS quits name interpretation after seeing more
    than a certain number of symbolic links in a
    single name interpretation operation or if it
    sees the same inode twice
  • Why have symbolic links if they cause so much
    trouble?
  • Its the only way to have links across file
    systems

7
Model File Attributes
  • Attributes are metadata data describing the
    file data and/or how to use it
  • Possible attributes type, size, access control,
    dates, lock bit, version number
  • Attributes vary across file systems
  • Type attribute
  • Special types system file, hidden
  • Information relevant to type program that
    created data record size location of key field
    length of key
  • Size current, maximum allowed
  • Dates creation, last read, last modified,
    version number
  • Access control owner (user or program), group
    access, password, lock indicator

8
Model File Types
  • General types
  • Regular files contain user information
  • Directories system files for maintaining
    structure of file system
  • Character special files I/O for character
    devices
  • Block special files I/O for block devices

9
Model Regular File Typing
  • Strong typing
  • OS is aware of certain types
  • Optimizes access to these types
  • At system call level, prevents all but certain
    uses of these types and/or certain programs from
    using the files
  • Disadvantages
  • There will always be new types
  • Different types important to different users, so
    never have all the types everyone wants
  • N types means N modules of code in the OS
    bloats OS code
  • Harder to change type code inside OS
  • Need escape mechanism to use typed file in a
    different way, but lose benefits of strong typing

10
Model Regular File Typing
  • Unix untyped files were considered an advance
    over IBM record-oriented file types
  • Still, often useful to know the type
  • Prevent mistakes by naïve users
  • Mac PC convention is to map one file type to
    one program
  • Levels of typing
  • Strong typing enforced by OS at system call level
    (all applications must obey)
  • Weaker typing enforced at level of user
    visibility by launching applications based on
    type
  • Weakest extension is just a convention, no OS or
    shell enforcement, though user applications may
    choose to enforce

11
Unix Executable Type
  • Unix executables identified via magic number that
    is part of the data (in first few bytes of the
    file)
  • Interpreted ASCII scripts have interpreter
    explicitly named at beginning of file
  • The chararcter on 1st line indicates a script
  • Interpreter also named on 1st line
    !/usr/bin/perl
  • Some programs have their own first-byte
    convention (exp. Postscript !PS-Adobe-2.0)
  • Example of Unix executable binary file
Write a Comment
User Comments (0)
About PowerShow.com