Chapter 7
Chapter 7
• Create • Append
• Delete • Seek
• Open • Get attributes
• Close • Set Attributes
• Read • Rename
• Write • Lock
Directories
The directories contains information about the files, including
attributes, locations and ownerships
The directory is itself a file owned by the operating system and it
consisting of sub directories
A file system that contain millions of files are hard to manage
To manage these files grouped them and load one group into one
directory
The directory structure provides a mechanism for organizing many
files in the file system
Directory Structure
1. Single Level Directory System
In this directory system having only one directory ,it consisting of the all
files
Sometimes it is said to be root directory
Root Directory
A D
B C
The advantage of this scheme are its simplicity and ability to locate files
quickly
Directory Structure
2. Two Level Directory Structure
The problem in a single level directory is defferent users may be accidentally use
the same names for their files
To avoid the problem each user need a private directory
Root Directory
B A C
A B B
Directory Structure
3. Hierarchical Directory System
The two level directory eliminates name conflicts among users
but it is not satisfactory for users with a large number of files.
Hierarchical directory system solve the problem
Root
directory
Sub-dir Sub-dir
A B
Sub-sub Sub-sub Sub-sub Sub-sub
directory directory directory directory
A
B C D
Directory Structure
4. General graph directory structure
The primary advantage of this structure is traversing is easy and file sharing also
possible
Root
directory
Sub-dir Sub-dir
A B
Sub-sub Sub-sub Sub-sub Sub-sub
directory directory directory directory
A
B C D
Path Names
•Absolutepath name:
-Unix: /usr/home/anda/teaching/lec22.ppt
-Windows: c:\My Documents\teaching\lec22.ppt
•Relative path name
-use the “current directory” as a starting point
-“.” (dot) for “this directory”
-“..” (dot dot) for “parent of this directory”
-if current directory is /usr/home/anda/research:
•../teaching/lec22.ppt.txt is the same file as
•/usr/home/anda/teaching/lec22.ppt
A Unix Directory Tree
C 35 7 7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48
File Allocation Methods
This method is best suited for sequential files .
The main problem is: It is difficult to find the contiguous free
blocks in the disk
Another problem is external fragmentation- it means some free
blocks could happen between two files.
2. Linked Allocation:-
External fragmentation can be avoided
It is easy to locate the files, b/c allocation is on an individual
block basis.
File Allocation Methods
Each block contains a pointer to the next free block in the chain.
Here is also the file allocation table consisting of a single entry for
each file
Using this method any free block can be added to a chain very
easily.
There is a link b/n one block to another block
File Allocation Methods
0 1 2 3 4 5 6
File name Start length
name 7 8 9 10 11 12 13
Bubble sort 10 7
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
35 36 37 38 39 40 41
42 43 44 45 46 47 48
49 50 51 52 53 54 55
56 57 58 59 60 61 62
File Allocation Methods
Advantage
Avoid the external fragmentation
Suited for sequential files
Disadvantage
The pointer itself occupies some memory with in the block
It takes much accessing time
File Allocation Methods
3. Group Allocation or Indexed Allocation
In this method the file allocation table contains a single entry for
each file .
The entry consisting of one index block, the index box having the
pointers to the other blocks which is occupied by the particular file.
File Allocation Methods
0 1 2 3 4 5 6
File name Index
block 7 8 9 10 11 12 13
: :
14 15 16 17 18 19 20
: :
: :
21 22 23 422
24 25 26 27
Bubble sort 42
28 29 30 31 32 33 34
: :
: : 35 36 37 38 39 40 41
: : 42
42 43 44 45 46 47 48
23 38 56 51 24 49 50 51 52 53 54 55
56 57 58 59 60 61 62
File Allocation Methods
Advantage
Indexed allocation supports both sequential and direct access of files
The file indexes are not physically stored as part of the file allocation table
Whenever the file size increases, we can easily add some more blocks to the
index
No external fragmentation
Disk Space Management
•Generally the files are stored on disk, so management of disk space
is a major problem to the designer
•To allocate the space to file, what space on the disk available must
be known
•So in addition to file allocation table disk allocation table is needed
•To keep track of free disk space, the file system maintains a free
space list
•The free space list records all the disk blocks which are free
Disk Space Management
•To create a file we search a free space list for the required amount
of space and allocate it to the new file
•This space then removed from the list
•When the file is deleted, its disk space is added to the free space list
•A number of techniques have been implemented here
Disk Space Management
1. Bit vector or Bit table
• It is a collection of bits, in which each block is represented by
one bit.
• If the block is free, the bit is 0
• If the bit is allocated, the bit is 1
• For example consider the a disk where blocks
5,8,16,35,40,43,48,51 are free, the free space bit vector would be
111101101111111011111111111111111101111011011110110
5 8 16 35 40 43 48
51
Disk Space Management
2. Chain free points or Linked free space list
•This approach is to link all the free space blocks together,
keeping a pointer to the first free block
•This block contains a pointer to the next free disk block and so
on
•Example: keep a pointer to block 5,it contains a pointer to block
8, which would point to block 16, which would block to point to
35 and so on
Disk Space Management
3. Index block list
•A modification of this approach would store the address of n free
blocks in the first free block.
•The n-1 of these are actually free
•The last one is the disk address of another block containing the
address of another n free blocks
Advantage
•The address of large number of free blocks can be found quickly
Windows 2000 File System
•Windows 2000 supports several file systems, the most important of
which are:
i.FAT -16: it is the old MS-DOS file system. -It uses 16bit
disk addresses, so it supports only 2GB(216)