You are on page 1of 31

File Systems Management

 Hard disks, files, folders, directory tables


  The file system installation method

  Manage the list of empty blocks

  Manage the security of the file system

  Some file systems: MSDOS / Windows, UNIX


Hard disk
File
 Information collection is named and stored on disk
 File properties:
 File name
 File type: text file and binary file
 File location: List of disk clusters allocated to the file
 File size
 File creation date and time, file creator
 File classify: hidden, read-only, system, archive, file / directory
 Protect file: Use account (username, password), owner/creator or use
permissions granted to user or group on a file or directory, including
the following permissions: Read, Write, Delete, Execute, List,
Append, ...
File operations

 Create file (create)


 Delete file (delete)
 Open file (open)
 Close file (close)
 Read file (read)
 Write file (write)
 Append file (append)
 Get file attribute (get attribute)
 Set file attribute (set attribute)
 Rename file (rename)
Directory Structure

 is used to manage all files on disk.


 Directory structure is written on disk and includes
multiple entries (Directory Entry)
 Each item stores information for a file or subdirectory
 The operations on the folder can be: Create, Delete,
Open, Close, Read, Rename, Link, Unlink, ...
Entry 0 Entry 1 …. Entry n FileName Attribute storage location

Directory Structure Entry in Directory Structure

Dir Structure

Files
F1 F2 F4
F3
Fn
Directory Structure
Single Level Directory

Two Level Directory

Tree-Structured Directory
Organization of disk partitions
Directory Table
The structure of an
entry in the directory
table of
MSDOS/WINDOWS
(FAT)

The structure of an
entry in the directory
table of CP/M

The structure of an
entry in the directory
table of UNIX
Continuous memory block allocation

 Start: the start block number


 Length: the number of blocks allocated to the file
Non-continuous memory block allocation

 Directory Table
 Use one more structure:
 linked list
 index table
 file allocation table
 I-Nodes table
Non-continuous memory block allocation - linked
list

 start: the first block number


 end: the end block number
 Each block:
 Some first/end bytes to store the next block number of the file (4bytes)
 The rest of the block will save the file's data
Non-continuous memory block allocation - Index
Table
 Each file has an index table that occupies one or several blocks
 The index table contains all the block numbers of a file.
 An item in the directory table will store the block number
containing the file's index table
Non-continuous memory block allocation - Index
Table

 The hard disk has a capacity of 32 MB


 1 block size is 512 Bytes.
 What is the size of an index table if you want to manage a file
with a maximum size of 256K?

 32 MB=25 x 210 x 210 B = 225 B = 216 blocks (each block 512


Bytes (29) ) => 216 address on disk => Each index table
element needs 2 bytes.
 File size 256KB = 256 x 1024 byte = 512 blocks => The index
table needs 512 elements => an index table occupies 2 blocks
(512 elements x 2bytes)!
Non-continuous memory block allocation -
File Allocation Table (FAT)
 Each item in the directory table contains the first block
number
 The number of remaining blocks of the file will be
saved in a table called the file allocation table (FAT
table).
 Easy to protect the block number of files, access
random file easier, expand the file size easier
 FAT is limited by the memory size for it.
 MSDOS, OS / 2, Windows (FAT) used to manage files.
Non-continuous memory block allocation - File
Allocation Table (FAT) – Example 1
 The file “test.txt” is stored in turn: 217, 618, 339.

Non-continuous allocation model, using FAT table


Non-continuous memory block allocation - File
Allocation Table (FAT) – Example 2
 file A: 4, 7, 2, 10, 12 ;
 file B: 6, 3, 11, 14
FAT table :

Non-continuous allocation model, using FAT table, 2 files


Non-continuous memory block allocation - I-nodes
Table

I-node structure in I-nodes Table


Method of organizing disk management by I-nodes

Non-continuous allocation model, using I-nodes Table


Method of organizing disk management by I-nodes

Non-continuous allocation model, using I-nodes Table


Manage empty blocks
 Linked list
 Each node in linked list is a block containing a table:
 empty block numbers
 The last element of the table saves the next block
number in the linked list
 Bit vector (bit sequence)
 The i-th bit = 1: the i-th block (cluster) is empty.
Otherwise, the i-th block is used.
 Vector bits are stored on one or more blocks, when
needed, read into memory for fast processing
Manage empty blocks - Linked list

 Example: A 20M disk, using a cluster of size 1K. To manage this disk, if
the disk is completely empty, how many blocks does the “Linked list”
need (the maximum number of nodes of “Linked list”)?
 20M= 20x 210 blocks ~ 215 blocks => use 16 bit=2 byte in order to save a
cluster
 => 1 block =1024 byte can save 511 empty blocks
 => To manage this completely empty disk (20M) , “Linked list” need 20x
210/ 511 ~ 40 blocks

 A lot of memory is used for “Linked list” if the disk is completely empty,
but less memory will be spent on “Linked list” if the disk is nearly full.
Manage list of empty blocks using linked lists
Management of empty blocks – Bit vector

 Bit vector takes less memory than “Linked list”,


but the bit vector size is fixed and the OS needs to
synchronize the bit vectors in memory and the bit
vectors on the disk.
 Example: A 20M disk, using a block of size 1 K. To
manage this disk, if the disk is completely empty
and uses the bit vector, calculate the bit vector size.
 20M disk: 20 x 210 blocks, so the bit vector size: 20 x
210 bit = 20 x 210 /8/ 210 KB ~ 3 blocks.
Manage the security of the file system

 Manage broken blocks


 Use software: file
 Use hardware: sector
 Backup File
The MSDOS/Windows (FAT) file system

 Boot Sector
 FAT table
 ROOT DIR table
Boot Sector
 On the first sector, track 0, side 0 of the floppy, for the hard
disk this position is the partition table, then the boot sector
of the first partition, for other partitions the boot sector is
the first sector.
 The boot sector contains the BPB disk parameters table
(Bios Parameter Block) and contains the boot code used to
load system files.
 On an IBM PC after performing POST (Power On Self
Test), ROM BIOS finds a valid boot sector, reads the boot
sector to 0X7C00, assigns CS = 0000h, IP = 7C00h and
executes the first command in boot sector (JMP command).
FAT table
 Located behind the boot sector.
 Each FAT entry manages a block of data.
 The block size stored in the boot sector is typically
1 to 8 sectors.
 There are three types of FAT are FAT 12 (4096
blocks) and FAT 16 (64 K blocks), FAT 32 (4G
blocks per partition).
ROOT DIR
 Located right after FAT
 Each entry of the DIR table is 32 bytes.
 When the system opens a File/Directory, MS-DOS
looks for the File/Directory name in the ROOT
DIR table, gets the first block number assigned to
the File/Directory and looks for the next block
number in the FAT table.
MSDOS/Windows (FAT) file system
- Example

 Xét đĩa 1.44MB, được format dưới hệ điều hành MS-


DOS/WINDOWS (FAT12).
The Windows NT file system
 NTFS volume structure: partition boot sector, Master File Table,
file system, data area.
 Partition boot sector: This is the partition's boot sector.
 Master File Table (MFT):
 saves information about all files/directory + empty block list.
 organized into several lines.
 File system: (1Mb)
 MFT2: copy of the MFT
 Log file: information for recovery.
 Cluster bitmap: represents the storage information of the cluster
 Property definition table: defines the supported property types for the
volume.
The UNIX file system
 The following blocks: boot blocks, special blocks, I-nodes,
data blocks.
 Boot block: contains the boot code of the system.
 Super block: contains information about the entire file
system, including:
 Size of the entire file system.
 The address of the first data block.
 Number of empty blocks and list of empty blocks.
 The number of empty I-nodes and the list of empty I-nodes.
 The super block date was last updated.
 The name of the file system.

You might also like