Chapter 11 File-System Interface Silberschatz - Operating System…
Silberschatz - Operating System Concepts 9th
The file’s owner might write the file to a USB disk, send it as an e-mail attachment, or copy it across a network, and it could still be called example.c on the destination system
A file’s attributes vary from one operating system to another but typically consist of these:
Time, date, and user identification
Writing a file
Make a system call specifying both the name of the file and the information to be written to the file.
Reading a file
Use a system call that specifies the name of the file and where the next block of the file should be put.
Creating a file
Two steps are necessary to create a file
First, space in the file system must be found for the file.
Second, an entry for the new file must be made in the directory.
Repositioning whiting a file
The directory is searched for the appropriate entry,and the current-file-position pointer is repositioned to a given value.
Deleting a file
search the directory for the named file and erase the directory entry.
Truncating a file
Rather than forcing the user to delete the file and then recreate it, this function allows all attributes to remain unchanged but lets the file be reset to length zero and its file space released.
This pointer is unique to each process operating on the file and therefore must be kept separate from the on-disk file attributes.
Tracks the number of opens and closes and reaches zero on the last close.
Disk location of the file
The information needed to locate the file on disk is kept in memory so that the system does not have to read it from disk for each operation.
Information is stored on the per-process table so the operating system can allow or deny subsequent I/O requests.
If an operating system recognizes the type of a file,it can then operate on the file in reasonable ways
A common technique for implementing file types is to include the type as part of the file name.
print or view
File types also can be used to indicate the internal structure of the file source and object files have structures that match the expectations of the programs that read them.
Internal File Structure
Internally, locating an offset within a file can be complicated for the operating system. Disk systems typically have a well-defined block size determined by the size of a sector. All disk I/O is performed in units of one block, and all blocks are the same size
Information in the file is processed in order, one record after the other.
a file is made up of fixed-length logical records that allow programs to read and write records rapidly in no particular order.
Directory and Disk Structure
The simplest directory structure is the single-level directory. All files are contained in the same directory, which is easy to support and understand
Each user has his own user file directory (UFD).
Delete a file
When a file is no longer needed,we want to be able to remove it from the directory
List a directory
We need to be able to list the files in a directory and the contents of the directory entry for each file in the list.
Create a file
New files need to be created and added to the directory.
Rename a file
Because the name of a file represents its contents to its users, we must be able to change the name when the contents or use of the file changes.
Search for a file
We need to be able to search a directory structure to find the entry for a particular file
Traverse the file system
We may wish to access every directory and every file within a directory structure. This technique provides a backup copy in case of system failure.
Allows users to create their own subdirectories and to organize their files accordingly
A virtual file system that maintains“contract” information to manage which processes start when the system boots and must continue to run during operation
A “loop back” file system that allows one file system to be accessed in place of another one
A “virtual” file system (essentially an interface to the kernel that looks like a file system) that gives debuggers access to kernel symbols
A virtual file system that presents information on all processes as a file system
General-purpose file systems
A “temporary” file system that is created in volatile main memory and has its contents erased if the system reboots or crashes
Allows directories to share subdirectories and files. The same file or subdirectory may be in two different directories. The acyclic graph is a natural generalization of the tree-structured directory scheme
The directory structure may be built out of multiple volumes, which must be mounted to make them available within the file-system name space.
Remote File System
Distributed Information Systems
To make client–server systems easier to manage, distributed information systems, also known as distributed naming services, provide unified access to the information needed for remote computing
Some kind of state information may be maintained on both the client and the server. If both server and client maintain knowledge of their current activities and open files, then they can seamlessly recover from a failure
The Client-Server Model
Allow a computer to mount one or more file systems from one or more remote machines
These semantics specify how multiple users of a system are to access a shared file simultaneously
In the UNIX semantics, a file is associated with a single physical image that is accessed as an exclusive resource. Contention for this single image causes delays in user processes.
Given a directory structure that allows files to be shared by users, the system must mediate the file sharing. The system can either allow a user to access the files of other users by default or require that a user specifically grant access to the files.
Types of Access
Access is permitted or denied depending on several factors, one of which is the type of access requested. Several different types of operations may be controlled:
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.
Constructingsuchalistmaybeatediousandunrewardingtask,especially if we do not know in advance the list of users in the system.
The directory entry, previously of fixed size, now must be of variable size, resulting in more complicated space management.
Daniela Porras Quiros