To recover the specified file, the functions calculate() and integrate() are called within the function. The coding of the function calculate() has been given below:
/* Function To calculate the CHS Geomatry For The
Recovery */
void calculate(unsigned int start,unsigned int *cylinder,
unsigned int *head,unsigned int *sector)
{
unsigned int temp;
*cylinder=0;
*head=1;
*sector=14;
if(start<5)
*sector=14+start;
else
{
temp= (start-4)/18;
if(temp>0)
{
if(temp%2==0)
*head=0;
else
*head=1;
*cylinder+=1+temp/2;
}
else
{
*head=0;
*cylinder=1;
}
*sector=(start-4)%18;
}
/// Display The CHS of The File to Be Recovered \\\
gotoxy(10,23);
cprintf("Cylinder = %u, Head = %u, Sector = %u",
*cylinder,*head,*sector);
}
Comments on coding:
The function calculate() is to calculate the Cylinder, Head and Sector information for the file to be recovered. After calculation the Cylinder, Head and Sector numbers are displayed on the screen.
The coding for the function integrate() has been given below:
/* Integrate File and Save the Recovered File To the Specified Path and File name */
void integrate(long unsigned int size, unsigned int cylinder, unsigned int head, unsigned int sector)
{
void clear_the_line(unsigned int);
/* Function to Verify The Sector for Errors */
int verify_the_sector(unsigned int, unsigned int, unsigned int);
int status;
char buf[512],*Filename_with_path;
struct diskinfo_t dinfo;
unsigned int result;
FILE *fp;
unsigned int left,i;
unsigned int sec;
|