1 / 28

CHAPTER 10: FILE-SYSTEM INTERFACE

CHAPTER 10: FILE-SYSTEM INTERFACE. The file system consists of two distinct parts : a collection of files , each storing related data, and a directory structure , which organizes and provides information about all the files in the system. File Concept Access Methods

elan
Download Presentation

CHAPTER 10: FILE-SYSTEM INTERFACE

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. CHAPTER 10: FILE-SYSTEM INTERFACE The file system consists of two distinct parts: a collection of files, each storing related data, and a directory structure, which organizes and provides information about all the files in the system. • File Concept • Access Methods • Directory Structure

  2. FILE CONCEPT • Introduction • File attributes • File operations • File types • File structure • Internal file structure

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

  4. File Concept • A file has a certain defined structure, which depends on its type. • A text file is a sequence of characters organized into lines or pages. • A source file is a sequence of subroutines and function. • An object file is a sequence of bytes organized into blocks. • An executable file is a series of code sections that the loader can bring into memory and execute.

  5. File Concept: Attributes • Name: The symbolic file name in human-readable form. • Identifier: This unique tag, usually a number, identifies the file within the file system; non-human-readable form. • Type: This information is needed for system to support different types. • Location: A pointer to a device and to the location of file on device. • Size: The current size of the file (in bytes, words, or blocks). • Protection: Access-control information determines who can do reading, writing, executing, and so on. • Time, date, and user identification: This information may be kept for creation, last modification, and last use. Typically, the directory entry consists of the file’s name and its unique identifier. The identifier in turn locates the other file attributes. It may take more than a kilobyte to record this information for each file.

  6. File concept: Operations • Create: To allocate file space and make directory entry • Write: To write a file, we make a system call specifying both the name of file and information to be written to. • Read: To read from a file, we use a system call that specifies the name of file and where (in memory) the next block of the file should be put. • Reposition within a file: reposition the current operation location of specified file. • Delete: To find the directory entry, release all file space and erase the directory entry. • Truncate: To erase the contents of a file but keep its attributes.

  7. File concept: Operations • 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 remove the directory entry in the open-file table and free the file descriptor • Open-file Table • Per-process table: track all files that a process has open. • System-wide table: each entry in per-process table in turn points to a system-wide open-file table. • Several pieces of information are associated with an open file • File pointer • File-open count • Disk location of the file • Access rights

  8. 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) • 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. • Apple Macintosh OS: Each file has a type and also has a creator attribute containing the name of the program that created it. • UNIX uses a crude magic number to indicate roughly the type of file. And not all files have magic numbers.

  9. File concept: Types

  10. File concept: Structure • File types also can be used to indicate the internal structure of the file. • Certain files must conform to a required structure that is understood by OS. • Some OS support a minimal number of file structures. Each application program must include its own code to interpret an input file as to the appropriate structure. • All OS must support at least one structure, executable file, so that the system is able to load and run programs.

  11. File concept: Internal File Structure • Disk systems typically have a well-defined block size determined by the size of sector. • All disk I/O is performed in units of one block. • It is unlikely that the physical record size will exactly match the length of block, so use the packing. • The file is considered to be a sequence of blocks. All the basic I/O functions operate in terms of blocks. • Disk space is always allocated in blocks, some portion of the last block of each file is generally wasted ——internal fragmentation.

  12. Access Methods • When file is used, its stored information must be accessed and read into computer memory. • Some systems provide only one access method for files. • Other systems support many access methods, and choose the right one for a particular application.

  13. File access: Sequential access Sequential access is the simplest access method. Information in the file is processed in order, one record after the other. Sequential access operations: Read next, Write next and Reset

  14. File access: Direct access For direct access, the file is viewed as a numbered sequence of blocks or records. There are no restrictions on the order of reading or writing for a direct-access file. Direct access operations: Read n, Write n Simulation of sequential access on a direct-access file by keeping a variable of current position, cp.

  15. File access: Other access • Index file: we first search the index, and then use the pointer to access the desired record directly. (page 887 in text book) • Index file itself may become too large: create an index for the index file • Primary index file  secondary index file  file data • Example (next slide)

  16. File access: Other access

  17. Directory Structure • Disks  partitions/slices/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 for a file • Create a file • Delete a file • List a directory • Rename a file • Traverse the file system

  18. Directory structure A Typical File-system Organization

  19. Directory structures Most common schemes for defining logical structure of a directory. • Single-level directory • Two-level directory • Tree-structured directory • Acyclic graph directory • General graph directory

  20. Directory structure: Single-Level Directory • A single directory for containing all files for all users. • Naming problem: unique name and limited name length. • Remembering problem: difficult to remember the names of all files as the number of files increases.

  21. 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: search specified user’s UFD • User isolation: advantage for user independence and disadvantage for user cooperation

  22. Directory structure: Tree-Structured Directories

  23. Directory structure: Tree-Structured Directories • Most common directory structure • The tree has a root directory, and every file in the system has a unique path name. • A directory contains a set of files and subdirectories. • Current directory (working directory) • cd change current directory • Absolute or relative path name • Creating a new file is done in current directory • Delete a file e.g. rm <file-name> • Creating a new subdirectory is done in current directory. e.g. mkdir <dir-name>

  24. Directory structure: Acyclic-graph directories

  25. Directory structure: Acyclic-graph directories • A common used subdirectory can be shared. • Tree-structured directory + sharing  Acyclic-Graph Directories • Linux ln: • hard link: target file has many aliases • soft link: a file linked to the target file • Potential problems • To traverse the entire FS: we do not want to traverse shared structures more than once. • To delete a file (for symbolic link and hard link)

  26. Directory structure: General graph directory

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

  28. That’s all for our OS! • Thanks!

More Related