5.1 Introduce File Management
File management is defined as the process of manipulating files in the computer system, its management includes the process of creating, modifying, and deleting the files. A file management system is used for file maintenance (or management) operations. It is a type of software that manages data files in a computer system. A file management system is also known as a file manager.
A file system is a process of managing how and where data is on a storage disk, which is also referred to as file management or FS. It is a logical disk component that compresses files separated into groups, which is known as directories
A file is a named collection of related information that is recorded on secondary storage.
5.2 Explain File Naming, File operation, File Extension, and File System layout
Every file carries a name by which the file is recognized in the file system. One directory cannot have two files with the same name. The symbolic file name is the only information kept in human-readable form.
A file is a collection of logically related data that is recorded on the secondary storage in the form of a sequence of operations. The content of the files is defined by the creator who is creating the file. The various operations which can be implemented on a file such as read, write, open and close, etc. are called file operations.
a) File Create Operation: The file is created with no data.
b) File Delete Operation: The file must have to be deleted when it is no longer needed just to free up the disk space.
c) File Open Operation: The process must open the file before using it.
d) File Close Operation: The file must be closed to free up the internal tablespace.
e) File Read Operation: The file read operation is performed just to read the data.
f) File Write Operation: The file writes operation is used to write the data to the file.
g) File Append Operation: The file append operation only adds the data at the end of the file.
h) File Rename Operation: The file rename operation is used to change the name of the existing file.
A common technique for implementing file types is to include the type as part of the file name which is called file extension. The name is split into two parts—a name and an extension, usually separated by a period character.
Picture files: .jpg, .png
Music and sound files: .mp3, .wav
Operating system files: .dll, .exe
Text and word processing documents: .docx, .txt
Spreadsheet files: .xlsx, .csv
Web Page files: .htm, .html
File System Layout
A file system is a set of files, directories, and other structures. File systems maintain information and identify where a file or directory’s data is located on the disk. In addition to files and directories, file systems contain a boot block, a superblock, bitmaps, and one or more allocation groups.
- MBR: Master Boot Record is used to boot the computer
- Partition Table: Partition table is present at the end of MBR. This table gives the starting and ending addresses of each partition.
- Boot Block: When the computer is booted, the BIOS reads in and executes the MBR. The first thing the MBR program does is locate the active partition, read in its first block, which is called the boot block, and execute it. The program in the boot block loads the operating system contained in that partition. Every partition contains a boot block at the beginning though it does not contain a bootable operating system.
- Super Block: It contains all the key parameters about the file system and is read into memory when the computer is booted or the file system is first touched.
5.3 Describe File Allocation: Contiguous, Index
The allocation methods define how the files are stored in the disk blocks. There are three main disk space or file allocation methods.
If the blocks are allocated to the file in such a way that all the logical blocks of the file get the contiguous physical block in the hard disk then such allocation scheme is known as contiguous allocation.
• It is simple to implement.
• We will get an excellent read performance.
• The disk will become fragmented.
• It may be difficult to have a file grow.
Linked List allocation solves all problems of contiguous allocation. In linked list allocation, each file is considered as the linked list of disk blocks. However, the disks blocks allocated to a particular file need not be contiguous on the disk. Each disk block allocated to a file contains a pointer that points to the next disk block allocated to the same file.
• There is no external fragmentation with linked allocation.
• Any free block can be utilized in order to satisfy the file block requests.
• Random Access is not provided.
• Pointers require some space in the disk blocks.
5.4 Free Space Management
A file system is responsible to allocate the free blocks to the file therefore it has to keep track of all the free blocks present in the disk. There are mainly two approaches by using which, the free blocks in the disk are managed.
- Bit Vector
In this approach, the free space list is implemented as a bit map vector. It contains the number of bits where each bit represents each block.
If the block is empty then the bit is 1 otherwise it is 0. Initially all the blocks are empty therefore each bit in the bit map vector contains 1.
LAs the space allocation proceeds, the file system starts allocating blocks to the files and setting the respective bit to 0.
- Linked List
It is another approach for free space management. This approach suggests linking together all the free blocks and keeping a pointer in the cache which points to the first free block.
Therefore, all the free blocks on the disks will be linked together with a pointer. Whenever a block gets allocated, its previous free block will be linked to its next free block.