Lecture 9 File System
Lecture 9 File System
System
File structure
File Structure
Unstructured Files
• Unstructured files also called flat files are in the form of
an unstructured sequence of bytes with no fields or
records.
• UNIX and Windows use this kind of file structure.
File Types
There are three types of files
i. Regular files
ii. Directories
iii. Special files
File Types
Regular Files
• Regular files contain the user information.
• Regular files may be either of ASCII (can be read or
edited using any text editor) or binary type.
File Types
Regular Files
Some types of files are mentioned below:
• Source code files are used when writing programs. For
example, a C language program will be written in a file
with a .c extension.
• Object file. It is a compiled or machine language file. Its
extension are .obj or .o
• Executable file contains executable (linked and ready to
run) code. Its extensions are .exe, .com, .bin, etc.
File Types
Regular Files
• Text file. A general text document is known as a text file.
Its extension is .txt or .doc.
• Batch file consist of some commands to be executed and
given to the command interpreter. Its extension is .bat.
• Archive file: When a group of files is compressed in a
single file, it is known as an archive file. It extensions are
.zip, .rar etc
• Multimedia file: It is a file containing audio or video
information. Its extensions are .mpeg, .mov, .mp3, .jpg,
etc.
File Types
Directories
• Directory is a file type used to organize other files into a
group.
• That is to say, a directory is a collection of files
• Every file belongs to one or more directories.
Disadvantages
i. External fragmentation due to over estimation of file size
ii. Files growing beyond originally allocated space
File Allocation
Linked file allocation
• Allocation is on an individual block basis.
• Each block contains a pointer to the next block in the
chain.
Disadvantages:
Linked allocation is only efficient for sequential access files
Internal fragmentation
File Allocation
Indexed file allocation
• The file allocation table contains a separate one-level
index for each file
• The index has one entry for each block allocated to the
file.
Free Space Management
• Since storage space is limited, we need to reuse the
space from deleted files for new files.
• To keep track of free disk space, the system maintains a
free-space list that records all free blocks that are not
allocated to some file or directory.
Free Space Management
The following approaches are used for free disk space
management
Bit Vector
• The free-space list is implemented as a bit vector with
each block is represented by one bit.
• If the block is free, the bit is set to 1 otherwise if the
block is allocated the bit is set to 0.
• For example, a disk with free blocks 2, 3, 4, 5, 8, 9, 10,
11, 12, 13, 17, 18, 25, 26, and 27 would have a bit vector
below
001111001111110001100000011100000 ...
It is a fast and efficient
The downside is it requires some disk space to store the bit
vector
Free Space Management
Linked List
• Another approach to free-space management is to link
together all the free blocks
• A special pointer on the disk is reserved that points to
the first free disk block. The first free block points to the
second free block, the second block points to the third
one, and so on
Free Space Management
Other free space management approaches
• Grouping
• Counting
• Space Maps
Further Reading
Find below topics for further reading
• Efficiency and performance
• Recovery
• Back up and restore
• File system mounting
• Partitioning
• File sharing
• Virtual file system
• Network file system
• Remote file system