1 / 40

Operating Systems Files, Directory and File Systems

Operating Systems Files, Directory and File Systems. Topics. Files and Directories File-System Structure Allocation Methods Free-Space Management Directory Implementation Efficiency and Performance Recovery. File Structure. None - sequence of words, bytes Simple record structure

edwardbryan
Download Presentation

Operating Systems Files, Directory and File Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating Systems Files, Directory and File Systems

  2. Topics • Files and Directories • File-System Structure • Allocation Methods • Free-Space Management • Directory Implementation • Efficiency and Performance • Recovery

  3. File Structure • None - sequence of words, bytes • Simple record structure • Complex Structures • Can simulate last two with first method by inserting appropriate control characters • Responsible by • Operating system • Program

  4. File Attributes • Name • Type • Location • Size • Protection • Time, date, and user identification • Information about files are kept in the directory structure.

  5. File Operations • Create • Write • Read • Reposition within file - file seek • Delete • Truncate • Open(Fi)-search the directory structure on disk for entry Fi, and move the content of entry to memory. • Close(Fi)-move the content of entry Fi in memory to directory structure on disk.

  6. File Types • Executable • Object • Source Code • Batch • Text • Word processor • Library • Print or view • Archive

  7. Access Methods • Sequential Access read next write next reset no read after last write (rewrite)

  8. Access Methods (continued) • Direct Access read n write n position to n read next write next rewrite n n=relative block number

  9. 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.

  10. Information in a Directory • Name • Type • Address • Current Length • Maximum Length • Date last accessed (for archival) • Date last update (for dump) • Owner ID (who pays) • Protection information (discuss later)

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

  12. Organization of the Directory • Efficiency • Naming • Grouping

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

  14. Two-Level Directory • Separate directory for each user • Path name • No naming problem • Efficient searching • No grouping capability

  15. Tree-Structured Directories • Efficient searching • Grouping capability • Current directory • cd /spell/mail/prog • cat list

  16. Tree-Structured Directories (continued) • Absolute or relative path name • Creating a new file is done in current directory. • Delete a file • Creating a new subdirectory is done in current directory. • Deleting a directory

  17. Acyclic-Graph Directories • Two different names (aliasing) • If dict deletes list dangling pointer. Solutions: • Backpointers, so we can delete all pointers. Variable size records a problem. • Backpointers using a daisy chain organization. • Entry-hold-count solution.,

  18. General Graph Directory • 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 detection algorithm to determine whether it is OK.

  19. Protection • File owner/creator should be able to control • what can be done • by whom • Types of access • Read • Write • Execute • Append • Delete • List

  20. Access Lists and Groups -NFS • Mode of access: read, write, execute • Three classes of users RWX a) owner access 7 1 1 1 RWX b) groups 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 that group.

  21. Access Lists and Groups (continued) • For a particular file (say game) or subdirectory, define an appropriate access. • Attach a group to that file chgrp G game owner group public chmod 761 game

  22. File-System Structure • File structure • File system resides on secondary storage • File system organized into layers. • File control block - storage structure consisting of information about a file.

  23. Contiguous Allocation • Each file occupies a set of contiguous blocks on the disk. • Simple-only starting location (block #) and length (number of blocks) are required. • Random Access. • Wasteful of space (dynamic storage-allocation problem).

  24. Contiguous Allocation (continued) • Files cannot grow • Mapping from logical to physical. Starting address and displacement.

  25. Linked Allocation • Each file is a linked list of disk blocks; blocks may be scattered anywhere on the disk. Block = pointer

  26. Linked Allocation • Simple - need only starting address • Free-space management system - no waste of space • No random access • Mapping • File-allocation table (FAT) - disk-space allocation used by MS-DOS and OS/2.

  27. Indexed Allocation • Brings all pointers together into the index block. • Logical view

  28. Indexed Allocation (continued) • Need index table • Random access • Dynamic access without external fragmentation, but have overhead of index block. • Mapping from logical to physical in a file of maximum size of 256K words and block size of 512 words. We need only 1 block for index table • Q • R

  29. Indexed Allocation- Mapping (continued) • Mapping from logical to physical in a file of unbounded length (block size of 512 words). • Linked scheme - Link blocks of index tables (no limit on size). LA / (512 x 511) Q1 R1

  30. Indexed Allocation - Mapping (continued) • Q1 = block of index table • R1 is used as follows: R1 / 512 • Q2 = displacement into block of index table. • R2 = displacement into block of file. Q2 R2

  31. Indexed Allocation - Mapping (continued) • Two-level index (maximum file size is 5123) LA / (512 x 512) • Q1 = displacement into outer-index • R1 is used as follows: R1 / 512 Q1 R1 Q2 R2

  32. Indexed Allocation - Mapping (continued) • Q2 = displacement into block of index table • R2 = displacement into block of file

  33. Indexed Allocation - Mapping (continued) outer- index file index table

  34. Combined Scheme: UNIX (4K bytes per block) Mode owners (2) timestamps (3) size block count direct blocks single indirect double indirect triple indirect data data data . . . data . . . . . . . . . data data . . . data . . . data data data

  35. Free-Space Management • Bit vector (n blocks) bit[ i ] = 0 1 n-1 2 ... 0 block [ i ] free 1 block [ i ] occupied

  36. Free-Space Management (continued) • Block number calculation (number of bits per word) * (number of 0-value words) + offset of first 1 bit • Bit map requires extra space. Example block size = 212 bytes disk size = 230 bytes ( 1 gigabyte) n = 230/212=218 (or 32K bytes)

  37. Free-Space Management (continued) • Easy to get contiguous files • Linked list (free list) • Cannot get contiguous space easily • No waste of space • Grouping • Counting

  38. Free-Space Management (continued) • Need to protect • Pointer to free list • Bit map • Must be kept on disk • Copy in memory and disk may differ • Cannot allow for block [ i ] to have a situation where bit [ i ] = 1 in memory and bit [ i ] = 0 on disk.

  39. Free-Space Management (continued) • Solution • Set bit [ i ] = 1 in disk. • Allocate block [ i ]. • Set bit [ i ] = 1 in memory.

  40. Directory Implementation • Linear list of file names with pointers to the data blocks • Hash Table - linear list with hash data structure.

More Related