Docsity

File System Interface and Implementation: A Comprehensive Overview, Exams of Systematics

Toggle sidebar
bg1
File system Interface:The concept of a file, access methods, directory structure, file system
mounting, files sharing, protection.
File System Implementation: File system structure, allocation methods, free-space
management, and secondary storage structure – overview of mass-storage structure, disk
scheduling and algorithms
File
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes,
lines or records whose meaning is defined by the files creator and user.
Properties of a File System
Here, are important properties of a file system:
• Files are stored on disk or other storage and do not disappear when a user logs off.
• Files have names and are associated with access permission that permits controlled
sharing.
• Files could be arranged or more complex structures to reflect the relationship between
them.
File Attributes
A file has a name and data. Moreover, it also stores meta information like file creation date and
time, current size, last modified date, etc. All this information is called the attributes of a file
system.
Here, are some important File attributes used in OS:
• Name: It is the only information stored in a human-readable form.
• Identifier: Every file is identified by a unique tag number within a file system known as
an identifier.
• Location: Points to file location on device.
• Type: This attribute is required for systems that support various types of files.
• Size. Attribute used to display the current file size.
• Protection. This attribute assigns and controls the access rights of reading, writing, and
executing the file.
• Time, date and security: It is used for protection, security, and also used for monitoring
Functions of File
• Create file, find space on disk, and make an entry in the directory.
• Write to file, requires positioning within the file
• Read from file involves positioning within the file
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download File System Interface and Implementation: A Comprehensive Overview and more Exams Systematics in PDF only on Docsity!

File system Interface: The concept of a file, access methods, directory structure, file system mounting, files sharing, protection. File System Implementation: File system structure, allocation methods, free-space management, and secondary storage structure – overview of mass-storage structure, disk scheduling and algorithms File A file is a named collection of related information that is recorded on secondary storage such as magnetic disks, magnetic tapes and optical disks. In general, a file is a sequence of bits, bytes, lines or records whose meaning is defined by the files creator and user. Properties of a File System Here, are important properties of a file system:

  • Files are stored on disk or other storage and do not disappear when a user logs off.
  • Files have names and are associated with access permission that permits controlled sharing.
  • Files could be arranged or more complex structures to reflect the relationship between them. File Attributes A file has a name and data. Moreover, it also stores meta information like file creation date and time, current size, last modified date, etc. All this information is called the attributes of a file system. Here, are some important File attributes used in OS:
  • Name: It is the only information stored in a human-readable form.
  • Identifier : Every file is identified by a unique tag number within a file system known as an identifier.
  • Location: Points to file location on device.
  • Type: This attribute is required for systems that support various types of files.
  • Size. Attribute used to display the current file size.
  • Protection. This attribute assigns and controls the access rights of reading, writing, and executing the file.
  • Time, date and security: It is used for protection, security, and also used for monitoring Functions of File
  • Create file, find space on disk, and make an entry in the directory.
  • Write to file, requires positioning within the file
  • Read from file involves positioning within the file
  • Delete directory entry, regain disk space.
  • Reposition: move read/write position. File types- name, extension File Type Usual extension Function Executable exe, com, bin or none ready-to-run machine- language program Object obj, o complied, machine language, not linked Source code c. p, pas, 177, asm, a source code in various languages Batch bat, sh Series of commands to be executed Text txt, doc textual data documents Word processor doc,docs, tex, rrf, etc. various word-processor formats Library lib, h libraries of routines Archive arc, zip, tar related files grouped into one file, sometimes compressed. File Access Methods File access is a process that determines the way that files are accessed and read into memory. Generally, a single access method is always supported by operating systems. Though there are some operating system which also supports multiple access methods. Three file access methods are:
  • Sequential access
  • Direct random access

Let us now study the directory structure with the help of the figure above. The field File name , contains the name of the concerned file in the directory, Type field indicates the kind or category of the file, Location Info field indicates the location where the file is stored. Protection Info field contains the information whether the file can be accessed by the other user in the system or not. Flag field contains the kind of directory entry like value D in Flag field indicates that the file is a directory, value L indicates that the file is a link, value M indicates that the file is a mounted file system. The Misc info filed in the directory contains the miscellaneous information about the owner of the file, the time of its creation, the time at which the file was modified last. Types of Directory Structures In this section, we will be discussing the most common types of directories, their benefits and drawbacks.

1. Single-level directory structure Single level directory structure has only one directory which is called the root directory. The users are not allowed to create subdirectories under the root directory. All the files created by the several users are present in the root directory only. As you can see in the diagram below all the file F1, F2, F3, F4 created by the different users are present at the root directory.

There is one drawback of Single-level directory structure, a user cannot use the same file name used by another user in the system. Even if the file with the same name is created the old file will get destroyed first and replaced by the new file having the same name.

2. Two-level directory structure In Two-level directory structure, the users create directory directly inside the root directory. But once a user creates such directory, further he cannot create any subdirectory inside that directory. Observe the figure below, 4 users have created their separate directory inside the root directory. But further, no subdirectory is created by the users.

The tree directory structure provides an asymmetric way for the user to access the shared files of a different user. For example, a user can access a file of its own user directory with a shorter path than the other user.

5. Acyclic-Graph Directory Structure This problem can be solved by the acyclic-graph directory structure. As this directory structure allows a directory or a file to have many parent directories. So, a shared file in a directory can be pointed by the other user directories who have access to that shared file using the links. In the diagram below you can see that the directory having file F7 and F8 have two parent directories.

Operations on Directory As discussed above, a directory contains the entries of all the related files. For organizing the directory in the better way the user must be able to insert, delete, search, list the entries in the directory. Below we will be discussing the operation that can be performed on the directory.

1. Searching A directory can be searched for a particular file or for another directory. It can also be searched to list all the files with the same name. 2. Creating

  • To illustrate file mounting, consider the file system depicted in Fig, where the triangles represent sub-trees of directories that are of interest. At this point, only the files on the existing file system can be accessed. At this point, only the files on the existing file system can be accessed. Figure 10.13 shows the effects of mounting the volume residing on /device/dsk over /users. If the volume is unmounted, the file system is restored to the situation depicted in Figure 10.12. Systems impose semantics to clarify functionality. For example, a system may disallow a mount over a directory that contains files; or it may make the mounted file system available at that directory and obscure the directory's existing files until the file system is unmounted, terminating the use of the file system and allowing access to the original files in that directory.

As another example, a system may allow the same file system to be mounted repeatedly, at different mount points; or it may only allow one mount per file system. Consider the actions of the Macintosh operating system. Whenever the system encounters a disk for the first time (hard disks are found at boot time, and floppy disks are seen when they are inserted into the drive), the Macintosh operating system searches for a file system on the device. If it finds one, it automatically mounts the file system at the root level, adding a folder icon on the screen labeled with the name of the file system (as stored in the device directory). The user is then able to click on the icon and thus display the newly motinted file system. The Microsoft Windows family of operating systems (95, 98, NT, small 2000, XP) maintains an extended two-level directory structure, with devices and volumes assigned drive letters. Volumes have a general graph directory structure associated with the drive letter. The path to a specific file takes the form of drive-letter;\path\to\file. The more recent versions of Windows allow a file system to he mounted anywhere in the directory tree, just as UNIX does. Windows operating systems automatically discover all devices and mount all located file systems at boot time. In some systems, like UNIX, the mount commands are explicit. A system configuration file contains a list of devices and mount points for automatic mounting at boot time, but other mounts may be executed manually. Files sharing File sharing is the practice of sharing or offering access to digital information or resources, including documents, multimedia (audio/video), graphics, computer programs, images and e- books. It is the private or public distribution of data or resources in a network with different levels of sharing privileges. File sharing can be done using several methods. The most common techniques for file storage, distribution and transmission include the following: i. Removable storage devices ii. Centralized file hosting server installations on networks iii. World Wide Web-oriented hyperlinked documents iv. Distributed peer-to-peer networks File sharing is a multipurpose computer service feature that evolved from removable media via network protocols, such as File Transfer Protocol (FTP). Beginning in the 1990s, many remote file-sharing mechanisms were introduced, including FTP, hotline and Internet relay chat (IRC). Operating systems also provide file-sharing methods, such as network file sharing (NFS). Most file-sharing tasks use two basic sets of network criteria, as follows: Peer-to-Peer (P2P) File Sharing: This is the most popular, but controversial, method of file sharing because of the use of peer-to- peer software. Network computer users locate shared data with third-party software. P2P file

The need to protect files is a direct result of the ability to access files. Systems that do not permit access to the files of other users do not need protection. Thus, we could provide complete protection by prohibiting access. Alternatively, we could provide free access with no protection. Both approaches are too extreme for general use. What is needed is controlled access. access that can be made. 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 tree 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. For many systems, however, these higher-level functions may be implemented by a system program that makes lower-level system calls. Protection is provided at only the lower level. For instance, copying a file may be implemented simply by a sequence of read requests. In this case, a user with read access can also cause the file to be copied, printed, and so on. Many protection mechanisms have been proposed. Each has advantages and disadvantages and must be appropriate for its intended application. A small computer system that is used by only a few members of a research group, for example, may not need the same types of protection as a large corporate computer that is used for research, finance, and personnel operations. Access Control The most common approach to the protection problem is to make access dependent on the identity of the user. Different users may need different types of access to a. file or directory. The most general scheme to implement identity dependent access is to associate with each file and directory an access-control list (ACL) specifying user names and the types of access allowed for each user. When a user requests access to a particular file, the operating system checks the access

list associated with that file. If that user is listed for the requested access, the access is allowed. Otherwise, a protection violation occurs, and the user job is denied access to the file. This approach has the advantage of enabling complex access methodologies. The main problem with access lists is their length. If we want to allow everyone to read a file, we must list all users with read access. This technique has two undesirable consequences:

  • Constructing such a list may be a tedious and unrewarding task, especially if we do not know in advance the list of users in the system. « The directory entry, previously of fixed size, now needs to be of variable size, resulting in more complicated space management. These problems can be resolved by use of a condensed version of the afccess list. To condense the length of the access-control list, many systems recognize three classifications of users in connection with each file:
  • Owner. The user who created the file is the owner.
  • Group. A set of users who are sharing the file and need similar access is a group, or work group.
    • Universe. All other users in the system constitute the universe. The most common recent approach is to combine access-control lists with the more general (and easier to implement) owner, group, and universe accesscontrol scheme just described. For example, Solaris 2.6 and beyond use the three categories of access by default but allow access-control lists to be added to specific files and directories when more fine-grained access control is desired. To illustrate, consider a person, Sara, who is writing a new book. She has hired three graduate students (Jim, Dawn, and Jill) to help with the project. The text of the book is kept in a file named book. The protection associated with this file is as follows:
  • Sara should be able to invoke all operations on the file.

File Protection Another difficulty is assigning precedence when permission and ACLs conflict. For example, if Joe is in a file's group, which has read permission, but the file has an ACL granting Joe read and write permission, should a write by Joe be granted or denied? Solaris gives ACLs permission (as they are more fine-grained and are not assigned by default). This follows the general rule that specificity should have priority. 10.6.3 Other Protection Approache s Another approach to the protection problem is to associate a password with each file. Just as access to the computer system is often controlled by a password, access to each file can be controlled in the same way. If the passwords are chosen randomly and changed often, this scheme may be effective in limiting access to a file. The use of passwords has a few disadvantages, however. First, the number of passwords that a user needs to remember may become large, making the scheme impractical. Second, if only one password is used for all the files, then once it is discovered, all files are accessible; protection is on an all-or-none basis. Some systems (for example, TOPS-20) allow a user to associate a password with a subdirectory, rather than with an individual file, to deal with this problem. The IBMVM/CMS operating system allows three passwords for a minidisk—one each for read, write, and multiwrite access. Some single-user operating systems—such as MS-DOS and earlier versions of the Macintosh operating system prior to Mac OS X—provide little in terms of file protection. In scenarios where these older systems are now being placed on networks where file sharing and communication are necessary, protection mechanisms must be retrofitted into them. Designing a feature for a new operating system is almost always easier than adding a feature to an existing one. Such updates are usually less effective and are not seamless. In a multilevel directory structure, we need to protect not only individual files but also collections of files in subdirectories; that is, we need to provide a mechanism for directory protection. The directory operations that must be protected are somewhat different from the file operations. We want to control the creation and deletion of files in a directory.

File Protection In addition, we probably want to control whether a user can determine the existence of a file in a directory. Sometimes, knowledge of the existence and name of a file is significant in itself. Thus, listing the contents of a directory must be a protected operation. Similarly, if a path name refers to a file in a directory, the user must be allowed access to both the directory and the file. In systems where files may have numerous path names (such as acyclic or general graphs), a given user may have different access rights to a particular file, depending on the path name used. File System Implementation: File system structure, allocation methods, free-space management, secondary storage structure – overview of mass-storage structure, disk scheduling and algorithms File System Structure File System provide efficient access to the disk by allowing data to be stored, located and retrieved in a convenient way. A file System must be able to store the file, locate the file and retrieve the file. Most of the Operating Systems use layering approach for every task including file systems. Every layer of the file system is responsible for some activities. The image shown below, elaborates how the file system is divided in different layers, and also the functionality of each layer.

mapped to physical blocks. This mapping is done by File organization module. It is also responsible for free space management. o Once File organization module decided which physical block the application program needs, it passes this information to basic file system. The basic file system is responsible for issuing the commands to I/O control in order to fetch those blocks. o I/O controls contain the codes by using which it can access hard disk. These codes are known as device drivers. I/O controls are also responsible for handling interrupts. allocation methods The allocation methods define how the files are stored in the disk blocks. There are three main disk space or file allocation methods.

  • Contiguous Allocation
  • Linked Allocation
  • Indexed Allocation The main idea behind these methods is to provide:
  • Efficient disk space utilization.
  • Fast access to the file blocks. All the three methods have their own advantages and disadvantages as discussed below: 1. Contiguous Allocation In this scheme, each file occupies a contiguous set of blocks on the disk. For example, if a file requires n blocks and is given a block b as the starting location, then the blocks assigned to the file will be: b, b+1, b+2,……b+n-1. This means that given the starting block address and the length of the file (in terms of blocks required), we can determine the blocks occupied by the file. The directory entry for a file with contiguous allocation contains
  • Address of starting block
  • Length of the allocated portion. The file ‘mail’ in the following figure starts from the block 19 with length = 6 blocks. Therefore, it occupies 19, 20, 21, 22, 23, 24 blocks.

Advantages:

  • Both the Sequential and Direct Accesses are supported by this. For direct access, the address of the kth block of the file which starts at block b can easily be obtained as (b+k).
  • This is extremely fast since the number of seeks are minimal because of contiguous allocation of file blocks. Disadvantages:
  • This method suffers from both internal and external fragmentation. This makes it inefficient in terms of memory utilization.
  • Increasing file size is difficult because it depends on the availability of contiguous memory at a particular instance. 2. Linked List Allocation In this scheme, each file is a linked list of disk blocks which need not be contiguous. The disk blocks can be scattered anywhere on the disk. The directory entry contains a pointer to the starting and the ending file block. Each block contains a pointer to the next block occupied by the file.