5.1 Introduction to file management
File management is a critical function of an operating
system (OS) that allows users to store, retrieve, organize, and manipulate
files efficiently. It
ensures efficient handling of files, enabling the creation, reading, updating,
and deletion of files.
A file
management system has limited capabilities and is designed to manage individual
or group files, such as special office documents and records. It may display
report details, like owner, creation date, state of completion and similar
features useful in an office environment. A
file management system is also known as a file manager.
5.2 File
naming, file operations, file extension and file system layout
File Naming
Descriptive file names are an important part of
organizing, sharing, and keeping track of data files. Develop a naming
convention based on elements that are important to the project.
File naming best practices:
●
Files should be named consistently
●
File names should be short but
descriptive (<25 characters)
●
Avoid special characters or spaces
in a file name
●
Use capitals and underscores
instead of periods or spaces or slashes
●
Use date format ISO 8601: YYYYMMDD
The
most basic operations that programs can perform on a file are:
●
Create a new file.
●
Change the access permissions and
attributes of a file.
●
Open a file, which makes the file
contents available to the program.
●
Read data from a file.
●
Write data to a file.
●
Delete a file.
File Extension
A file extension, or filename extension, is a suffix at
the end of a computer file. It comes after the period and is usually two to
four characters long. If you’ve ever opened a document or viewed a picture,
you’ve probably noticed these letters at the end of your file.
File extensions are used by the operating system to
identify what apps are associated with what file types. For example, a file
named “sankalpa.jpg” has the “jpg” file extension. When you open that file in
Windows, for example, the operating system looks for whatever app is associated
with JPG files, opens that app, and loads the file.
File System Layout
A file system
is a structured collection of files, directories, and related data that
organizes how information is stored and retrieved on a disk. It keeps track of
where each file is located and manages storage efficiently. A file system
includes components such as a boot block, superblock, allocation bitmaps, and
allocation groups, all of which work together to manage disk storage.
Boot Block
The boot block
is the first part of the file system, located at the beginning of the disk. It
contains the information required to start or boot the operating system.
Superblock
The superblock
stores important metadata about the entire file system. It includes details
such as the size of the file system, number of data blocks, state of the
system, and allocation group sizes.
Allocation Bitmaps
Allocation
bitmaps are used to keep track of used and free disk space. One bitmap records
the status of disk blocks (fragments), while another tracks the allocation of
i-nodes.
Disk Allocation (File Allocation)
Disk allocation
refers to the method used by an operating system to store files on disk blocks.
Its main goals are efficient space utilization and fast file access.
1. Contiguous Allocation
In contiguous
allocation, a file is stored in consecutive disk blocks starting from a
specific location. This method allows fast access because blocks are
sequential. However, it suffers from fragmentation and makes it difficult to
expand files when space is not available continuously.
2. Linked Allocation
In linked
allocation, file blocks are stored at random locations on the disk and
connected using pointers. This method eliminates external fragmentation and
allows easy file growth. However, it is slower because accessing data requires
following pointers, and it does not support direct access efficiently.
3. Indexed Allocation
In indexed
allocation, each file has a separate index block that stores pointers to all
its disk blocks. This method supports direct access and avoids fragmentation.
However, it introduces overhead due to the extra index block and may waste
space for small files.
Free Space Management
Free space
management is the process of tracking and managing unused disk blocks so they
can be allocated to new files. When a file is deleted, its space is returned to
the free space list for reuse.
1. Bitmap Method
In the bitmap
method, each disk block is represented by a bit. A value of 1 indicates a free
block, while 0 indicates an allocated block. This method is simple and
efficient for finding free space but may not be suitable for very large disks.
2. Linked List Method
In this method,
all free blocks are linked together using pointers. The system keeps a pointer
to the first free block. Although it is easy to allocate space, searching for
free blocks can be slow due to disk access time.
3. Grouping Method
Grouping stores
addresses of multiple free blocks together in one block. This improves
efficiency by allowing several free block addresses to be accessed at once
instead of one at a time.
4. Counting Method
Counting keeps
track of contiguous free blocks by storing the starting block address and the
number of free blocks. This method is efficient when free space exists in large
continuous chunks.
Comments
Post a Comment