Comments on coding:
The function integrate() is the actual module of performing the recovery of the user specified file, in this recovery program.
The file name with the destination path to store the recovered file is stored in the character pointer *Filename_with_path. If there is any error in opening the destination file, error message is displayed and user is prompt again to enter the destination.
The function _bios_disk(_DISK_READ, &dinfo); reads the data of the file from the data area of the disk sector by sector, specified by the structure dinfo and stored in the data buffer buf. This data of 512 bytes is written to the destination file. This is repeated until the complete file is integrated.
The function status=verify_the_sector(cylinder,head,sector); verifies the sector to be read. If the status = 10, it represents a bad (0xA) sector. The coding of the function has been given below:
/// Verify the Sector. (No Data is Transferred here) \\\
int verify_the_sector(unsigned int c,unsigned int h,unsigned int s)
{
int status;
char *buf;
union REGS in, out;
struct SREGS sg;
in.h.ah = 0x04; /* Function Number */
in.h.al = 1; /* Number of Sectors to Verify*/
in.h.dl = 0x00; /* Drive Number for A: */
in.h.ch = c; /* Cylinder Number */
in.h.dh = h; /* Head Number */
in.h.cl = s; /* Sector Number */
in.x.bx = FP_OFF(buf);/* Offset */
sg.es = FP_SEG(buf); /* Segment */
int86x(0x13,&in,&out,&sg); /* Call the Function 4H of INT 13H */
if(out.x.cflag)
{
status=out.h.ah;
}
return(status);
}
Comments on Coding:
The function verify_the_sector(), verifies sector to be read by the _bios_disk() function and returns the status of the operation. The function uses INT 13H and function 4H to verify the sector.
*buf is the data buffer, 0x04 is the function number specified by in.h.ah = 0x04; and in.h.al = 1; instructs to verify the one sector at a time. in.h.dl = 0x00; is used for the drive number for floppy drive A:, c,h, and s are Cylinder, Head and Sector numbers.
The function int86x() is used to invoke INT 13H (function 4H) with segment register values. The status of the operation is returned by the integer status.
|