Virtual Worlds #01
31 декабря 1999 |
|
Technical assistance - Dos Review: material on the format of the disk operating system IS-DOS.
DOS REVIEW # 00 (C) Nuts So said a series of articles, written Nuts'om in which describes the different Farmat DOS (disk operating system). Here all is you wanted to know about disk formats, but did not know who ask. Now NUTS incur any nonsense about it as well and much another. Long or a short is, but because of that is very far away if, as does not take a computer and a him every time a new disk format. MICROSOFT can only praise for what she unify disk format uymy for such computers. She also does not stint on the information, and if zhmotnichala, it quickly split the brave hackers. And do not whine that there, in the "Microsoft country", the poor nick die without life-giving information flow. Well, if anyone should all chew and put your mouth, please. Much more complicated to deal with other foreign, as well, and domestic systems. If say about the SPECA already spoken a lot, and described a lot, and He left a bunch of foreign periphery, as software nemeryannom under different operating systems, and that much only now comes to remote areas, well and some of which there are only names: any there OPUS, D80, etc., etc. What can we say about the other machines on which someone had never heard, and someone they are lying bestolku. And then, you see, and the them and the software been written by WHO and small truck, and the people of the heap Profile Views and soldered. In short, there chtoto ALIVE FOREVER. And you can long breeding pleasant tarybary that RULES, and that - MUST DIE. All this because, that netushki reliable spravochki that there is and how it is faring. We start all the same with MS-DOS ... Attempts to talk about this OS were, and software to work with this thing written a lot, since more with god know how long. But say, I personally do not pinned none of these tricks. All it is somehow specialized for certain area, often flexibility in working with different varieties of discs, as a rule, only MS -> TR & Design at 1985 There is, of course, and a very pleasant exception, and much is being done, but the fact remains. In general, I personally decided to delve into the literature, scout situation and provide all polzitelnoe Fiction. Decided it was still a long long time, and the case was almost done TIME KEEPER'om, so, too, because people do not sit still, they write a word, copying. To begin with, that all the disk parameters are stored in the 0th sector 0th track. Only thing that the amount of information built up with the versions MS-DOS, and only the fourth version You can learn all about the drive. But because the formatter FLOPPY FORMAT Ivan Roshchina formats CDs and records at this, so called BOOT-sector is the same, that itself MS-DOS, then forget about this problem and get back to the contents of this sector are help table: OFFSET LENGTH OF APPOINTMENT 0 3 team moving to bootloader code. March 8 program name-formatter. 0b 2 Length in bytes of the sector. 0d a number of sectors per cluster. 0e 2 Number of reserved sectors (from since the beginning of the disk) October 1 Number of FAT. February 11 Maximum number of files in root directory. February 13 Total number of sectors on the disk. Jan. 15-byte descriptor type of disc. February 16 number of sectors in one FAT. February 18 number of sectors per track. > DOS 3.0 1a 2 Number of heads on the disk. 1c 2 Number of hidden sectors. April 20 If the drive> 32MB, then its size sectors are already here. > DOS 4.0 24 January Number disc (HDD only) - number in the BIOS. January 25 Reserve. January 26 signature expansion of the sector, ie only wrote that DOS 4.0 and above, contains this # 29 April 27 Serial number - written during formatting disc contains a unique number and date November 26 Name the disk. August 26 Contains "FAT12" or "FAT16". What do these numbers mean ... In the beginning I will say that I will studiously silent about the work with the hard disk. This is not because I, for whatever reasons, I want to hide. On the contrary, The situation with the hard drive is very instructive to install it under other systems, but much more difficult to describe it in the review of the diskette formats - there because you and the problem of increasing the volume, and the main boot partition with the possibility of placing several operating systems, and a bunch of formats when working with packed Disk ... For a start - a little theory. Operating systems for the most part do not operate with sectors and tracks, and with shifts in absolute sectors. T. is, the concept of "track" that is practically not used, but there are a lot of sectors, ranging from zero and to a certain end, maybe one hundred thousandth. If, say, 10 sectors on the disk on the same logical path, starting from zero, then zero logical path is to be the sector with the 0-th to ninth on the First logical path from the 10 th on the 19th and so on. Moreover, to limit the number of bits that specify the number absolute sector, the entire disc divided into blocks of several sectors. Moreover, the zero unit can be located and not in the beginning of the disk and start with kakogolibo absolute sector. The first sector are precisely loading and information. In MS-DOS, such blocks are called clusters. Number of sectors per one cluster, you can learn from the boot sector. Number of logical sector, which is zero cluster, we have calculated based on data from boot sector, but this later. Such a breakdown is tricky to always be aware of free disk space, and various pieces of one file to record in different areas of the disk, wherever possible, and collect it, even if it is not in consecutive sectors. Therefore, it may not particularly care about cleaning the disc from the remote files. To know the location of each piece file, the table is FAT. Each element, starting with the first, contains a reference on the element of this table, where extends the file number cluster which corresponds to that element table, which contains a link to this file. Then Thus, if we have learned that the beginning file is, say, the fifth cluster, we load it and look at the fifth element Table FAT. And there, it means that Suppose the number 25. Well, then we quietly read the 25th cluster and Consider the 25th entry in the table. A He points to the number of the next cluster (he number of the next element in the table), or that this cluster is the last for this file, and more did not read right. It can also indicate that this sector is free or marked as defective. The only problem is that the disks, the size of one element is 12 bits (half byte) and half of each 2-nd byte refer to the previous one byte, and another - to the next. To determine the content of the table must be multiplied This cluster number by 1.5, we shift to a couple of bytes in the table, which contains the next cluster. If previous cluster had the odd number (determined by zero bat in the room of the cluster), we have to use 12 bits this pair, or - 12 seniors. If the resulting value is 0, then this cluster is free. If # FF8 - # FFF, then this is the last cluster of the file. # FF0 - # FF7 - the reserved sector, including # FF7 - the failed cluster. Only the 0th element of this table is no exception. He contains a copy of the descriptor byte this disc. For example, for disks, which can be read on the Spectrum: Byte: Type of drive: # F9 3'5 720 kb 2SD 9_SEC 80_TRKS # Fa 5'25 320 kb 1SD 8_SEC 80_TRKS # Fb 5'25 640 kb 2SD 8_SEC 80_TRKS # Fc 5'25 180 kb 1SD 9_SEC 40_TRKS # Fd 5'25 360 kb 2SD 9_SEC 40_TRKS # Fe 5'25 160 kb 1SD 8_SEC 40_TRKS # Ff 5'25 320 kb 2SD 8_SEC 40_TRKS But these bytes are many other discs, including those not with a standard breakdown. In fact, in these baytahopisatelyah type used only the low 3 bits, and senior bits are always zero. In this byte: 0th bit: 1 - two 0 - unilateral First bit: 1 - 8 of sects. at Dor. 0 - not 8 Second bit: 1 - constant, 0 - Removable Disk To determine the start of FAT, in boot sector indicated number of reserved and boot sectors. Ibid You can find number of tables FAT - for reliability make multiple copies. It is easy to be calculate the total number of employees at the beginning of the disk sectors and determine the one on which begins 0th cluster. The first two clusters always takes root, and maximum number of files in It is determined by the size of the clusters. But this number is contained and in the boot sector, and to determine the size of the catalog in sectors have to divide the it to 16. The root directory is always present on the disk. It contains information about files and first level of subdirectories. Recent represent a ordinary files, but with zero length, and their size is determined on the table FAT, and they can be segmented, ie, the scattered across the disk. At the beginning of each subdirectory is the descriptors 2 Files. " and "..". The first repeats the description of this directory catalog at a lower level and duplicated information on this directory. The second contains a description of the earliest katalogapraroditelya. Both of them are used for easy navigation through a disc. If catalog-grandparent is in the zero cluster, then it root directory. In this directory of links available, but if boot disk, there are descriptors of system files. Descriptor of any file or directory occupies 32 bytes of data: Displacement: FUNCTION: 0-7 file or directory name, big letters, the remainder fill the gap. If the 0th byte is equal to the file # E5 removed if the # 05 first letter of the code file indeed # E5. If 0 - a place of never used - the end of the catalog. 8.10 Expansion. 11 File attributes. Bits: 0 - Read-only 1 - hidden file 2 - file system, and 3 - the name of the disk first 11-bytes, only the root directory, primary sector and the length is not 4 - subdirectory does not use a length field, 5 - archive file archived it for safety or not. 12-21 are reserved. 22-23 Time of creation or last correction file contains both 16-bit word: bits 11/15 - Hours Bits 10-5 - minutes, bits 4-0 seconds / 2. 24-25 Date file creation or last correction contains both 16-bit word: bits 9.15 - Year since 1980, and ending with 2099 bits (!!!); 5.8 - month, bits 4-0 - day. 26-27 Number of the first cluster file, starting with the youngest bytes. The first two clusters takes root directory and all files beginning with the second cluster. 28-31 File size in bytes. The first pair of bytes contains lower level values, both pairs of bytes starting with Low Byte. Total length may reach up to 4 GB, well used to the format 830KB 20-bit - Max. That's all we need to work with the disk. To move from room cluster to the absolute sector must be added to the cluster number, multiplied by two, shift to no cluster in the absolute sector. Then obtained number needed to divide the number of sectors per track. In result is logical track, where the cluster and balance - a sector. I note In most I've seen literature, it is proposed that root directory (ie, the very first few clusters) not seem to be and not clusters, and introduce the concept of early data - Following the cluster catalog is kind of like a zero, well and, therefore, all rates clusters are of him at assistance priplyusoaniya-minusovaniya directory size. In short, only extra computation. In my view, if the directory is in a zero cluster, and it should considered as the origin of data, not for something special. It remains only to say that sometimes is just not enough to overtake the file on a Spectrum if it is in the format HOBETA (extension begins with "$"), SCL-format (the program AMD) or the file could contain the image of Spectrum Drive - ". TRD" and ". FDI". To do this, be aware of Format these files. Now we'll discuss the IS-DOS. As the program FLOPPY FORMAT Ivan Roshchina, this DOS supports eight breakdowns disk, which may very much differ from each other, because the sector size can be as 256 and 1024 bytes (the running drive.) Number sectors at the same time will be 16 or 5 respectively. Disk, there may be as unilateral or bilateral. Attention should be given the order sectors per track. Since disk can be avtozapuskaemym then, though them and is on 5 sectors per track, the last of them has the number 9. Now consider the structure disc. Her description is disk assembler IS-DOS. But It is designed for programmers working directly in This DOS. Here I will explain the basic facts of this description. "Inside" IS-DOS absolutely EVERYTHING storage device represented by a set of blocks 256 bytes of each numbered from 0 up to a certain maximum. The position of any file and generally any desired location on the disk given offset beginning of the disc - the 0-th block. AND measured this shift in these same blocks of 256 bytes. That is not so important a sector size - for determine the track and sector You can use the following formulas: DOR. = INT (SMESCH. / 5120) (Or 4096) CERT .= INT ((see-DOR .* 5120) / 1024) (4096 256) A remnant of the difference between shift to the sector and offset to give us the desired block offset within the 1024-byte sector. 0th block - this is the 0th 0th sector of the track. It contains: OFFSET LENGTH OF APPOINTMENT 0 2 Reserve August 2 The device name (disk) March 10 Symptom IS-DOS: "DSK" As it can be determined membership drive in the system. May 13 Reserve Feb. 18 Volume in drive units February 20 number of 0-th block of the master directory. For CDs 80TR/DS usually the third, ie same 0th sector for 1024 byte sectors. Or third - for 256 byte. January 22 The number of cylinders on the device - Is for the HDD. January 23 Disc Type - bits (0 / 1): 0th - 40/80 tracks 1st - 1 / 2 part. January 24 Sector Size: 1/2/4: 256/512/1024 bytes January 25 The number of sectors per track. January 26 Reserve January 27 Checksum file ????_ dos.sys This is something like MAGICK'a - a copy of a computer's memory system. Loaded and unloaded it special programs, and its parameters are stored in a special place. ?? - Any four characters. February 28 Reserve Feb. 30 date (what??) 32 32 descriptor ????_ dos.sys See above. 64 16 Table number of sectors. First block contains a bit-map device: each bit corresponds to its own block on the device - 1 bit / block 0-free 1-busy Such a table - bit Map drive - often used in different operating systems. Now let's talk about the files and directories. We already know where main directory. It is useful to remember that the files in the IS-DOS are not only segmented as in MS-DOS, but continuous, as in TR-DOS. Ie file can be scattered pieces-on segments the entire disk for a long time to boot and restore it after entry in the directory of it will be spoiled, extremely difficult. But worries about cleaning the disc from deleted files is almost gone. Also, the file may be continuous, loaded quickly, but problems with command MOVE, or more precisely, SQUEEZE (so it it is called in to HOBET'e HRC), all spektrumschikam (if they do not work under the emulator). However, according to some reports, the problem is solvable (See below), but - so far unknown. Most (all?) converters IBM <> ZX work on the principle of a conditional sequence of sectors the file, and if you write a converter IS <> TR, then You can make this file and non-segmented, but for the sake of completeness is necessary to tell how the system IS-DOS collects segments of its files disc. So, in a directory handle this file contains a link not on the initial block file as per se, but a reference to a particular block - Sector File Allocation Table, or, as it is called in the company description, block descriptor file segments. 0th to byte contains the number of file segments - how many pieces he defeated. The remaining 255 bytes contains 85 three-byte records each of which describes a file segment. The first two bytes each contain the number zero block of the segment, well, the third - the number of blocks in the segment. And to read the file you want must first define the beginning this descriptor, then consider him. Then looping through the number of segments. On the first two bytes of each three determined by the beginning of the substantive segment and the ordinary way read sequence blocks containing sectors of the segment. If necessary, take care to exclude unwanted residues of the first and latter sectors. For the last block of this can be done simple manipulation with the address loading the next segment. A Here's the first tricky. Have to do move the team LDIR or read the sector in the intermediate buffer. But in any case, size of 1024 bytes will have to consider. To save the files have also disturb the bitmap disc. We must look for unoccupied blocks - their corresponding bits will be cleared. Need to install it, then fill out the appropriate record in the block descriptor, or add blocks to an old record. Make these operations better RAM. Catalogues, oddly enough, represent a nearly normal files, but they have two descriptors: the external, in katalogeroditele, and internal, it itself. At the main directory is only the inner handle - its 0th file. It is in the inner descriptor contains information about the number of files and level of nesting. In addition, record of the file / directory contains the determining a label showing the ownership of the file to a particular group (see below). It should also be aware of the constraints: number of files in a directory - to 128, the nesting level - to 6. Catalogue can also be segmented or non-segmented. Now more about the structure file descriptor. Note that in describing the structure of records Internal handle directory I have not made everything clear. OFFSET LENGTH DESCRIPTION 0 8 Filename August 3 File Type January 11 status register file bit (0 / 1): 0 - deleted / a 2 - is protected against reading (1) 3 - write-protected (1) 4 - Visible / hidden file 5 - file / directory (root) file 6 - segmented / non-segmented 7 - protected from removal (1) February 12 address the default boot March 14 Length February 17 number Block descriptor segment, or 0-th block file - if the file is continuous January 19 "Special" June 20th Reserve February 26 checksum of file February 28th Time February 30 Date Date and time are encoded in MS-DOS. Checksum, possibly, too. That is what is known about the inner handle (use the 23 bytes): OFFSET LENGTH DESCRIPTION 0 8 The name of the current directory March 8 Its type (gaps) January 11 CSR (???) directory February 12 CBNN (like the initial block) directory - progenitor February 14 Directory size (bytes) January 16 nesting level directory. February 17 number block descriptor segment. (It's interesting. The catalog can be continuous, then there perhaps number of first block. But then definition of CSR should be the status bits) February 19 number of 0-th block directory (This is then what?) January 21 Total number of files (Including the directory itself and remote) January 22 The number of files (Pure free catalog, well, remote) Well, with the IS-DOS understood.
Other articles:
Similar articles:
В этот день... 21 November