ZX Power #02
24 мая 1997 |
|
Likbez - The structure of MS-DOS disk.
The structure of MS-DOS disk. (C) 1997 Digital Man. Special for ZX POWER. ________________________________ I must say that this material prednaznachaetsya for those people who've stuffed a couple of cones on the disc format of the system MS-DOS.Itak all MS-DOS disks organized in the same way. The sector size is always 512 bytes anything else determines the capacity Album: Traci Sector Capacity 320 kb 40 8 360 kb 40 9 720 kb 80 9 In contrast to TR-DOS Disk CDs MS-DOS'a used Special Allocation Table File (File Alloction Table - FAT) for abstraction of disk File and storage space Information about free sectors. For security reasons, to all disks are stored on two copies of FAT. They are stored in sequence starting from 0, track 0, sector 1 (sector 0 is busy writing the boot). The number of sectors allocated for FAT opredelyaetsya disk size (hereinafter referred to as a table through which we can determine Ramer FAT). There are also two types of construction FAT, 12-bit FAT or 16-bit FAT. Here we consider only 12-bit recording. Because 16-bit FAT drives use to fix the AT since they clusters of more than 4096. FAT stores information about each cluster of sectors on the disk. Cluster - a group of standard sectors depletion heads read / write, and because at 5'25 inch drives RAMER only two head the size of the cluster is two sectors (the exceptions are one-sided disk drives, which are sometimes found on computers). An example of the announcement is FAT on the disk size 720 kb: 0 Boot Sector Table 1.6 announcement is file 9.7 Root Note: it must be remembered that the FAT is stored on disk two copies! Each position in the file allocation table corresponds to a specific position in the cluster disk. Typically, the file takes a few clusters and the directory entry contains the number of seed clusters, which kept a piece of the file. Then on offset launch a cluster of FAT number is taken sleduyushego cluster, which in turn contains a number of the next cluster in the chain (Fig. 1). For the last cluster occupied by the file, FAT has values of # FF8 to # FFF. Free clusters is equal to the value of # 000, and defective sectors # FF7. Znachenioya from # FF0 # FF7 attributed to the standby cluster. Number of cluster contains 3 hexadecimal digits, which is necessary to store 1 1 / 2 bytes. To reduce the size FAT numbers for the two neighboring clusters are stored in three consecutive bytes table. The first three bytes of the FAT is not used for cluster numbers. The first byte contains the type of disk, and the next two bytes are # FF.Poskolku these positions are occupied, the clusters are numbered starting with 2, and cluster 2 and 3 is a second three bytes table. Code Type Disk # FF double-sided, 8 sectors # FE-sided, 8 sectors # FD double-sided, 9 sectors # FC-sided, 9 sectors # F9 double-sided, 15 sectors When you work with the FAT must comply with those rules: To find sleduyushego cluster file: 1.Umnozhte cluster number to 1.5. 2.Prochitayte 2 bytes with the received nym shift (rounding down). 3.If the cluster number is even, then Take the lower 12 bits, otherwise Take the older 12-bit. To convert the numbers cluster in the physical position on the disk requires the following calculation: 1.Umnozhte result by the number sectors in the cluster (usually 2) 2.Rezultat divide by the number of sectors in the track, thereby to luchite track and in balance sec torus. Certainly easier, and better do it all on the table ne rescheta. Now let's consider disk directory structure. But for early to determine with any just drive we are working to analyze 0 sectors as follows: See Length Description # 03 8bayt system type # 0B 1slovo Number of bytes in the sects. # 0D 1bayt sectors per cluster # 0E 1slovo length BOOT sector # 10 1bayt Number of FAT copies # 11 1slovo Number of Files # 13 1slovo total number of sectors. # 15 1bayt - # 16 1slovo number of sectors of FAT # 18 1slovo Sectors per track # 1A 1slovo Parties # 1C 1slovo number of hidden sects. Directory itself is located just behind a copy of FAT. Write it divided into 8 parts: See Length of Meaning # 00 8-byte file name # 08 3 bytes Expansion # 0B 1 byte attribute # 0C 10bayt Reserved # 16 2-byte time # 18 2 bytes Date # 1A 2 bytes Nach.nomer cluster # 1C 4-byte size Offset # 00 and # 08: Name and file extension normal ASCII text, which does not require explanations. But when creating a file or rename it desirable not to include spaces and special characters, and the remaining place in the record file name and extension to fill gaps. Offset # 0B: The file attribute is as follows: Bit Value 76543210 ....... 1 File is read only. ...... 1. Hidden file ..... 1 .. System file .... 1 ... Volume Label ... 1 .... Subdirectory .. 1 ..... Archive .1 ...... - 1 ....... - Subfolder (directory) is stored on disk as a file. Format of its entries is identical to format records the root directory. Only the number of entries it depends on the availability of free disk space. Offset # 0C: Reserved. Offset # 16: Time = (hours * 2048) + (Min * 32) + + (Second + 2). Offset # 18: Date = (Year - 1980) * 512) + + (Month * 32) + day. Offset # 1A: Starting a cluster file. Offset # 1C: File size. In this record Added unsigned long in 4 bytes (most significant byte comes first). Thus file can have a pretty large size: 42946967295 bytes. Perhaps this is possible and complete the theory and show the principle of File read and decode FAT. Reading from a file: Directory entry The name of the Extended Home Cluster File MUSIC MOD 0003 reading Reading Reading FAT 002 005 000 008 000 FF7 FFF 2 3 4 5 6 7 8 By reading podrozumevaetsya reading cluster from the disk. Decoding FAT: ORG # 8000; top # 8000 LD HL, BUF; download FAT LD B, 4; to clipboard LD DE, 1 CALL LOAD LD DE, BUF LD HL, 3, in HL Room PUSH HL; cluster LD B, H; HL -> STEK LD C, L; HL -> BC AND A; BC / 2 RR B RR C ADD HL, HL; HL * 2 ADD HL, BC; HL + BC ADD HL, DE; HL + BUF LD D, (HL); D <- (HL) INC HL LD E, (HL); E <- (HL +1) POP HL BIT 0, L; check JR NZ, ODD; parity LD A, # 0F; care if so AND H LD H, A JR CONT ODD LD B, 4; shift in LOOP AND A; the right to RR H; a 16-th RR L; figure DJNZ LOOP; number of HL CONT. ; Sleduyushego . ; Cluster . RET LOAD PUSH HL; reading PUSH BC; sectors LD C, 5; drive MS-DOS CALL # 3D13; B-length POP BC; HL-where POP HL; DE-tr./sek. INC H LD A, E CP 9; count JR C, NET; sectors INC D; track LD E, 0 NET DJNZ LOAD RET BUF DEFS 4096; allot ; Place 4 sectors Well, perhaps all! And yet Try following the write operation file, first check the correctness of the changes FAT, and then perekopirovat FAT in reserve. ________________________________
Other articles:
Similar articles:
В этот день... 21 November