Miracle #03
16 июля 1999 |
|
kodit Who's there? - Working with MS-DOS: Ms-Dos floppy disk - a description of the structure of Ms-Dos disk.
(C) Steelzer / Triumph -------------------- The structure of MS-DOS floppies At SPECTRUM'e can safely read discs following Format: -------------------------------------------------- --------- s name. hand ident.bayt capacity lanes sec. in a cluster on the track -------------------------------------------------- --------- D-August 22 # FF 320K 408 S-Aug. 11 # FE 160K 408 D-September 22 # FD 360K 409 S-September 1911 # FC 180K 409 QD-September 22 # F9 720K 809 -------------------------------------------------- --------- Now make no mistake: the name, symbol, where the letter S-single, D-double (side) the numbers 8 or 9-number sektorov on the track, and Q-quality (High density recording, refers to 80 tracks). You can add that there are More formats and D-10 and S-10, but they are so rare that write about their structure is not meaning; sectors in the cluster - - If SPECTRUM'e unit - - The sector is on pisyuke cluster, the cluster size depends the number of parties floppy - If the disk is double-sided, then cluster size is 2 sectors; Identification byte-first entry in FAT'e that I can identify with what we drive dealing with. So, when working with MS-DOS floppy disk, when moving various files profitable high capacity floppy disks, then further will be discussed only two formats: D-9 and QD-9. Forgot to mention about the format of QD-15, but it already unreadable density on normal drive. The structure of the 0th track If we say that disk format, D9-9 sectors, then we should mean by those that TR-DOS understands them as sector 0 .. 8, but as for them there understands iBM - this we must interested in the least. And here's what to know: Sector iBM - at 512 bytes, so read them need only "1! Ie if we need to read the 0th track to do something like this does not should not in any way, as: LD HL, BUFFER LD DE, 0 LD BC, # 0905 CALL # 3D13 Need to read and write only sector-wise! Because Only in this way can record and / or read sector, non-standard length. 0 sector contains the boot record, but the interest is the following information is given in the table below: -------------------------------------------------- --------- offset length description -------------------------------------------------- --------- March 8 byte system ID (word) January 11th floor of the sector size (512 bytes) January 13 byte cluster size January 14 word number of reserved sectors January 16 bytes of the number of copies of the FAT (D9-2, QD9-3) January 17 word number of files in a directory January 19 words total, sec. on the disc (D9-720) January 21 byte code format (see below) January 22 word number of copies of FAT (QD9-3) January 24 word number of sectors per track January 26th floor of the parties floppy January 28th floor of spices. sectors (???) -------------------------------------------------- --------- 3.1 Sector (1 and 2 for D9) FAT. 4.6 Sector (3 and 4 for D9) copy FAT'a. 7.8 Sector (5-8 D9) directory. 1 track: Sector 0-4 (0-2 for D9) extension directory. 8.5 Sector (3-8 for D9) beginning of the data. -------------------------------------------------- --------- Directory. Each entry in the catalog has a 32-byte length. -------------------------------------------------- --------- Displacement OpisanieRazmer (B) Recording Format -------------------------------------------------- --------- 00 File name 8 bytes ASCII characters 08 Name of file type ASCII characters 3 bytes 11 File attributes 1 byte bits (see below) 12 Utility field 10 bytes Not used 22 Time a 2 byte word (see below) 24 Date sozdaniya2 bayta word (see below) 26 The initial cluster of 2-byte word (see below) 28 Size (bytes) 4-byte word (integer). -------------------------------------------------- --------- 1.Imya file. Unused items directory have an initial byte 00. It should be noted that the DOS stops the output directory when meeting 00. If the first byte entry is # E5, it is means that the file is erased. This means that all the clusters assigned to this file marked as free, and if you need a new DOS'u directory entry, it overwrite any information about erased files, and then his recovery will be virtually impossible. And if, as a first byte code appears # 2E (.) it means to us subdirectory. But if the second B # 2E, then this element corresponds to the parent directory of the current and the initial cluster number indicates the parent directory location. 2.Atributy file. -------------------------------------------------- --------- RazryadZnachenie Note -------------------------------------------------- --------- 0 is allowed read-only 1 Invisible 2 System 3 Volume Label 4 Sub-Identifies the subdirectory 5 History floppy useless 07.06 Not used pure -------------------------------------------------- --------- 3.Vremya creation or last modified cation. Time itself is viewed as an unsigned unit, consisting of hours, minutes and seconds to the next formula: Hours * 2048 + Minutes * 32 + Seconds 2 Hours are based on a 24- hour cycle and can vary from 0 to 23. Because two-byte field used recording time for one bit shorter than necessary to store the full value the number of seconds per day, while stored in units equal to two seconds, and the number of such units varies from 0 to 29. 4.Data creation or last modified cation. By themselves, these 2 bytes can be regarded as unsigned word consisting of the year, month and day using the following Claims: (Year-1980) * 512 + Month * 32 + Day While this system may work until 2108, maximum year supported DOS'om equals 2099. 5.Nomer initial cluster. This is 2 bytes, which give number of the initial cluster. He acts as an entry point into the a chain of occupied space files in FAT'e. For files that are not in data area of the initial cluster number is 0. 6.Razmer file. This is 4 bytes giving us length of the file in bytes. After reading this information, all seems to be understood even neprodvinutomu useru and the only thing that has not yet been described, so it is FAT. And so, what it is, and what it eat? FAT (File Allocated Table). All files and subdirectories (Which are very similar data files) are stored in the latest and most a large part of any disk. File is given as much space how much they need one cluster at a time. In many cases, the file occupies a contiguous block of disk space. However, the file can be scattered across the disk, and not necessarily that the end of your text file, for example located after the start. Such The situation is manifested in those Where information added to the existing file, or when it becomes file in place, the remaining after the removal of another file. Such a division is, of course, slows down access to the file, but only in the case When files are fragmented. To monitor the location of the file on disk is a special data area called FAT'om. FAT is 12ti and 16ti bit. The following discussion focuses only on a 12-bit format, because 16 bit is used only on disks where kolichichestvo clusters exceeds 4095 (# FFF). FAT is organized as a table, which can contain up to 4096 numbers range 0 to 4095, which are records for each cluster the data space. The number in each entry indicates the status and use of the cluster, the corresponding this entry FAT. Range numbers in the record may not exceed three HEX digits. If the entry contains a 0, it means that the cluster is free and it can be used. If record contains a # FF7 (4087) and is not part of any distribution chain file then this cluster is marked not in use due to an error in formatting. Clusters consistently numbered from 2 to numbers on one greater than the total number of clusters on the disk. Entries FAT'a contain the number of 2 to 4080 (# FF0), indicating that the corresponding cluster using a file. Value # FFF means that This cluster contains the last part of the file. For that same purpose can be used the number of # FF8 to # FFE. Entry for a file in the directory contains the number of primary cluster, and record FAT'a point to the next used file clusters. When a file is washed, then all recording FAT'e falling into file labeled 0, ie as free, but the actual file data in the field data do not change as remains unchanged big part of the information on file in directory. Although it seems that FAT-simple table of numbers stored it in a rather tricky form. One entry requires 12 bits, or 1.5 bytes, ie for two records used 3 bytes, while the 16-bit FAT'e 4 bytes. The first byte in FAT'e is a code format (See below table), the following 2 bytes are equal to # FF and used. Next come a pair of by 3 bytes. If you going to recode FAT over pairs of records, the better it is done by the following formula: read AB CD EF>>> perekodiruem in DAB and EFC But if you do not want encode a FAT 16-bit a more convenient format, and prefer to read individual recording directly from FAT'a, here algorithm: setting any number cluster, we can find the value of FAT, multiplying the cluster number by 3, then divide the result by 2, and use this number as offset within FAT'a. Taking on obtained at the word, we have 3 HEX digits and write FAT another unnecessary HEX digit. Now discard older number if the cluster number even, and the youngest, if the number odd. As a result, all these operations, we have room next cluster file for excluding the value # FFF, which means that this cluster contains the latest part of the file. In general, if we need to read the file, we look at field recording catalog number primary cluster for this file, read this cluster, Then, look at the table FAT'a next cluster file, read it again and so repeat this procedure until has not yet vsetretim in FAT'e # FFF-hence the cluster for the last FAT. To illustrate an example: At first read, for example only the first sector FAT'a: LD BC, # 0105 LD HL, BUFFER LD DE, # 0101 CALL # 3D13 ... Then, look memory dump Address BUFFER: FD FF FF 03 40 00 05 60 00 07 80 00 09 00 A0 FF FF FF ______/ ______/ ______/ ______/ ______/ ______/ unnecessary clusters ... ... ... ..... title 2-3 4-5 6-7 8-9 10-11 Now look at the title file (before that we should read it): for example file begins with a 2-second cluster; take 3 bytes, which is info on the 2 cluster and perekodiruem him on a previously unknown formula: AB CD EF = DAB EFC: 03 40 00 = 003 004 From this it follows that the next cluster of the file 003 read 2 cluster, then read the third and look into the FAT ... Table ID byte: -------------------------------------------------- --------- ID byte: Format: -------------------------------------------------- --------- # FF D-8 # FE S-8 # FD D-9 # FC S-9 # F9 QD-9 -------------------------------------------------- --------- Unfortunately I have to There are currently no required information on the format S-10, D-10, QD-10, but if anyone is interested please contact address MIRACLE marked 'FOR STEELZER', I will answer you and I'll send all the information in their documentation with examples of working procedures ... -------------------------------------------------- --------- Note: as previously said MS-DOS diskette contains 2 copies FAT'a, but should know that if you changed catalog (write to a file or erased) should be amended as and a copy of FAT'a because some bend to reconcile their pisyukah FAT'y and if they are not equal, then the issue unpleasant messages in your address and refuse to work the floppy ...
Other articles:
Similar articles:
В этот день... 21 November