Web Development

How Does File System of an Operating System Work

File systems are an integral part of any operating system with the capacity for long-term storage. There are two distinct parts of a file system, the mechanism for storing files and the directory structure into which they are organised.

In modern operating systems where several users can access the same files simultaneously, it has also become necessary for such features as access control and different forms of file protection to be implemented.

What is a File?

A file is a collection of binary data. A file could represent a programme, a document, or, in some cases, part of the file system itself. In modern computing, it is common for several different storage devices to be attached to the same computer.

Files can have very different data structures but can all be accessed by the same methods built into the file system. The arrangement of data within the file is then decided by the program creating it. The file systems also store several attributes for the files within it.

All user-accessible files have names. Most current file systems use a unique name, a period, and an extension. The term ‘bob’ identifies the file ‘bob.jpg’ as a jpeg picture file. The file extension tells the OS how to open the file. The OS stores file extension relationships. If a user opens ‘bob.jpg,’ the system’s default image viewer will likely open it.

The system also stores the location of a file. In some file systems, files can only be stored as one contiguous block. This has simplified storage and access to the file, as the system then only needs to know where the file begins on the disc and how large it is. It does, however, lead to complications if the file is to be extended or removed, as there may not be enough space available to fit the larger file version.

Most modern file systems overcome this problem by using linked file allocation. This allows the file to be stored in any number of segments. The file system then has to store where every block of the file is and how large they are. This dramatically simplifies file space allocation but is slower than contiguous allocation as the file can be spread out all over the disc. Modern operating systems overcome this flaw by providing a disc defragmenter. This utility rearranges all the files on the disc so they are all in contiguous blocks.

The file system includes file-protection information. Protection can range from the rudimentary FAT system of early Windows, where files might be designated as read-only or hidden, to NTFS, where the file system administrator can define distinct read and write access privileges for individual users or user groups. File security is required in a scenario where several computers or users may access the same discs via a network or time-shared system, such as a raptor.

Some file systems store who generated a file and when. This isn’t necessary for the file system, but it helps users. A file system needs operations for generating, opening, and modifying files to work properly. Almost all file systems offer the same file-manipulation methods. File systems can produce files. To do so, the drive must have adequate capacity. Same-named file must be the only one in the directory. After creating the file, the system records the aforementioned properties.

For a file to be helpful, it must, of course, be readable. To do this, you need to know the name and path of the file. From this, the file system can ascertain where the file is stored on the drive. While reading a file, the system keeps a read pointer. This stores which part of the drive is to be read next. Sometimes, it is impossible to read all of the files into memory. File systems also allow you to reposition the read pointer within a file. To perform this operation, the system needs to know how far into the file you want the read pointer to jump.

An example of where this would be useful is a database system. When a query is made on the database, it is obviously inefficient to read the whole file up to the point where the required data is. Instead, the application managing the database would determine where the required bit of data is in the file and jump to it. This operation is often known as a file seek.

Deleting Files

File systems also allow you to delete files. To do this, it needs to know the name and path of the file. To delete a file, the system simply removes its entry from the directory structure. It adds all the space it previously occupied to the free space list (or whatever other free space management system it uses).

These are the most basic operations required by a file system to function correctly. They are present in all modern computer file systems, but their functions may vary. For example, performing the delete file operation in a current file system like NTFS with file protection built into it would be more complicated than operating in an older file system like FAT. Both plans would check to see whether the file was in use before continuing. NTFS would then have to check whether the user currently deleting the file has permission to do so.

Some file systems also allow multiple people to open the same file simultaneously, so they have to decide whether users have permission to write a file back to the disc if other users currently have it open. If two users have read and given permission to share a file, should one be allowed to overwrite it while the other still has it available? Or, if one user has read-write permission and another only has read permission on a file, should the user with write permission be allowed to overwrite it if there is no chance of the other user also trying to do so?

File systems offer several access mechanisms. Sequential file access is the easiest. This accesses a file record by record from the beginning. To modify a file’s location, rewind, forward, or reset to the beginning. This access mechanism is based on tape drive file storage systems but works on sequential and random-access devices (like hard drives). This approach is simple and appropriate for media playback, but inefficient for database maintenance.

Direct access is a more modern approach that better facilitates reading tasks that aren’t likely to be sequential. Direct access allows records to be read or written over in any order the application requires. This method of allowing any part of the file to be read in any order is better suited to modern hard drives, as they also allow any part of the file to be read in any order with little reduction in transfer rate.

On top of storing and managing files on a drive, the file system also maintains a system of directories in which the files are referenced. Modern hard drives store hundreds of gigabytes. The file system helps organise this data by dividing it up into directories. A directory can contain files or more directories. Like files, there are several basic operations that a file system needs to be able to perform on its directory structure to function correctly.

It must produce files. This is addressed by the file operation overview, but creating the file must be added to the directory structure. When a file is erased, its space becomes free. The file itself must also be deleted. Renaming files is possible. This modifies the directory structure, but not the file. Directory. The user needs know all the disc’s folders to utilise it successfully. The user must also be able to navigate hard disc folders.

Since the earliest directory structures were created, they’ve changed significantly. All files were on the same level before directory hierarchies. This system has one file directory. Two-level directories are the next step, or initial directory structure. One level of directories is listed. These folders hold files. This lets users and apps isolate their files. Then emerged the first directory trees. Tree-structure folders allow guides and files to be stored. All current file systems employ tree-structure directories, although several add security.

Protection in Operating Systems

Protection can be implemented in many ways. Some file systems allow you to have password-protected directories in this system. The file system won’t allow you to access a directory before it is given a username and password. Others extend this system by giving different users or groups access permissions. The operating system requires the user to log in before using the computer and then restricts their access to areas they don’t have permission for. The system used by the computer science department for storage space and coursework submission on raptors is an excellent example of this. In a file system like NTFS, all types of storage space, network access, and use of a device such as printers can be controlled in this way. Other types of access control can also be implemented outside of the file system. For example, applications such as WinZIP allow you to password-protect files.

Show More

Raj Maurya

Raj Maurya is the founder of Digital Gyan. He is a technical content writer on Fiverr and freelancer.com. He loves writing. When not working he plays Valorant.

Leave a Reply

Back to top button