Technical Reference
Total Page:16
File Type:pdf, Size:1020Kb
AmigaDOS Technical Reference Manual AmigaDOS Technical Reference Manual Table of Contents 1.1 AmigaDOS File Structure 1.1.1 Root Block 1.1.2 User Directory Blocks 1.1.3 File Header Block 1.1.4 File List Block 1.1.5 Data Block 1.2 DISKED - The Disk Editor AmigaDOS Technical Reference Manual Filing System 1.1 AmigaDOS File Structure The AmigaDOS file handler uses a disk that is formatted with blocks of equal size. It provides an indefinitely deep hierarchy of directories, where each directory may contain other directories and files, or just files. The structure is a pure tree - that is, loops are not allowed. There is sufficient redundancy in the mechanism to allow you to patch together most, if not all, of the contents of a disk after a serious hardware error, for example. To patch the contents of a disk, you use the DISKED command. For further details on the syntax of DISKED, see section 1.2, "DISKED - The Disk Editor," later in this chapter. Before you can patch together the contents a disk, you must understand the layout. The subsections below describe the layout of disk pages. 1.1.1 Root Block The root of the tree is the Root Block, which is at a fixed place on the disk. The root is like any other directory, except that it has no parent, and its secondary type is different. AmigaDOS stores the name of the disk volume in the name field of the root block. Each filing system block contains a checksum, where the sum (ignoring overflow) of all the words in the block is zero. The figure on the following page describes the layout of the root block. 1-1 Filing System AmigaDOS Technical Reference Manual 0 | T.SHORT | Type 1 1 o I Header key (always zero) 2 1 o | Highest seq number (always zero) 3 | HT SIZE | Hashtable size (= blocksize-56) 4 0 | 5 CHECKSUM | 6 hash j table | / / \ \ SIZE-51 SIZE-50 | BMFLAG j TRUE if Bitmap on disk is valid SIZE-49 Bitmap | Used to indicate the blocks pages | containing the bitmap SIZE-24 SIZE-23 DAYS | Volume last altered date and time SIZE-22 MINS | SIZE-21 TICKS | SIZE-20 DISK | Volume name as a BCPL string NAME j of <= 30 characters SIZE-7 CREATEDAYS | Volume creation date and time SIZE-6 CREATEMINS | SIZE-5 CREATETICKS| SIZE-4 o 1 Next entry on this hash chain (always zero) SIZE-3 0 1 Parent directory (always zero) SIZE-2 o 1 Extension (always zero) SIZE-1 ST.ROOT | Secondary type indicates root block j Figure 1-A: Root Block 1-2 AmigaDOS Technical Reference Manual Filing System 1.1.2 User Directory Blocks The following figure describes the layout of the contents of a user directory block. 0 | T.SHORT | Type 1 OWN KEY | Header key (pointer to self) 2 0 | Highest seq number (always zero) 3 o 1 4 o 1 5 CHECKSUM | 1 — - — 1 6 1 hash | table j / / \ \ SIZE-51 SIZE-50 Spare | SIZE-48 PROTECT | Protection bits SIZE-47 o Unused (always zero) SIZE-46 COMMENT j Stored as a BCPL string SIZE-24 SIZE-23 DAYS | Creation date and time SIZE-22 MINS j SIZE-21 TICKS | SIZE-20 DIRECTORY | Stored as a BCPL string NAME j of <= 30 characters SIZE-4 HASHCHAIN | Next entry with same hash value SIZE-3 PARENT | Back pointer to parent directory SIZE-2 1 o Extension (always zero) SIZE-1 ST.USERDIR j secondary type Figure 1-B: User Directory Blocks 1-3 Filing System AmigaDOS Technical Reference Manual User directory blocks have type T.SHORT and secondary type ST.USERDIRECTORY. The six information words at the start of the block also indicate the block's own key (that is, the block number) as a consistency check and the size of the hash table. The 50 information words at the end of the block contain the date and time of creation, the name of the directory, a pointer to the next file or directory on the hash chain, and a pointer to the directory above. To find a file or sub-directory, you must first apply a hash function to its name. This hash function yields an offset in the hash table, which is the key of the first block on a chain linking those with the same hash value (or zero, if there are none). AmigaDOS reads the block with this key and compares the name of the block with the required name. If the names do not match, it reads the next block on the chain, and so on. 1-4 AmigaDOS Technical Reference Manual Filing System 1.1.3 File Header Block The following figure describes the layout of the file header block. h + 0 T.SHORT | Type 1 OWN KEY | Header key 2 HIGHEST SEQ| Total number of data blocks in file 3 DATA SIZE | Number of data block slots used 4 FIRST DATA| First data block 5 CHECKSUM | 6 \ \ DATA BLK 3| DATA BLK 2| list of data block keys SIZE-51 DATA BLK l| SIZE-50 Spare | SIZE-48 PROTECT | Protection bits SIZE-47 BYTESIZE | Total size of file in bytes SIZE-46 COMMENT | Comment as BCPL string SIZE-24 SIZE-23 DAYS | Creation date and time SIZE-22 MINS | SIZE-21 TICKS | SIZE-20 | FILE | Stored as a BCPL string | NAME | of <= 30 characters SIZE-4 | HASHCHAIN | Next entry with same hash value SIZE-3 PARENT | Back pointer to parent directory SIZE-2 EXTENSION | Zero or pointer to first extension block SIZE-1 ST.FILE | Secondary type h + Figure 1-C: File Header Block 1-5 Filing System AmigaDOS Technical Reference Manual Each terminal file starts with a file header block, which has type T.SHORT and secondary type ST.FILE. The start and end of the block contain name, time, and redundancy information similar to that in a directory block. The body of the file consists of Data blocks with sequence numbers from 1 upwards. AmigaDOS stores the addresses of these blocks in consecutive words downwards from offset size-51 in the block. In general, AmigaDOS does not use all the space for this list and the last data block is not full. 1.1.4 File List Block If there are more blocks in the file than can be specified in the block list, then the EXTENSION field is non-zero and points to another disk block which contains a further data block list. The following figure explains the structure of the file list block. 0 T.LIST | Type 1 OWN KEY Header key 2 BLOCK COUNT = number of data blocks in block list 3 DATA SIZE Same as above 4 FIRST DATA| First data block 1 5 CHECKSUM | 1 — 6 \ \ BLOCK N+3 | BLOCK N+2 Extended list of data block keys SIZE-51 BLOCK N+l SIZE-50 info (unused) SIZE-4 o Next in hash list (always zero) SIZE-3 PARENT File header block of this file SIZE-2 EXTENSION Next extension block SIZE-1 ST.FILE secondary type Figure ID: File List Block There are as many file extension blocks as required to list the data blocks that make up the file. The layout of the block is very similar to that of a file header block, except that the type is different and the date and filename fields are not used. 1-6 AmigaDOS Technical Reference Manual Filing System 1.1.5 Data Block The following figure explains the layout of a data block. 0 T.DATA | type _ 1 1 HEADER | header key __ 1 2 SEQ NUM | sequence number — 1 3 DATA SIZE | 4 NEXT DATA | next data block 5 CHECKSUM | 6 DATA Figure IE: Data Block Data blocks contain only six words of filing system information. These six words refer to the following: o type (T.DATA) o pointer to the file header block o sequence number of the data block o number of words of data o pointer to the next data block o checksum Normally, all data blocks except the last are full (that is, they have a size = blocksize-6). The last data block has a forward pointer of zero. 1-7 Filing System AmigaDOS Technical Reference Manual 1.2 DISKED - The Disk Editor To inspect or patch disk blocks, you may use the AmigaDOS disk editor, DISKED. Because DISKED writes to the disk directly, you should use it with care. Nevertheless, you can use it to good effect in recovering information from a corrupt floppy disk, for example. A disk does not have to be inserted to be examined by DISKED. You should only use DISKED with reference to the layout of an AmigaDOS disk. (For a description of the layout, see subsections 1.1.1 through 1.1.5 in the first part of the chapter.) DISKED knows about this structure - for example, the R (Root block) command prints the key of the root block. The G (Get block) command followed by this key number reads the block into memory, whereupon the I (Information) command prints out the information contained in the first and last locations, which indicate the type of block, the name, the hash links, and so on. If you specify a name after an H (Hash) command, DISKED gives you the offset on a directory page that stores as the first key headers with names that hash to the name you supplied. If you then type the number that DISKED returns followed by a slash (/), DISKED displays the key of that header page.