Download presentation
Presentation is loading. Please wait.
Published byBarnaby Fisher Modified over 9 years ago
1
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 10: File System
2
10.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10: File System File Concept Access Methods Directory Structure File Sharing Protection
3
10.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Objectives To explain the function of file systems To describe the interfaces to file systems To discuss file-system design tradeoffs, including access methods, file sharing, file locking, and directory structures To explore file-system protection
4
10.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System A file system (often also written as filesystem) is a method of storing and organizing computer files and their data. Essentially, it organizes these files into a database for the storage, organization, manipulation, and retrieval by the computer's operating system. File systems are used on data storage devices such as hard disks or CD- ROMs to maintain the physical location of the files
5
10.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Concept Computers can store information on various storage media, such as magnetic disks, magnetic tapes, and optical disks. So that the computer system will be convenient to use, the operation system provides a uniform logical view of information storage. OS abstracts from the physical properties of its storage device to define a logical storage unit, called File. Files are mapped by the OS onto physical devices. These storage devices are usually nonvolatile. A file is a named collection of related information that is recorded on secondary storage, so a file is the smallest allotment of logical secondary storage; that is, data cannot be written to secondary storage unless they are within a file. In general, a file is a sequence of bits, bytes, lines, or records, the meaning of which is defined by the file’s creator and user.
6
10.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Concept (cont.) Data files may be: Numeric, alphabetic, alphanumeric or binary Text file is a sequence of characters organized into lines. Source file is a sequence of subroutines and executable statements. Object file is a sequence of bytes organized into blocks understandable by the system’s linker. Executable file is a series of code sections that the loader can bring into memory and execute.
7
10.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Attributes A file’s attributes vary from one operating system to another but typically consist of these:- Name – symbolic file name, the only information kept in human-readable form. Many OS support two part file names (name.extension) – File.bak (backup file); file.pdf (pdf file); file jpg (still picture in JPEG format) – Some OS do not enforce extensions (e.g., UNIX), so do (e.g., Windows, MAC OS) Identifier – unique tag (number) identifies file within file system Type – needed for systems that support different types Location – pointer to file location on device Size – current file size Protection – controls who can do reading, writing, executing Time, date, and user identification – data for protection, security, and usage monitoring The Information about files are kept in the directory structure, which is maintained on the disk.
8
10.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Operations Create : Two steps are necessary to create a file. First, space in the file system must be found for the file. Second, and entry for the new file must be made in the directory. Write: To write a file, the system call specifying both the name of the file and the information to be written to the file. Read: the system calls specifies the name of the file and where in memory the next block of the file should be put. Reposition within file: The directory is searched for the appropriate entry, and the current-file-position pointer is repositioned to a given value. Delete: To delete a file, we search the directory for the named file, and release all file space. Truncate: The user may want to erase the contents of a file but keeping its attributes. Rather than forcing the user to delete the file and then recreate it, this function allows all attributes to remain unchanged except for file length, but lets the file be reset to length zero and its file space released. To define a file properly, we need to consider the operations that can be performed on files. The operating system can provide system calls to create, write, read, reposition, delete, and truncate files.
9
10.9 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Types – Name, Extension
10
10.10 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Structure A source and objects files have structures that match the expectations of the programs that read them. Further, certain files must conform to a required structure that is understood by the operating system. For example, the operating system requires that an executable file have a specifying structure so that it can determine where in memory to load the file and what the location of the first instruction is. None - sequence of words, bytes Simple record structure Lines, Fixed length, Variable length Complex Structures Formatted document Relocatable load file Can simulate last two with first method by inserting appropriate control characters Who decides: Operating system Program
11
10.11 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Access Methods Sequential Access read next write next no read after last write (rewrite) Direct Access read n write n rewrite n n = relative block number
12
10.12 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Sequential-access File The simplest access method. Information in the file is processed in order, one record after the other. This mode of access is by far the most common; for example, editors and compilers usually access files in this fashion. Reads and writes make up the bulk of the operations on a file. A read operation: - read next()- reads the next portion of the file and automatically advances a file pointer. A write operation – write next()- appends to the end of the file and advances to the end of the newly written material.
13
10.13 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Direct-access File A file is made up of fixed length that allow programs to read and write records rapidly in no particular order. This method is based on a disk model of a file, since disks allow random access to any file block. The file is viewed as a numbered sequence of blocks or records. Thus we may read block 14, then read block 53, and then write block 7. there are no restrictions on the order of reading or writing for a direct-access file. It is a great of use for immediate access to large amount of information “ Databases”. The file operations must be modified to include the block number as a parameter. Thus, we have read n, where n is the block number rather than read next, and write n rather than write next.
14
10.14 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Directory Structure Some systems store millions of files on terabytes of disk, to manage all these data, we need to organize them. This organization involves the use of directories. A collection of nodes containing information about all files F 1 F 2 F 3 F 4 F n Directory Files Both the directory structure and the files reside on disk Backups of these two structures are kept on tapes
15
10.15 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Disk Structure Disk can be subdivided into partitions Disks or partitions can be RAID protected against failure Disk or partition can be used raw – without a file system, or formatted with a file system Partitions also known as minidisks, slices Entity containing file system known as a volume Each volume containing file system also tracks that file system’s info in device directory or volume table of contents As well as general-purpose file systems there are many special-purpose file systems, frequently all within the same operating system or computer Redundant Array of Independent Disks (RAID) is a technology that provides increased storage functions and reliability through redundancy, combining multiple disk drives components into a logical unit where all drives in the array are interdependent.
16
10.16 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition A Typical File-system Organization
17
10.17 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Operations Performed on Directory Search for a file Create a file Delete a file List a directory Rename a file Traverse the file system
18
10.18 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Logical directory structure schemes The most common schemes for defining the logical structure of a directory: Single-Level Directory Two-Level Directory Tree-Structured Directories Acyclic-Graph Directories General Graph Directory
19
10.19 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Single-Level Directory The simplest directory structure is the single-level directory. All files are contained in the same directory, which is easy to support and understand. A single-level directory has significant limitations, however, when the number of files increases or when the system has more than one user. Since all files are in the same directory, they must have unique names. -Confusion of file names among different users. The standard solution is to create a separate directory for each user. -All files are contained in the same directory. -Easy to support and understand.
20
10.20 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Two-Level Directory Separate directory for each user, each user has his own user file directory One master file directory. Each user has their own user file directory. Each entry in the master file directory points to a user file directory. Sharing-accessing other users files. Grouping problem.
21
10.21 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Tree-Structured Directories -The tree has a root directory and every file in the system has a unique path name. - A directory contains a set of files or subdirectories. -The directory structure is a tree with arbitrary height. -Users may create their own subdirectories. -Efficient searching, grouping.
22
10.22 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Acyclic-Graph Directories n Consider two programmers who are working on a joint project. The files associated with that project can be stored in a subdirectories, separating them from other projects and files of the two programmers. But since both programmers are equally responsible for the project, both want the subdirectory to be in their own directories. The common subdirectory should be shared. A shared directory of file will exist in the file system in two places at once. A tree structure prohibits the sharing of files or directories. n Allow sharing of directories and files several times on the tree structure. n Only once actual copy of the file or directory is stored. n Can be accessed through one or more paths. n May have different names.
23
10.23 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition - A problem with an acyclic graphs: how to ensure that there are no cycles. - A second problem exist when we are trying to determine when a file can be deleted. With acyclic-graph directory structures, a value of 0 in the reference count means that there are no more references to the file or directory, and the file can be deleted. However, when cycles exist, the reference count may not be zero even when it is no longer possible to refer to a directory of file. -If we start with a directory and allow users to create subdirectories, a tree-structured directory results. It should be fairly easy to see that simply adding new files and subdirectories to an existing tree-structured directory preserves the tree- structure nature. However, when we add links to an existing tree-structured directory, the tree structure is destroyed, resulting in a simple graph structure. -The primary advantage of an acyclic graph is the relative simplicity of the algorithms to traverse the graph and to determine when there are no more references to a file. General Graph Directory
24
10.24 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition General Graph Directory (cont.)
25
10.25 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition General Graph Directory (Cont.) 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
26
10.26 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing File sharing is the practice of distributing or providing access to digitally stored information, such as computer programs, multi-media (audio, video), documents, or electronic books. It may be implemented through a variety of ways. Storage, transmission, and distribution models are common methods of file sharing incorporate manual sharing using removable media, centralized computer file server installations on computer networks, World Wide Web-based hyperlinked documents, and the use of distributed peer- to-peer networking. Difficulties involved in allowing users to share files. Such file sharing is very desirable for users who want to collaborate and to reduce the effort required to achieve a computing goal.
27
10.27 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing (cont.) Sharing of files on multi-user systems is desirable Sharing may be done through a protection scheme On distributed systems, files may be shared across a network Network File System (NFS) is a common distributed file-sharing method
28
10.28 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing – Multiple Users The owner and group IDs of a given file are stored with the other file attributes. When a user requests an operation on a file, the user ID can be compared with the owner attribute to determine if the requesting user is the owner of the file. Likewise, the group IDs can be compared. The result indicates which permissions are applicable. The system then applies those permissions to the requested operation and allows or denies it. User IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights
29
10.29 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing – Remote File Systems Uses networking to allow file system access between systems Manually via programs like FTP Automatically, seamlessly using distributed file systems Semi automatically via the world wide web Client-server model allows clients to mount remote file systems from servers Server can serve multiple clients Client and user-on-client identification is insecure or complicated NFS is standard UNIX client-server file sharing protocol CIFS is standard Windows protocol Standard operating system file calls are translated into remote calls Distributed Information Systems (distributed naming services) such as LDAP, DNS, NIS, Active Directory implement unified access to information needed for remote computing
30
10.30 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing – Failure Modes Local file systems can fail for a variety of reasons. Such as, disk- controller failure, cable failure, and host-adapter failure. Users or system-administrator failure can also cause files to be lost or entire directories to be deleted. Remote file systems add new failure modes, due to network failure, server failure Recovery from failure can involve state information about status of each remote request Stateless protocols such as NFS include all information in each request, allowing easy recovery but less security
31
10.31 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Sharing – Consistency Semantics Consistency semantics specify how multiple users are to access a shared file simultaneously In particular, they specify when modifications of data by one user will be observable by other users. These semantics are typically implemented as code with the file system. Similar to Ch 7 process synchronization algorithms – Tend to be less complex due to disk I/O and network latency (for remote file systems Andrew File System (AFS) implemented complex remote file sharing semantics AFS has session semantics – Writes only visible to sessions starting after the file is closed
32
10.32 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File owner/creator should be able to control: - what can be done - by whom Types of access - Read: Read from the file. – Write: Write or rewrite the file. – Execute: Load the file into memory and execute it. – Append: Write new information at the end of the file. – Delete: Delete the file and free its space for possible reuse. – List: List the name and attributes of the file. – Other operations, such as renaming, copying, and editing the file may also be controlled. Protection
33
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, End of Chapter 10
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.