The format of the disk can be divided into low-level formatting and advanced formatting. Low-level formatting is for hard drives, which can clear all the data in the hard disk, including the main boot record of the hard disk, DOS boot record, and partition table information, of course, can also remove all viruses that are hidden by the disk. The older version of the CMOS setting includes hard disk low formatting programs, which can use some low-grade software such as DM, etc. in CMOS. There are several forms of advanced formatting of disks. It is rapidly formatted. The basic format program published with DOS allows users to quickly format (optional parameters / q) for disks (optional parameters / q). Before introducing the rapid formatting, first make a simple introduction to the structure of the disk, and then make a comparison of rapid formatting and general advanced formatting. A successful high-level hard disk can be divided into the following sections: main boot record and partition table information, DOS boot record, file allocation table (FAT) information, root directory (root) information, and data area. The main boot record and partition table information stores in the first sector of the hard disk, and the main boot record can be written according to the different operating system. Based on this feature, it is not a difficult thing to implement multiple operating systems. The partition table is the last 64 bytes in the first sector of the hard disk, corresponding to the start and end flags of "80h" and "55aah". It records information such as the number, start and end of the hard disk logic area, where "80h" and "55aah" are called two critical code of the hard disk, and the hard disk will not be booted after the loss is lost. The DOS boot record saves the description of the three files of the boot system, which also includes a partition table information. The file allocation table and root directory information records the name, attribute, etc. of the file, and the address of the stored address. When positioning, combined with the assignment table information and root directory information, it can easily find the file. The data area is a part of the upper part of the hard disk, which is used to save file data. Let's take a look at the process of file deletion: Modify the file allocation table, change the first character of the file name and release the disk space. It must be noted that the content stored in the data area is not deleted, so the deleted file can be recovered. In contrast, the advanced formatting of the disk mainly does the following: the disk is divided into the track and sector, write boot information to the main boot area and the DOS boot area, empty the file allocation table and root directory area and scan the track. However, rapid formatting is different, and it does not perform track scans, so fast formatting and completely deleting disk files are the same. Compared with the structure of the hard disk, there is no main guidance area in the floppy disk. Advanced formatting is also four things to do in the floppy, but for the format command, before performing the operation, the file allocation table, the content of the root area is saved to the last few sectors of the disk, so As a result, the floppy disk data can be recovered back by "reverse formatting" operation (as long as the data area is not covered). Given the 1.44MB 3.5-inch floppy disk FAT zone and root directory area The number of sector is constant (FAT1: Sector 1-9; FAT2: Sector 10-18; root: Sector 19-32), we can practice Write a fast formatting program to implement the rapid formatting of the 1.44MB 3.5-inch floppy disk. Since the program is simple, unformat information is not saved, the data cannot be restored after formatting, so it should be particularly careful when experimentation.
We can use the C language library function AbsWrite to implement fast format because it is defined in the dos.h header file, so the program should be written on: #include
Main () {Int i; char C; Printf ("/ nquick format 1.44MB / n"); Printf ("Program by chenqing./n" ;printf (" All Data IN the floppy disk will be lost !! / N "); Printf (" / Ninsert a Diskette for Drive A: / N "); Printf (" and press Enter when ready. "); c = getchar (); Printf (" / n / ncleaning fat area. "); Buff [0] = 0xF0; buff [1] = buff [2] = 0xff; for (i = 3; i <512; i ) buff [i] = 0; Abswrite (0, 1, 1 , BUFF); AbSwrite (0, 1, 10, buff); for (i = 0; i <512; i ) buff [I] = 0; for (i = 2; i <10; i ) Abswrite (0, 1, I, buff); for (i = 11; i <19; i ) Abswrite (0, 1, I, buff); Printf ("/ ncleaning root area........................................................ <33; i ) Abswrite (0, 1, I, BUFF); Printf ("/ n / nquickformat completed! / N");}