The Root Directory-System Programming-Lecture Notes, Study notes of System Programming

This lecture handout is for System Programming course. It was provided by Prof. Indubhushan Vijayabhas at Ambedkar University, Delhi. It includes: Root, Directory, Slide, File, Dos, Recursively, Data, Block, Obtain, Portion, Contents, System

Typology: Study notes

2011/2012

Uploaded on 08/07/2012

anishay
anishay 🇮🇳

4.2

(25)

118 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture # 33
The Root Directory
root
The DOS directory structure is a Tree like structure. The top most level of the tree being
the root directory. The root directory contains files and folders. Each folder can contains
more files and folders and so on it continues recursively as shown by the slide.
File
Is logically viewed as an organization of Data.
Physically it can be a collection of clusters or
blocks.
O.S. needs to maintain information about the
cluster numbers of which a file may be comprised
of.
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download The Root Directory-System Programming-Lecture Notes and more Study notes System Programming in PDF only on Docsity!

Lecture # 33

The Root Directory

root

The DOS directory structure is a Tree like structure. The top most level of the tree being

the root directory. The root directory contains files and folders. Each folder can contains

more files and folders and so on it continues recursively as shown by the slide.

File

• Is logically viewed as an organization of Data.

• Physically it can be a collection of clusters or

blocks.

• O.S. needs to maintain information about the

cluster numbers of which a file may be comprised

of.

Control information about files are maintained in a data structure called the File control

block (FCB). The FCB for each file is created and stored in the disk.

File Control Block (FCB)

0B BYTE Attribute

1Ah WORD First Cluster

1Ch DWORD size

18h WORD Date

16h WORD Time

0C BYTE [10] Reserved + used by OS /

08 BYTE [3] File extension

00 BYTE [8] File Name in 8 bytes

Offset TYPE Description

The root directory consists of FCBs for all the files and folders stored on the root

directory. To obtains these FCBs, the portion on disk reserved for root directory can be

read.

User

Data

Root

Dir

FAT FAT

Boot Block

Location of Root Directory

The user data area is divided into clusters. The first cluster in user data area is numbered

2 in a FAT based systems. A cluster is not the same as block and also there are no system

calls available which use the cluster number. All the system calls use the LSN address. If

the cluster number is known it should be converted into LSN to access the blocks within

the cluster. Moreover all the information about file management uses the cluster number

rather than the LSN for simplicity and for the purpose of managing large disk space. So

here we devise a formula to convert the cluster number into LSN.

Root User Data

Directory

FAT FAT

Re served Block Clust 2

Blocks for FAT

Converting a Cluster # into Sector

First Block of User Data

No. of entries*32/byte s per block

using the information the above slide the following formula can be devised as shown in

the slide below to convert the cluster number into LSN.

No. of System Area Blocks =

Reserved Block + Sector per FAT * No. of

FAT’s + No. of entries * 32 / Bytes per Block

First User Block No. =

No. of System Area Blocks

Sector No. =

(Clust_no – 2)* Blocks per Clust + First User

Block #

The following memory dump extracts the starting cluster number from the FCB of a file

and then converts the cluster number in sector to get its starting block.

Directory Dump (Again)

-l 1000 0 13 e

-d 1000 2c

13AD:1000 E5 5F 41 4E 53 20 20 20-54 58 54 20 10 BB 19 70 ._ANS TXT ...p 13AD:1010 3C 33 3C 33 00 00 60 05-72 28 02 00 4F 8F 00 00 <3<3...r(..O... 13AD:1020 41 43 00 70 00 61 00 70-00 65 00 0F 00 54 72 00 AC.p.a.p.e...Tr. 13AD:1030 2E 00 74 00 78 00 74 00-00 00 00 00 FF FF FF FF ..t.x.t......... 13AD:1040 43 50 41 50 45 52 20 20-54 58 54 20 00 BB 19 70 CPAPER TXT ...p 13AD:1050 3C 33 3C 33 00 00 60 05-72 28 02 00 4F 8F 00 00 <3<3...r(..O... 13AD:1060 54 45 53 54 20 20 20 20-54 58 54 20 18 AB 29 70 TEST TXT ..)p 13AD:1070 3C 33 3C 33 00 00 AE 70-3C 33 4A 00 31 00 00 00 <3<3...p<3J.1... 13AD:1080 E5 4F 4F 54 20 20 20 20-54 58 54 20 18 4D 4E 70 .OOT TXT. MNp 13AD:1090 3C 33 3C 33 00 00 D5 70-3C 33 4B 00 B3 8A 00 00 <3<3...p<3K..... 13AD:10A0 E5 4F 4F 54 20 20 20 20-54 58 54 20 18 4D 4E 70 .OOT TXT. MNp 13AD:10B0 3C 33 3C 33 00 00 22 71-3C 33 4B 00 26 00 00 00 <3<3.."q<3K.&... 13AD:10C0 52 4F 4F 54 20 20 20 20-54 58 54 20 18 25 55 71 ROOT TXT .%Uq 13AD:10D0 3C 33 3C 33 00 00 56 71-3C 33 4B 00 0D 00 00 00 <3<3..Vq<3K.....

File Contents =

File Cluster # = 4a File Start Sector # = (4a 2 )*1 + 21H = 69H

The contents of the blocks/cluster at the start of file are then examined by loading the

sectors within the first cluster to that file in the following slide. Here the contents of the

file can be seen on the right side column.