SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
File Management (Continued)

   COMP 229 (Section PP) Week 10

       Prof. Richard Zanibbi
       Concordia University
          March 20, 2006
Last Week...File Management
File System Types (pp. 514-528)
  Low-Level File System (for Byte Stream Files)
  Structured File System (e.g. for records, .mp3 files)

Low-Level File System Implementations
(pp. 529-544)
  Low-level file system architecture
  Byte stream file Open and Close operations
  Block Management (in part)

                                                          2
Files and the File Manager
Files As Resource Abstraction
  Files are used to represent data on storage devices (e.g. disk)

Files As a Central Abstraction of Computation
  – Most programs read one or more files, and eventually write results to
    one or more files
  – Some view programs as filters that read data, transform the data, and
    write the result to a new file (is this an “extreme view”?)
     • e.g. UNIX shell applications using the pipe operator ( | )
  – In C: by default, stdin, stdout, stderr are defined

File Manager (OS Service Responsible for Files)
  – Implements file abstraction (including APIs for file types)
  – Implements directory structure for organizing files
  – Implements file systems for organizing collections of directories (e.g. on
    separate disks)
  – File management involves operations on external devices & memory 3
File Descriptors, Revisited
         Field                        Purpose
External Name            A string identifier
Sharable                 Can processes share the file? For
                         read/write/execution?...
Owner                    User who created the file
Protection Settings      Which users can read/write/execute
                         the file
Length                   Number of bytes in file
Time of Creation         When file was created
Time of Last Modific.    Date when file was last written to
Time of Last Access      Date when file was last used
Reference Count          # directories in which file appears
Storage Device Details   File block organization (on device)
                                                               4
File System Types
External View of File Manager
  Part of the System Call Interface implemented by the file manager (see Fig.
    13.2)

Low vs. High-Level (Structured) File Systems
  See Fig. 13.3
  – Low Level File System implements only Stream-Block Translation and
    Byte-Stream Files (e.g. WIndows, Unix)
     • Applications must translate byte streams to/from abstract data types used in
       programs
  – Structured (High-Level) File Systems also implement Record-Stream
    translation and Structured Record files (e.g. MacOS, systems for
    commercial applications, e.g. some IBM systems)
     • Have a language for defining record types, keys for searches

  Marshalling: producing blocks from records (“flattening”)
  Unmarshalling: producing records from blocks

  See Fig. 3.16 (marshalling a record into a byte stream)
                                                                                      5
Structured File Types
(Record-Oriented) Structured Sequential Files
  Records organized as a list
  Record attributes encoded in file Header

Indexed Sequential Files
  – Records have an integer index in their header
  – Records contain one or more fields used to index records in the file (e.g.
    student #)
  – Applications of File Manager define tables associating record
    attributes with index values
  – Representation: just index values in records, linked lists (one per key), or
    stored index table (used by file manager)
  – Popular in business, human resources applications

Inverted Files
  – Generalized external (system) index tables used by file manager: allow
    entries to point to groups of records or fields
  – New record fields are extracted and placed in the index table, with pointer in
    the table to the new record where appropriate
  – Records accessed using the index table rather than location in file              6
struct message {                          Abstract Data Type
  address to;                            (for email messages)
  address from;
  line subject;
  address cc;
  string body;
}                                            Retrieves next record

struct message *getRecord(void) {
  struct message *msg;
  msg = allocate(sizeof(message));
  msg->to = getAddress(...);
  msg->from = getAddress(...);
                                     •Programmer-defined abstract data
  msg->cc = getAddress(...);         types
  msg->subject = getLine();          •Programmer-defined record
  msg->body = getString();           read/write methods (e.g. using
  return(msg);                       standard, predefined access function
}                                    names)
                                     •File Manager invokes programmer
putRecord(struct message *msg) {
                                     routines
  putAddress(msg->to);                       Appends record to file
  putAddress(msg->from);
  putAddress(msg->cc);
  putAddress(msg->subject);
  putString(msg->body);      Example: (“Record-Oriented”) Structured
}                                Sequential File for an “Inbox”             7
Opening Files
Fig. 13.10
  – Opening a file
  – Note difference between internal and external file
    descriptor
  – Also, note that an additional process-specific data
    structure is needed (Process-File Session)

Fig. 13.11
  – Opening a Unix file
  – Note that Process-File Session is represented using
    two Data Structures (Open File Table, File Structure
    Table)

                                                           8
Closing a File

When Issued:
 All pending operations completed (reads, writes)
 Releases I/O buffers
 Release locks a process holds on a file
 Update external file descriptor
 Deallocate file status table entry




                                                    9
This week...File Management (Cont’d)

 File Management (pp. 534-558)
  Block Management, Continued
  Reading/Writing Byte Streams
  Supporting High-Level File Abstractions
  Directories (Structures, Implementations)
  File Systems




                                              10
Block Management, and
Reading and Writing Byte Streams
Block Management
Purpose
  Organizing the blocks in secondary storage (e.g. disk) that hold file
      data
  (blocks containing file data are referenced from the “Storage Device
      Detail” field in a file descriptor; see p.530)

Computing number of blocks for a file
  See page 534 in text

Block Management Strategies:
  1. Contiguous allocation
  2. Linked lists
  3. Indexed allocation

                                                                          12
Examples of Block Management
Contiguous Allocation
  See Fig. 13.12
  All blocks are adjacent (contiguous) on storage device: fast write/read
  Problems with external fragmentation (space between files)
     • must be space for the whole file when file is expanded; if not, the whole file must be
       relocated to another part of storage (e.g. the disk)
  NOTE: “Head Position” is the location of the file pointer (current byte)

Linked Lists (Single and Doubly-Linked)
  See Figs. 13.13 and 13.14
  Blocks have fields defining the number of bytes in a block and link(s) to the next
    (also previous, if doubly-linked) block in the file
  Blocks do not have to be contiguous, allowing us to avoid the fragmentation
    problems with contiguous allocation

Indexed Allocation
  See Fig. 13.15
  Size/link headers for blocks separated from the blocks and placed in an index
  Index is stored with the file, and loaded into memory when a file is opened
  Speeds searching, as all blocks are stored within the index table (no link
    following to locate blocks in the file)=                                  13
Contiguous Allocation Strategies
Best Fit
  Find smallest free area large enough for the file

First Fit
  – Use first unallocated block sequence large enough for
    the file
  – Found using linear search

Worst Fit
  – Use largest available contiguous space
  – Divide space in 2, one part for the file, the rest for free
    space

                                                                  14
Block Representation in Unix File
           Descriptors
UNIX File Descriptors
  See Table 13.1

UNIX File Block Representation
  See Fig. 13.16
  – 12 direct links to data blocks
  – 3 index block references, which are singly, doubly, and triply
    indirect, respectively
  Block Types: Data or Index
  Index Block: list of other data or index blocks
  The Unix block representation can represent more locations than
    most machines can store (example numbers given in text)



                                                                     15
UNIX File Descriptors (inode)
           Field                       Purpose
Mode                      Access permissions
UID                       ID for user that created the file
Group ID                  ID identifying group of users with
                          access to the file
Length in bytes           Number of bytes in file
Length in blocks          Number of blocks implementing file
Time of Last Modific.     Time when file was last written to
Time of Last Access       Time when file was last read
Time of Last inode mod.   Time when inode was last changed
Reference Count           # directories in which file appears
Block references          Pointers, indirect pointers to file
                          block                                 16
DOS File Allocation Tables (FAT)
Represents Linked List Allocation
 Each location in the table is a logical block address
 Content of each table cell is a pointer to the next block in
  a file, or an “end of file” marker


“Modern” FAT Alteration
 Table locations point to clusters (a group of contiguous
  blocks) rather than individual blocks




                                                                17
Unallocated Blocks
“Free List” representation
  A linked list of unallocated blocks
  Very large, particularly if disk is mostly empty
  Hard to efficiently manage so that adjacent free blocks
   can be easily found

Block Status Map
  Represents every block on a disk using one bit
  If bit is on, block is used (‘0’ if free)
  Can be kept in memory; much faster to find adjacent free
     blocks vs. a free list
  Useful for checking file system contents
    • e.g. comparing blocks that files on a disk reference vs. those
      that are indicated as used in the Block Status Map, as part of
      disk recovery                                                    18
Packing/Unpacking Blocks
Reading/Writing
  – File system reads/writes one block of data at a time
  – Blocks of data are copied into or out of the byte stream for the file
  – On file open, first block is copied into memory (as byte stream),
    and file pointer located at the start of the first block.
  – Processes operate on the copy of the data that is in memory (the
    byte stream)
  – Write operations pack (marshall) bytes into copies of device
    storage blocks into memory. When blocks become full, the write
    operation will transfer the blocks to the device
  – Note that when we open for writing, the block is still read in, and
    overwritten. When the program finishes writing out a block, the
    write operation will arrange for the data to be written to disk



                                                                            19
Packing/Unpacking Continued
Location of a Byte on Disk
  Assuming we have fixed-sized blocks (of size k),
  then we can compute the block containing a byte using N = i/k ,
    where N is the block number

See Fig. 13.18
  – Inserting/Deleting bytes in the interior of a byte-stream file
  – Leads to internal fragmentation (unused block bytes)

Buffering (see page 544)
  To improve performance, file manager tries to read ahead blocks in
    a file (into a “buffer”), and “write behind” the blocks that have been
    filled in the buffer used to store bytes in the file

                                                                             20
Supporting High-Level File
      Abstractions
Structured Sequential Files
Implementation
  Logically same as for byte stream file manager
  – record rather than byte-based
  – insertion: similar issues per bytes in low-level files


Additional File Descriptor Fields:
  File type (e.g. relocatable object file, postscript)
  Access methods (abstract data type function.)
    • May be fixed (e.g. OS-provided)
    • May be programmer-defined (e.g. email example)
  Other: relationships with other files, minimum version
   number of file manager handling file type, etc.
                                                             22
Indexed Sequential Files
Index Field
  Normally indicates order of records (from 0)

Implementation
  – File manager manages mapping from records to blocks
    (I/O requests are record index-based)
  – Inserting records causes complications (e.g.
    fragmentation issues)
  – Optional index table
  – Buffers unlikely to be very helpful for many usage
    scenarios (e.g. servicing bank customers)

                                                          23
Database Management Systems
Storage Manager
  Replaces file manager
  Low-level interface, allow direct manipulation of storage devices

Database Administrator
  Chooses organization or records across and within files

Common Database Types
  Relational: concerned with efficient searches on relationships
  Object-Oriented: application defines access methods
  *Conventional file system interfaces do not support these

*Note
  Usually data stored in a database cannot be accessed by the
   “normal” file interfaces of the File Manager
                                                                      24
Multimedia Documents
Storage Demands
 Similar to databases (OO databases often support
  multimedia files)


Performance Issues
 – Block allocation affects streaming/bandwidth
 – File Manager: normally assume that applications will
   not request multiple blocks simultaneously
 – *No widely-used OS’s currently provide high
   performance support for multimedia files

                                                          25
Directories
(Structures, Implementations)
File Directories

File Directory
 A set of files and other (sub)directories
 Principle function: help people find their way
  around data on a system


Implementation
 Directories are stored as additional files



                                                  27
Operations for Directory Management
 (key parameter: file/directory name)
 Enumerate
   List contents of a directory (files, subdirectories)
        • e.g. using ‘ls’ in Unix, ‘dir’ in Windows

 Copy
   Make a copy of a file (e.g. within the directory)

 Rename
   Change file name

 Delete
   Remove file from current directory; release file descriptor and all blocks in
     the file

 Traverse
   Change current directory by indicating new directory to go to
   – e.g. ‘cd’ in Unix, Windows

                                                                                   28
Motivation for Structuring Directories
  (e.g. organizing lecture notes)
Small Number of Files (e.g. 5 lectures)
  – Small enough to easily sort through

‘Medium’ Number of Files (e.g. 50 lectures)
  – Now probably easier to manage if we organize by
   course, for example (one group of subdirectories)

Large Number of Files (e.g. database, Millions)
  – Becomes impractical to manage manually: start
    employing additional subdirectories
  – Perhaps even patterns of subdirectories
    • all courses also have subdirectories for each year
    • each year has subdirectories for each term, etc.
                                                           29
(Pure) Hierarchical File Organization
         in the “Real” World
File
  Paper Document (e.g.)

Folder
  Group of Files, with an additional document summarizing the files in
   the folder (the directory)

“Super” Folder
  Contains a group of folders and files, with an additional directory
   summarizing the folder contents

File Drawer...
File Cabinet...
Filing Room...
Filing Building...
Filing Complex...
                                                                         30
Filing Nation (?....)
Directory Structures
...refers to how directories are organized and related in a system

Root Directory
  Initial node in a hierarchical file system
  – e.g. “/” in Unix

Directory Tree
  Most common directory structure: purely hierarchical organization (creating
   a tree)

File/Directory Sharing
  – Example: two or more users wish to refer to the same file from within their
    own home directories
  – Reference count in file descriptors used to prevent a shared file from
    being deleted when still being used
  – Tree becomes a directed (and hopefully acyclic) graph

                                                                                  31
Directory Structures

See Fig. 13.19
 Note that a “Strict Hierarchy” is often called a
  “directory tree”




                                                    32
Absolute and Relative Paths
Absolute Path
 Path from the root directory to the desired directory/file
    • e.g. “/home/zanibbi/comp229/slides.ppt”
    • e.g. “D:myfileszanibbicomp229slides.ppt”


Relative Path
 Path from (“relative to”) a given directory
    • (usually current)
    • e.g. : “comp229/slides.ppt” (from /home/zanibbi)
    • e.g. : “comp229slides.ppt” (from D:myfileszanibbi)


                                                              33
Example: DOS File Directory
             “This Machine”    (usually implicit root directory of file system)



A:   B:       C:            D:                (Disk Drive D)
...   ...       ...
                              USER

                  GJN                           PROGRAMS

       BIN            AUTOEXEC.BAT                PRIME.C

      PATCH




                                                                           34
Example: Unix File Directories
Directed Acyclic Graphs
  Root Directory: “/” (e.g. “cd /”)



                                   /

              home           etc       lib   bin


  zanibbi            jones


 comp229


 slides.ppt
                                                   35
Implementing Directories
Directory (as File)
 Set of structured records (files/directories)


Directory Entries (Records)
 Each record refers to an external file descriptor,
  provides information for locating the external
  file descriptor
   • Linux: Filename, disk address for external file
     descriptor
   • MS-DOS: Filename, extension (type), creation time,
     file size, address of first file block
                                                          36
Implementing Directories, Cont’d
Directory Operations
 Operate on directory (record) entries
 If file attributes stored on disk, must be retrieved (e.g.
    Linux)

Long File Names
 Old days: Usually 8 character length names (max)
 ~1990: “long” file names appear
   • MS-DOS: extra characters stored in additional directory entry
   • Unix: Create a heap in each directory, used for extra
     characters when needed

Directories On Disk
 Directory file has a file descriptor, indicating blocks
  where directory data is located on disk.                           37
Opening Files, Searching Paths
Path Representation
 – Directories, directory entries organize files on disk
 – To locate a file, directory entries must be used

Path Searching
 Recursive, from the initial directory (root directory for
  absolute paths)
   • e.g. /usr/gjn/books/opsys/chap13 – 5 directories
   • e.g. books/opsys/chap13 (from /usr/gjn) – 3 directories (must
     read current directory (“gjn”) to start)

Caching Directory Information
 To speed up searches, some file managers store
  directory data in memory
                                                                     38
File Systems
File Systems
Disk Partitioning
  For organization and performance, disks are often partitioned to act
    as two or more separate disks

Removable Storage
  Floppy disks, Zip disks, CD-ROMS, etc.
  – must combine directories for use by system

File System
  – Hierarchical file collection associated with a removable or
    permanent storage medium
  – Single root directory
  – Describes set of files on a removable storage medium

Volume
  The contents of a file system
                                                                         40
Example: ISO 9660 File System
     (see Figs. 13.21-13.23)
Creation of Standard
 Derived from “High Sierra” specification created by
  industry experts in 1986

Features
 – Focus: reading files (CD’s originally non-writable):
   simplifies block allocation
 – CDs store data in a single helical track
 – Sectors (blocks) are 2048 bytes
 – Each file/directory is stored in a contiguous set of
   sectors (contains file descriptor and file)

                                                          41
Mounting File Systems
System Boot Disk
 – Logical device (e.g. disk partition) from which the
   master boot record is loaded
 – Also the device that will contain the root directory for
   the system


Other Disks/Storage
 Must be “grafted” onto the base directory structure
 This “grafting” is often called “mounting” (from Unix)


                                                              42
Mounting File Systems, Cont’d
mount() – See Fig. 13.24
  – Unix system call requesting a removable device be
    added to the file hierarchy
  – Root directory of the mounted system will be treated
    as a subdirectory in the base hierarchy
  – Mounted files can be used as though part of the file
    system on the system boot disk
    • e.g. “mount /dev/cdrom”, “cd /media/cdrom”


umount()
  “Unmounts” a device from the base hierarchy
    • e.g. before removing a cd-rom
                                                           43
Heterogeneous File Systems
Definition
  A file system comprised of files systems of different
   types (e.g. ISO9660, ext3, FAT32)

Virtual File System (Linux – See Fig. 13.25)
  – File manager has file system dependent and
    independent parts
  – File System Dependent: reads/writes data
  – File System Independent: implements general file
    manager algorithms (e.g. traversal, delete, copy, etc.)
  – File Manager defines its own internal file descriptor
    (need to translate those from different file systems), in
    Linux, based on inodes (Unix)
                                                                44
Next Week...

Device Management
 pp. 152-174


Compilers (back to Part I of text)
 pp. 225-242
 Basic Compiler Functions
 Lexical Analysis using Finite State Automata


                                                45

Contenu connexe

Tendances

file system in operating system
file system in operating systemfile system in operating system
file system in operating systemtittuajay
 
Distributed file system
Distributed file systemDistributed file system
Distributed file systemAnamika Singh
 
Windows operating system
Windows operating systemWindows operating system
Windows operating systemLeah Gonzales
 
File system security
File system securityFile system security
File system securityAmmAr mobark
 
File system Os
File system OsFile system Os
File system OsNehal Naik
 
Windows V/S Linux OS - Comparison
Windows V/S Linux OS - ComparisonWindows V/S Linux OS - Comparison
Windows V/S Linux OS - ComparisonHariharan Ganesan
 
Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1abhinav baba
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File ManagementDamian T. Gordon
 
Network and System Administration chapter 2
Network and System Administration chapter 2Network and System Administration chapter 2
Network and System Administration chapter 2IgguuMuude
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device ManagementDamian T. Gordon
 
UNIX Operating System
UNIX Operating SystemUNIX Operating System
UNIX Operating SystemFatima Qayyum
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk managementTanveer Malik
 

Tendances (20)

Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
Distributed file system
Distributed file systemDistributed file system
Distributed file system
 
File Management
File ManagementFile Management
File Management
 
Windows operating system
Windows operating systemWindows operating system
Windows operating system
 
11. dfs
11. dfs11. dfs
11. dfs
 
File system security
File system securityFile system security
File system security
 
File system Os
File system OsFile system Os
File system Os
 
Windows V/S Linux OS - Comparison
Windows V/S Linux OS - ComparisonWindows V/S Linux OS - Comparison
Windows V/S Linux OS - Comparison
 
Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1Operating System - Types Of Operating System Unit-1
Operating System - Types Of Operating System Unit-1
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Windows Architecture
Windows ArchitectureWindows Architecture
Windows Architecture
 
operating system
operating systemoperating system
operating system
 
Hard drive partitions
Hard drive partitionsHard drive partitions
Hard drive partitions
 
Network and System Administration chapter 2
Network and System Administration chapter 2Network and System Administration chapter 2
Network and System Administration chapter 2
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device Management
 
Processes
ProcessesProcesses
Processes
 
UNIX Operating System
UNIX Operating SystemUNIX Operating System
UNIX Operating System
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk management
 

En vedette

File management ppt
File management pptFile management ppt
File management pptmarotti
 
File Management Presentation
File Management PresentationFile Management Presentation
File Management PresentationSgtMasterGunz
 
File Organization
File OrganizationFile Organization
File OrganizationManyi Man
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)Vaibhav Bajaj
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfsLucky Ali
 
File access methods.54
File access methods.54File access methods.54
File access methods.54myrajendra
 
Single level directory structure.55
Single level directory structure.55Single level directory structure.55
Single level directory structure.55myrajendra
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System ImplementationWayne Jones Jnr
 
37 segmentation
37 segmentation37 segmentation
37 segmentationmyrajendra
 
booting steps of a computer
booting steps of a computerbooting steps of a computer
booting steps of a computerAnusha Babooa
 
File System and File allocation tables
File System and File allocation tablesFile System and File allocation tables
File System and File allocation tablesshashikant pabari
 
File System Hierarchy
File System HierarchyFile System Hierarchy
File System Hierarchysritolia
 

En vedette (20)

File management ppt
File management pptFile management ppt
File management ppt
 
File Management Presentation
File Management PresentationFile Management Presentation
File Management Presentation
 
File Management
File ManagementFile Management
File Management
 
File system
File systemFile system
File system
 
File Management
File ManagementFile Management
File Management
 
File Systems
File SystemsFile Systems
File Systems
 
Memory management
Memory managementMemory management
Memory management
 
File Organization
File OrganizationFile Organization
File Organization
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Operating system.ppt (1)
Operating system.ppt (1)Operating system.ppt (1)
Operating system.ppt (1)
 
Ntfs
NtfsNtfs
Ntfs
 
Fat and ntfs
Fat and ntfsFat and ntfs
Fat and ntfs
 
File access methods.54
File access methods.54File access methods.54
File access methods.54
 
Single level directory structure.55
Single level directory structure.55Single level directory structure.55
Single level directory structure.55
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
37 segmentation
37 segmentation37 segmentation
37 segmentation
 
booting steps of a computer
booting steps of a computerbooting steps of a computer
booting steps of a computer
 
File System and File allocation tables
File System and File allocation tablesFile System and File allocation tables
File System and File allocation tables
 
File System Hierarchy
File System HierarchyFile System Hierarchy
File System Hierarchy
 

Similaire à File management

Similaire à File management (20)

File
FileFile
File
 
Ch11 OS
Ch11 OSCh11 OS
Ch11 OS
 
OSCh11
OSCh11OSCh11
OSCh11
 
OS_Ch11
OS_Ch11OS_Ch11
OS_Ch11
 
file management_osnotes.ppt
file management_osnotes.pptfile management_osnotes.ppt
file management_osnotes.ppt
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.ppt
 
Chapter 10 - File System Interface
Chapter 10 - File System InterfaceChapter 10 - File System Interface
Chapter 10 - File System Interface
 
OSCh12
OSCh12OSCh12
OSCh12
 
Ch12 OS
Ch12 OSCh12 OS
Ch12 OS
 
OS_Ch12
OS_Ch12OS_Ch12
OS_Ch12
 
Ch10
Ch10Ch10
Ch10
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 
File system interface
File system interfaceFile system interface
File system interface
 
CH11.pdf
CH11.pdfCH11.pdf
CH11.pdf
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Ch11
Ch11Ch11
Ch11
 
File system interfacefinal
File system interfacefinalFile system interfacefinal
File system interfacefinal
 
Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems Unix file systems 2 in unix internal systems
Unix file systems 2 in unix internal systems
 
DFSNov1.pptx
DFSNov1.pptxDFSNov1.pptx
DFSNov1.pptx
 
File concept and access method
File concept and access methodFile concept and access method
File concept and access method
 

Plus de Mohd Arif

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcpMohd Arif
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarpMohd Arif
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocolMohd Arif
 
Project identification
Project identificationProject identification
Project identificationMohd Arif
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniquesMohd Arif
 
Presentation
PresentationPresentation
PresentationMohd Arif
 
Pointers in c
Pointers in cPointers in c
Pointers in cMohd Arif
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peerMohd Arif
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systemsMohd Arif
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdpMohd Arif
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgetingMohd Arif
 
Network management
Network managementNetwork management
Network managementMohd Arif
 
Networing basics
Networing basicsNetworing basics
Networing basicsMohd Arif
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformMohd Arif
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and sslMohd Arif
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psecMohd Arif
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardwareMohd Arif
 

Plus de Mohd Arif (20)

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
 
Project identification
Project identificationProject identification
Project identification
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
 
Presentation
PresentationPresentation
Presentation
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
 
Network management
Network managementNetwork management
Network management
 
Networing basics
Networing basicsNetworing basics
Networing basics
 
Loaders
LoadersLoaders
Loaders
 
Lists
ListsLists
Lists
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
 
Heap sort
Heap sortHeap sort
Heap sort
 

Dernier

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 

Dernier (20)

APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 

File management

  • 1. File Management (Continued) COMP 229 (Section PP) Week 10 Prof. Richard Zanibbi Concordia University March 20, 2006
  • 2. Last Week...File Management File System Types (pp. 514-528) Low-Level File System (for Byte Stream Files) Structured File System (e.g. for records, .mp3 files) Low-Level File System Implementations (pp. 529-544) Low-level file system architecture Byte stream file Open and Close operations Block Management (in part) 2
  • 3. Files and the File Manager Files As Resource Abstraction Files are used to represent data on storage devices (e.g. disk) Files As a Central Abstraction of Computation – Most programs read one or more files, and eventually write results to one or more files – Some view programs as filters that read data, transform the data, and write the result to a new file (is this an “extreme view”?) • e.g. UNIX shell applications using the pipe operator ( | ) – In C: by default, stdin, stdout, stderr are defined File Manager (OS Service Responsible for Files) – Implements file abstraction (including APIs for file types) – Implements directory structure for organizing files – Implements file systems for organizing collections of directories (e.g. on separate disks) – File management involves operations on external devices & memory 3
  • 4. File Descriptors, Revisited Field Purpose External Name A string identifier Sharable Can processes share the file? For read/write/execution?... Owner User who created the file Protection Settings Which users can read/write/execute the file Length Number of bytes in file Time of Creation When file was created Time of Last Modific. Date when file was last written to Time of Last Access Date when file was last used Reference Count # directories in which file appears Storage Device Details File block organization (on device) 4
  • 5. File System Types External View of File Manager Part of the System Call Interface implemented by the file manager (see Fig. 13.2) Low vs. High-Level (Structured) File Systems See Fig. 13.3 – Low Level File System implements only Stream-Block Translation and Byte-Stream Files (e.g. WIndows, Unix) • Applications must translate byte streams to/from abstract data types used in programs – Structured (High-Level) File Systems also implement Record-Stream translation and Structured Record files (e.g. MacOS, systems for commercial applications, e.g. some IBM systems) • Have a language for defining record types, keys for searches Marshalling: producing blocks from records (“flattening”) Unmarshalling: producing records from blocks See Fig. 3.16 (marshalling a record into a byte stream) 5
  • 6. Structured File Types (Record-Oriented) Structured Sequential Files Records organized as a list Record attributes encoded in file Header Indexed Sequential Files – Records have an integer index in their header – Records contain one or more fields used to index records in the file (e.g. student #) – Applications of File Manager define tables associating record attributes with index values – Representation: just index values in records, linked lists (one per key), or stored index table (used by file manager) – Popular in business, human resources applications Inverted Files – Generalized external (system) index tables used by file manager: allow entries to point to groups of records or fields – New record fields are extracted and placed in the index table, with pointer in the table to the new record where appropriate – Records accessed using the index table rather than location in file 6
  • 7. struct message { Abstract Data Type address to; (for email messages) address from; line subject; address cc; string body; } Retrieves next record struct message *getRecord(void) { struct message *msg; msg = allocate(sizeof(message)); msg->to = getAddress(...); msg->from = getAddress(...); •Programmer-defined abstract data msg->cc = getAddress(...); types msg->subject = getLine(); •Programmer-defined record msg->body = getString(); read/write methods (e.g. using return(msg); standard, predefined access function } names) •File Manager invokes programmer putRecord(struct message *msg) { routines putAddress(msg->to); Appends record to file putAddress(msg->from); putAddress(msg->cc); putAddress(msg->subject); putString(msg->body); Example: (“Record-Oriented”) Structured } Sequential File for an “Inbox” 7
  • 8. Opening Files Fig. 13.10 – Opening a file – Note difference between internal and external file descriptor – Also, note that an additional process-specific data structure is needed (Process-File Session) Fig. 13.11 – Opening a Unix file – Note that Process-File Session is represented using two Data Structures (Open File Table, File Structure Table) 8
  • 9. Closing a File When Issued: All pending operations completed (reads, writes) Releases I/O buffers Release locks a process holds on a file Update external file descriptor Deallocate file status table entry 9
  • 10. This week...File Management (Cont’d) File Management (pp. 534-558) Block Management, Continued Reading/Writing Byte Streams Supporting High-Level File Abstractions Directories (Structures, Implementations) File Systems 10
  • 11. Block Management, and Reading and Writing Byte Streams
  • 12. Block Management Purpose Organizing the blocks in secondary storage (e.g. disk) that hold file data (blocks containing file data are referenced from the “Storage Device Detail” field in a file descriptor; see p.530) Computing number of blocks for a file See page 534 in text Block Management Strategies: 1. Contiguous allocation 2. Linked lists 3. Indexed allocation 12
  • 13. Examples of Block Management Contiguous Allocation See Fig. 13.12 All blocks are adjacent (contiguous) on storage device: fast write/read Problems with external fragmentation (space between files) • must be space for the whole file when file is expanded; if not, the whole file must be relocated to another part of storage (e.g. the disk) NOTE: “Head Position” is the location of the file pointer (current byte) Linked Lists (Single and Doubly-Linked) See Figs. 13.13 and 13.14 Blocks have fields defining the number of bytes in a block and link(s) to the next (also previous, if doubly-linked) block in the file Blocks do not have to be contiguous, allowing us to avoid the fragmentation problems with contiguous allocation Indexed Allocation See Fig. 13.15 Size/link headers for blocks separated from the blocks and placed in an index Index is stored with the file, and loaded into memory when a file is opened Speeds searching, as all blocks are stored within the index table (no link following to locate blocks in the file)= 13
  • 14. Contiguous Allocation Strategies Best Fit Find smallest free area large enough for the file First Fit – Use first unallocated block sequence large enough for the file – Found using linear search Worst Fit – Use largest available contiguous space – Divide space in 2, one part for the file, the rest for free space 14
  • 15. Block Representation in Unix File Descriptors UNIX File Descriptors See Table 13.1 UNIX File Block Representation See Fig. 13.16 – 12 direct links to data blocks – 3 index block references, which are singly, doubly, and triply indirect, respectively Block Types: Data or Index Index Block: list of other data or index blocks The Unix block representation can represent more locations than most machines can store (example numbers given in text) 15
  • 16. UNIX File Descriptors (inode) Field Purpose Mode Access permissions UID ID for user that created the file Group ID ID identifying group of users with access to the file Length in bytes Number of bytes in file Length in blocks Number of blocks implementing file Time of Last Modific. Time when file was last written to Time of Last Access Time when file was last read Time of Last inode mod. Time when inode was last changed Reference Count # directories in which file appears Block references Pointers, indirect pointers to file block 16
  • 17. DOS File Allocation Tables (FAT) Represents Linked List Allocation Each location in the table is a logical block address Content of each table cell is a pointer to the next block in a file, or an “end of file” marker “Modern” FAT Alteration Table locations point to clusters (a group of contiguous blocks) rather than individual blocks 17
  • 18. Unallocated Blocks “Free List” representation A linked list of unallocated blocks Very large, particularly if disk is mostly empty Hard to efficiently manage so that adjacent free blocks can be easily found Block Status Map Represents every block on a disk using one bit If bit is on, block is used (‘0’ if free) Can be kept in memory; much faster to find adjacent free blocks vs. a free list Useful for checking file system contents • e.g. comparing blocks that files on a disk reference vs. those that are indicated as used in the Block Status Map, as part of disk recovery 18
  • 19. Packing/Unpacking Blocks Reading/Writing – File system reads/writes one block of data at a time – Blocks of data are copied into or out of the byte stream for the file – On file open, first block is copied into memory (as byte stream), and file pointer located at the start of the first block. – Processes operate on the copy of the data that is in memory (the byte stream) – Write operations pack (marshall) bytes into copies of device storage blocks into memory. When blocks become full, the write operation will transfer the blocks to the device – Note that when we open for writing, the block is still read in, and overwritten. When the program finishes writing out a block, the write operation will arrange for the data to be written to disk 19
  • 20. Packing/Unpacking Continued Location of a Byte on Disk Assuming we have fixed-sized blocks (of size k), then we can compute the block containing a byte using N = i/k , where N is the block number See Fig. 13.18 – Inserting/Deleting bytes in the interior of a byte-stream file – Leads to internal fragmentation (unused block bytes) Buffering (see page 544) To improve performance, file manager tries to read ahead blocks in a file (into a “buffer”), and “write behind” the blocks that have been filled in the buffer used to store bytes in the file 20
  • 22. Structured Sequential Files Implementation Logically same as for byte stream file manager – record rather than byte-based – insertion: similar issues per bytes in low-level files Additional File Descriptor Fields: File type (e.g. relocatable object file, postscript) Access methods (abstract data type function.) • May be fixed (e.g. OS-provided) • May be programmer-defined (e.g. email example) Other: relationships with other files, minimum version number of file manager handling file type, etc. 22
  • 23. Indexed Sequential Files Index Field Normally indicates order of records (from 0) Implementation – File manager manages mapping from records to blocks (I/O requests are record index-based) – Inserting records causes complications (e.g. fragmentation issues) – Optional index table – Buffers unlikely to be very helpful for many usage scenarios (e.g. servicing bank customers) 23
  • 24. Database Management Systems Storage Manager Replaces file manager Low-level interface, allow direct manipulation of storage devices Database Administrator Chooses organization or records across and within files Common Database Types Relational: concerned with efficient searches on relationships Object-Oriented: application defines access methods *Conventional file system interfaces do not support these *Note Usually data stored in a database cannot be accessed by the “normal” file interfaces of the File Manager 24
  • 25. Multimedia Documents Storage Demands Similar to databases (OO databases often support multimedia files) Performance Issues – Block allocation affects streaming/bandwidth – File Manager: normally assume that applications will not request multiple blocks simultaneously – *No widely-used OS’s currently provide high performance support for multimedia files 25
  • 27. File Directories File Directory A set of files and other (sub)directories Principle function: help people find their way around data on a system Implementation Directories are stored as additional files 27
  • 28. Operations for Directory Management (key parameter: file/directory name) Enumerate List contents of a directory (files, subdirectories) • e.g. using ‘ls’ in Unix, ‘dir’ in Windows Copy Make a copy of a file (e.g. within the directory) Rename Change file name Delete Remove file from current directory; release file descriptor and all blocks in the file Traverse Change current directory by indicating new directory to go to – e.g. ‘cd’ in Unix, Windows 28
  • 29. Motivation for Structuring Directories (e.g. organizing lecture notes) Small Number of Files (e.g. 5 lectures) – Small enough to easily sort through ‘Medium’ Number of Files (e.g. 50 lectures) – Now probably easier to manage if we organize by course, for example (one group of subdirectories) Large Number of Files (e.g. database, Millions) – Becomes impractical to manage manually: start employing additional subdirectories – Perhaps even patterns of subdirectories • all courses also have subdirectories for each year • each year has subdirectories for each term, etc. 29
  • 30. (Pure) Hierarchical File Organization in the “Real” World File Paper Document (e.g.) Folder Group of Files, with an additional document summarizing the files in the folder (the directory) “Super” Folder Contains a group of folders and files, with an additional directory summarizing the folder contents File Drawer... File Cabinet... Filing Room... Filing Building... Filing Complex... 30 Filing Nation (?....)
  • 31. Directory Structures ...refers to how directories are organized and related in a system Root Directory Initial node in a hierarchical file system – e.g. “/” in Unix Directory Tree Most common directory structure: purely hierarchical organization (creating a tree) File/Directory Sharing – Example: two or more users wish to refer to the same file from within their own home directories – Reference count in file descriptors used to prevent a shared file from being deleted when still being used – Tree becomes a directed (and hopefully acyclic) graph 31
  • 32. Directory Structures See Fig. 13.19 Note that a “Strict Hierarchy” is often called a “directory tree” 32
  • 33. Absolute and Relative Paths Absolute Path Path from the root directory to the desired directory/file • e.g. “/home/zanibbi/comp229/slides.ppt” • e.g. “D:myfileszanibbicomp229slides.ppt” Relative Path Path from (“relative to”) a given directory • (usually current) • e.g. : “comp229/slides.ppt” (from /home/zanibbi) • e.g. : “comp229slides.ppt” (from D:myfileszanibbi) 33
  • 34. Example: DOS File Directory “This Machine” (usually implicit root directory of file system) A: B: C: D: (Disk Drive D) ... ... ... USER GJN PROGRAMS BIN AUTOEXEC.BAT PRIME.C PATCH 34
  • 35. Example: Unix File Directories Directed Acyclic Graphs Root Directory: “/” (e.g. “cd /”) / home etc lib bin zanibbi jones comp229 slides.ppt 35
  • 36. Implementing Directories Directory (as File) Set of structured records (files/directories) Directory Entries (Records) Each record refers to an external file descriptor, provides information for locating the external file descriptor • Linux: Filename, disk address for external file descriptor • MS-DOS: Filename, extension (type), creation time, file size, address of first file block 36
  • 37. Implementing Directories, Cont’d Directory Operations Operate on directory (record) entries If file attributes stored on disk, must be retrieved (e.g. Linux) Long File Names Old days: Usually 8 character length names (max) ~1990: “long” file names appear • MS-DOS: extra characters stored in additional directory entry • Unix: Create a heap in each directory, used for extra characters when needed Directories On Disk Directory file has a file descriptor, indicating blocks where directory data is located on disk. 37
  • 38. Opening Files, Searching Paths Path Representation – Directories, directory entries organize files on disk – To locate a file, directory entries must be used Path Searching Recursive, from the initial directory (root directory for absolute paths) • e.g. /usr/gjn/books/opsys/chap13 – 5 directories • e.g. books/opsys/chap13 (from /usr/gjn) – 3 directories (must read current directory (“gjn”) to start) Caching Directory Information To speed up searches, some file managers store directory data in memory 38
  • 40. File Systems Disk Partitioning For organization and performance, disks are often partitioned to act as two or more separate disks Removable Storage Floppy disks, Zip disks, CD-ROMS, etc. – must combine directories for use by system File System – Hierarchical file collection associated with a removable or permanent storage medium – Single root directory – Describes set of files on a removable storage medium Volume The contents of a file system 40
  • 41. Example: ISO 9660 File System (see Figs. 13.21-13.23) Creation of Standard Derived from “High Sierra” specification created by industry experts in 1986 Features – Focus: reading files (CD’s originally non-writable): simplifies block allocation – CDs store data in a single helical track – Sectors (blocks) are 2048 bytes – Each file/directory is stored in a contiguous set of sectors (contains file descriptor and file) 41
  • 42. Mounting File Systems System Boot Disk – Logical device (e.g. disk partition) from which the master boot record is loaded – Also the device that will contain the root directory for the system Other Disks/Storage Must be “grafted” onto the base directory structure This “grafting” is often called “mounting” (from Unix) 42
  • 43. Mounting File Systems, Cont’d mount() – See Fig. 13.24 – Unix system call requesting a removable device be added to the file hierarchy – Root directory of the mounted system will be treated as a subdirectory in the base hierarchy – Mounted files can be used as though part of the file system on the system boot disk • e.g. “mount /dev/cdrom”, “cd /media/cdrom” umount() “Unmounts” a device from the base hierarchy • e.g. before removing a cd-rom 43
  • 44. Heterogeneous File Systems Definition A file system comprised of files systems of different types (e.g. ISO9660, ext3, FAT32) Virtual File System (Linux – See Fig. 13.25) – File manager has file system dependent and independent parts – File System Dependent: reads/writes data – File System Independent: implements general file manager algorithms (e.g. traversal, delete, copy, etc.) – File Manager defines its own internal file descriptor (need to translate those from different file systems), in Linux, based on inodes (Unix) 44
  • 45. Next Week... Device Management pp. 152-174 Compilers (back to Part I of text) pp. 225-242 Basic Compiler Functions Lexical Analysis using Finite State Automata 45