Wa0024
Wa0024
Wa0024
File System :
FileConcepts
AccessMethods
DirectoryStructures
Protection Consistency Semantics
FileSystem Structures
AllocationMethods
FreeSpaceManagement.
System Security :
Security Problems
Program Threats
System and Network Threats
User Authentication.
File Concepts
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.
File Structure
A File Structure should be according to a required format that the
operating system can understand.
❑ An executable file is a series of code sections that the loader can bring into
memory and execute.
File Attributes
A file has a single editable name given by its creator. The name never
changes unless a user has necessary permission to change the file name. The
names are given because it is humanly understandable.
The information about the file is kept in a directory structure which also
resides on the secondary storage.
File Operations
A file is an abstract data type. The operating system performs the
following file operations using various system calls.
Create Files – User must have necessary disk space on the file system to create
a file. A directory entry is required where the file is created.
Read Files – The system call requires file name and next block in memory to be
read. The system needs a read pointer to read the file from a specific location in
the file and this pointer is updated for the next read from the file.
Write Files – The system call uses same file pointers of the process to write to a
file. This saves space and reduces complexity.
Deleting a file – We look into the directory for the file name, if a file is found,
release the space occupied by the file and remove directory entries for the deleted
file.
Truncating a file – Sometimes the user does not want to delete a file, but
remove some information from it. This will change file length attribute,
however, other attributes remain unchanged.
There are other file operations such as appending a file, renaming a file,
create a duplicate copy of the file.
Open-File Table
✔ To avoid frequent searches, the OS allows a system call – open() and keeps a
small table containing information about all open files called open file table.
✔ When the file operation is requested, the system refers to the file via an
index value.
✔ The file is not used actively, the process closes the file and the OS remove its
entry from the open file table.
File Type : A common technique for implementing file types is to include the type as part of
the file name.The name is split into two parts --- a name and an extension,usually separated by a
period character.
Word Processor wp, tex, rrf, doc Various word processor formats
Archive arc, zip, tar Related files grouped into one compressed file
Print or View gif, pdf, jpg It is a format for printing or viewing a ASCII or binary file.
File Access Methods
The information stored in a file must be accessed and read into memory.
Though there are many ways to access a file, some system provides only one
method, other systems provide many methods, out of which you must choose
the right one for the application.
TWO-LEVEL DIRECTORY
In this separate directories for each user is maintained. Due to two levels
there is a path name for every file to locate that file. Now,we can have same
file name for different user. Searching is efficient in this method.
Path names can be of two types: absolute path names ,relative path
names.
An absolute path name begins at the root and follows a path down to the
specified file , giving the directory names on the path.
Advantages :
Disadvantages :
Contiguous Allocation
Linked Allocation
Indexed Allocation
Advantages:
1. Both the Sequential and Direct Accesses are supported by this.
2. This is extremely fast since the number of seeks are minimal because of
contiguous allocation of file blocks.
Disadvantages:
1. This method suffers from both internal and external fragmentation. This
makes it inefficient in terms of memory utilization.
2. Increasing file size is difficult because it depends on the availability of
contiguous memory at a particular instance.
Example:
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.
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.
Advantage :
o No external fragmentation
o Effectively used in sequential access file.
o There is no need to declare the file size when that file was created.
Disadvantage :
The file ‘jeep’ in following image shows how the blocks are randomly
distributed. The last block (25) contains -1 indicating a null pointer and
does not point to any other block.
Indexed Allocation
* In this scheme, a special block known as the Index block contains the
pointers to all the blocks occupied by a file.
* Each file has its own index block.
* The ith entry in the index block contains the disk address of the ith file
block.
* The directory entry contains the address of the index block as shown in
the example.
Advantages :
Disadvantages :
The given instance of disk blocks on the disk in Figure 1 (where green blocks
are allocated) can be represented by a bitmap of 16 bits as:
0000111000000110.
Advantages :
• Simple to understand.
• Finding the first free block is efficient. It requires scanning the words (a
group of 8 bits) in a bitmap for a non-zero word. (A 0-valued word has all
bits 0).
• The first free block is then found by scanning for the first 1 bit in the non-
zero word.
For the Figure, we scan the bitmap sequentially for the first non-zero word.
The first group of 8 bits (00001110) constitute a non-zero word since all bits
are not 0. After the non-0 word is found, we look for the first 1 bit.
Counting
This approach stores the address of the first free disk block and a number
n of free contiguous disk blocks that follow the first block.
Every entry in the list would contain:
Address of first free disk block A number n
For example, in Figure-1, the first entry of the free space list would be:
([Address of Block 5], 2), because 2 contiguous free blocks follow block 5.