29.12.2012 Views

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

position where the last character is placed. For instance, after writing three bytes in<strong>to</strong><br />

positions 0, 1, and 2 of the buffer, the offset must be incremented <strong>to</strong> "3" since the next<br />

available buffer position is byte 3.<br />

6.4.6 Logical Drive Number - <br />

This contains the logical drive number in binary of the drive containing the file. It is<br />

absolutely essential that this byte be left undisturbed. It is used by the system's file<br />

access routines <strong>to</strong> obtain the logical disk drive number that physical I/O is <strong>to</strong><br />

reference. It, and the Direc<strong>to</strong>ry Entry Code contained in FCB+7 are the only links <strong>to</strong> the<br />

direc<strong>to</strong>ry information for the file. Since the operating system supports a maximmum of<br />

eight logical drives, the logical drive number is contained in a 3-bit field. <strong>The</strong><br />

remaining bits are reserved for future use in large disk segmentation.<br />

Bits 7-3 This field is reserved by the DOS for future use.<br />

Bits 2-0 This field contains the logical drive number where the file is s<strong>to</strong>red.<br />

6.4.7 Direc<strong>to</strong>ry Entry Code - <br />

This field contains the Direc<strong>to</strong>ry Entry Code (DEC) which points <strong>to</strong> the file's primary<br />

direc<strong>to</strong>ry entry. This code is the relative position in the Hash Index Table where the<br />

hash code for the file's direc<strong>to</strong>ry entry appears. Whenever the system needs <strong>to</strong> access the<br />

direc<strong>to</strong>ry for the open file, it must use both this DEC and the logical DRIVE <strong>to</strong> uniquely<br />

specify the proper direc<strong>to</strong>ry record. Do not tamper with this byte. It may be interesting<br />

<strong>to</strong> note that the device name, which uniquely identifies a device, and the DEC-DRIVE,<br />

which uniquely identifies a file, are contained in the same fields of their respective<br />

control blocks.<br />

6.4.8 Ending Record Number Byte Offset - <br />

This field contains the byte offset in the Ending Record Number which points <strong>to</strong> one byte<br />

past the end-of-file. This byte is similar <strong>to</strong> FCB+5 except it pertains <strong>to</strong> the ERN rather<br />

than the NRN. If a file has been extended during the time it was open, then the NRN byte<br />

offset and NRN become the new ERN byte offset and ERN when the file is closed.<br />

6.4.9 Logical Record Length - <br />

This field contains the logical record length in effect when the file was opened. This<br />

may not be the same LRL that exists in the direc<strong>to</strong>ry. <strong>The</strong> direc<strong>to</strong>ry LRL is generated at<br />

the file creation and will never change unless another file is cloned <strong>to</strong> it.<br />

6.4.10 Next Record Number <br />

This field contains the Next-Record-Number (NRN), which is a pointer <strong>to</strong> the relative<br />

sec<strong>to</strong>r for the next I/O operation. When a file is opened, NRN is set <strong>to</strong> zero indicating a<br />

pointer <strong>to</strong> the beginning of the file. Each physical sec<strong>to</strong>r I/O advances NRN by one. An<br />

@REWIND SuperVisor Call request will reset the NRN <strong>to</strong> zero.<br />

6.4.11 Ending Record Number <br />

This field is a pointer <strong>to</strong> the last sec<strong>to</strong>r of the file regardless of whether the sec<strong>to</strong>r<br />

is a full sec<strong>to</strong>r (i.e. all bytes occupied and EOF-OFFSET has a zero value) or a partial<br />

sec<strong>to</strong>r (i.e. EOF-OFFSET is not equal <strong>to</strong> zero). In a null file (one with no records), ERN<br />

will be equal <strong>to</strong> zero. If one sec<strong>to</strong>r had been written, ERN would be equal <strong>to</strong> one.<br />

6.4.12 Starting Extent - <br />

This field contains the same information as the first extent of the direc<strong>to</strong>ry. This<br />

represents the starting cylinder of the file (FCB+14) and the starting relative granule<br />

within the starting cylinder (FCB+15). FCB+15 also contains the number of contiguous<br />

granules allocated in the extent. This can always be used as a pointer <strong>to</strong> the beginning<br />

of the file referenced by the FCB. During any file access, this field will be searched<br />

first <strong>to</strong> see if it contains the granule which s<strong>to</strong>res the physical sec<strong>to</strong>r that is being<br />

referenced.<br />

6-16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!