OS CO4 S4 FileDirectories FileSystemImplementation
OS CO4 S4 FileDirectories FileSystemImplementation
LEARNING OUTCOMES
2
PERSISTENCE
STORAGE
• Keep data intact even if there is a power loss.
• Hard disk drive
• Solid-state storage device
• Example)
• A directory has an entry (“f1”, “10”)
• A file “f1” with the low-level name “10”
5
FILE ATTRIBUTES
1. Name
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.
2. Identifier
Along with the name, Each File has its extension which identifies the type of
the file. For example, a text file has the extension .txt, and A video file can have the
extension .mp4.
3. Type
In a File System, the Files are classified in different types such as video files, audio
files, text files, executable files, etc.
4. Location
In the File System, there are several locations in which, the files can be stored.
Each file carries its location as its attribute.
5. Size:
The Size of the File is one of its most important attributes. By size of the file,
we mean the number of bytes acquired by the file in the memory.
6. Protection:
The Admin of the computer may want the different protections for the
different files. Therefore each file carries its own set of permissions to the
different groups of Users.
LA/512
index table
EXAMPLE OF INDEXED ALLOCATION
INDEXED ALLOCATION – SMALL
FILES
• Need index table
• Random access
• Dynamic access without external fragmentation, but have
the overhead of index block
Q
LA/512
• SEQUENTIAL ACCESS
• RANDOM/DIRECT ACCESS
• INDEXED ACCESS
SEQUENTIAL ACCESS
Files
F1 F2 F4
F3
Fn
• Naming problem
• Grouping problem
TWO-LEVEL DIRECTORY
Path name
Can have the same file name for different user
Efficient searching
No grouping capability
TREE-STRUCTURED DIRECTORIES
TREE-STRUCTURED DIRECTORIES (CONT.)
• Efficient searching
• Grouping Capability
rm <file-name>
• Creating a new subdirectory is done in current directory
mkdir <dir-name>
Example: if in current directory /mail
mkdir count
• Access methods
• How does it map the calls made by a process as open(), read(), write(),
etc.
• Which structures are read during the execution of a particular system
call?
OVERALL
ORGANIZATION
• Let’s develop the overall organization of the file system data structure.
• The file system has to track which data blocks comprise a file,
its size, its owner, etc.
INODE TABLE IN THE FILE
SYSTEM
• Reserve some space for inode table
• This holds an array of on-disk inodes.
• Ex) inode tables : 3 ~ 7, inode size : 256 bytes
• 4-KB block can hold 16 inodes.
• The file system contains 80 inodes. (maximum
number of files)
56
ALLOCATION STRUCTURES
57
SUPERBLOCK
58
FILE ORGANIZATION: THE INODE
59
FILE ORGANIZATION: THE INODE
(CONT.)
• Disk are not byte addressable, sector addressable.
• Disk consist of a large number of addressable sectors, (512 bytes)
• Ex) Fetch the block of inode (inode number: 32)
• Sector address iaddr of the inode block:
• blk : (inumber * sizeof(inode)) / blocksize
• sector : (blk * blocksize) + inodeStratAddr ) /sectorsize
60
FILE ORGANIZATION: THE INODE (CONT.)
61
FILE ORGANIZATION: THE INODE (CONT.)
62
THE MULTI-LEVEL INDEX
63
THE MULTI-LEVEL INDEX
(CONT.)
64
THE MULTI-LEVEL INDEX (CONT.)
65
DIRECTORY ORGANIZATION
66
FREE SPACE MANAGEMENT
• File system tracks which inode and data block are free or not.
• To manage free space, we have two simple bitmaps.
• When a file is newly created, it is allocated inode by searching
the inode bitmap and updating the on-disk bitmap.
• Pre-allocation policy is commonly used to allocate contiguous
blocks.
67
ACCESS PATHS: READING A FILE FROM DISK
69
ACCESS PATHS: READING A FILE FROM DISK
(CONT.)
70
ACCESS PATHS: WRITING TO DISK
72
CACHING AND BUFFERING
79