Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Disk Utilities-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: Disk, Utility, Include, Signed, Char, Int, Quick, Format, Partition

Typology: Study notes

2011/2012

Uploaded on 08/07/2012

anishay
anishay 🇮🇳

4.2

(25)

121 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Disk Utilities-System Programming-Lecture Notes and more Study notes System Programming in PDF only on Docsity! Lecture # 41 #include <stdio.h> #include <dos.h> #include <bios.h> #include <alloc.h> typedef struct tagfcb { unsigned char filename [8]; unsigned char ext[3]; unsigned char attrib; unsigned char reserved [10]; unsigned int time,date; unsigned int firstcluster; unsigned long int size; }FCB; typedef struct tagBPB { unsigned int bytespersec; unsigned char secperclust; unsigned int reservedsecs; unsigned char fats; unsigned int rootdirents; unsigned int smallsecs; unsigned char media; unsigned int fatsecs; unsigned int secspertrack; unsigned int heads; unsigned long int hiddensecs; unsigned long int hugesecs; unsigned char driveno; unsigned char reserved; unsigned char bootsignature; unsigned long int volumeid; unsigned char volumelabel[11]; unsigned char filesystem[8]; }BPB; struct bootblock { unsigned char jumpinst[3]; unsigned char osname[8]; BPB bpb; unsigned char code[448]; }; docsity.com DPB far * getdpb(int drive) { DPB far *dpb=(DPB far *)0; _asm push ds; _asm mov ah,0x32 _asm mov dl,byte ptr drive; _asm mov dx,ds; _asm int 0x21; _asm pop ds _asm cmp al,0xff _asm je finish _asm mov word ptr dpb+2,dx _asm mov word ptr dpb,bx return dpb; finish: return ((DPB far *)(0)); } void main (void) { unsigned char filename[9]; struct bootblock bb; unsigned char ext[4]; FCB * dirbuffer; unsigned int * FAT; DPB d; DPB far * dpbptr; int i,flag; unsigned int cluster; puts("Enter filename:"); gets (filename); puts("Enter Extension"); gets(ext); if ((absread(0x05,1,0,&bb))==0) puts ("Success"); else{ puts("Failure"); exit(0); } docsity.com Scan Disk Surface Scan for Bad Sectors • It attempts to write a block. • After write it reads back the block contents. • Performs the CRC test on data read back. • If there is an error then the data on that block is not stable the cluster of that block should be marked bad. • The cluster is marked bad by placing the appropriate code for bad cluster so that they may not be allocated to any file. Lost Chains • The disk scanning software may also look for lost chains. • Lost chains are chains in FAT which apparently don’t belong to any file. • They may occur due to some error in the system like power failure during deletion process. docsity.com Looking for Lost Chains • For each file entry in the directory structure its chain in FAT is traversed. • All the cluster in the file are marked. • When done with all the files and folders, if some non-zero and non-reserved clusters are left then they belong to some lost chains. • The lost chains are firstly discretely identified and then each chain can either be restored to newly named files or can be deleted. Cross References • If a cluster lie in more than one file chain, then its said to be Cross Referenced. • Cross references can pose great problems. • Cross references can be detected easily by traversing through the chain of all files and marking the cluster # during traversal. • If a cluster is referenced more than once then it indicates a cross reference. • To solve the problem only one reference should be maintained. 7 14 EOF 9 7 53 5 7 11 13 14 docsity.com Defragmenter • Disk fragmentation is unwanted. • Fragmentation means that clusters of a same file are not contiguously placed, rather they are far apart, increasing seek time hence access time. • So its desirable that files clusters may be placed contiguously, this can be done by compaction or defragmentation. • Defragmentation Software reserves space for each file in contiguous block by moving the data in clusters and readjusting. • As a result of defragmentation the FAT entries will change and data will move from one cluster to other localized cluster to reduce seek time. • Defragmentation has high computation cost and thus cannot be performed frequently. File Restoration • FAT structure provides the possibility of recovering a file after deletion, if its clusters were contiguous and have not been over-written. • DOS perform file deletion by placing 0xE5 at the first byte of it FCB entry and placing 0’s (meaning available) in the entries for the file clusters in the FAT. • Two task should be performed successfully to undelete a file -- Replacing the 0xE5 entry in FCB by a valid file name character. -- placing the appropriate values in FAT for representation of file cluster chain. • If any one of the above cannot be done then the file cannot be fully recovered. docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved