![]() |
  Homebrew Mini-Computer based on Z80 CPU |
armandoacostawong@gmail.com |
VTFS stands for Virtual Tape File System. It is intended as an abstraction for programs running at the LC-81 minicomputer to access any kind of tape-based storage with disregard of the of the underlying technology. Tapes can be either real such audio cassettes and open reel audio tapes, or virtual, simulated with Floppy Disks or ROM memory.
The main reasons for have selected tapes instead of disks as the abstracted object is simplicity. Using a floppy disk for storing sequential files, for example, one sector after another, is much simpler that implementing a directory based structure such as FAT. Another reason is the intent to unify disparate storage technologies within a single access method.
The tape content is encoded in ASCII. In the case of non-textual content (such as binary files or programs object code), it is coded in Hexadecimal which in turn is encoded in ASCII.
The entire media is treated as a single sequence of bytes broken into Blocks being this the transfer unit. VTFS reads or writes tapes one block at the time into internal buffers. Applications read or write one byte at the time from VTFS buffers. VTFS takes care of the synchronization between application requests and buffers content.
In real tapes, blocks are physically separated by gaps. This is required for tapes containing long files because they will eventually stop in the middle of a file; tapes must stop with the head positioned over a gap, not a data zone.
The size of the block is fixed for a given tape but it can vary from tape to tape. Some types of media such as Floppy have a pr-established block size but this parameter is generally user-defined and ranges from 256 to 4096 bytes. The maximum number of blocks a file can contain is 256, hence the maximun size for a VTFS file is 1 MB.
The block format for real tapes is as following:
gap 02H ASCII Start-Of-Transmission (STX) MSN Block Number (Hex less signif. nibble) LSN Block Number (Hex most signif. nibble) . . data . . . 03H ASCII End-Of-Transmission (ETX) gap
In virtual tapes, blocks contain just the data.
The first block of a volume (Block 0) is always a LABEL containing information about the rest of the volume. The format is as following:
Start Mark (ASCII 'SOH': 01H) File System ID (VTFS) File System Version (1.0) Medium (ex: T) Block Size (ex: 1024) Block Count (ex: 21) Encoding (ex: A) File ID (FID) (ex: 04) File Description (ex: Employees Master File) Read-Only (Y or N) File Creation Date (ej: 2016-08-11)
These fields are delimited by a Line Feed character (0AH). The last one after the 'File Creation Date' field is interpreted as the end of the LABEL.
In real tapes, the LABEL is preseed by the STX mark and the two block number bytes ('00') since it is still a block. The remaining block space after the LABEL is kept all block-size long, then the ETX mark must appear. This extra space can prove usefull in case of rewriting the LABEL in a real tape.
Field 'Medium' accept one of the values: 'T' (real Tape), 'V' (Virtual tape). This is important since some VTFS operations (such as overwriting a block in the middle of the tape) are restricted to virtual tapes.
Field 'Block Count' is mandatory for program files but can be ignored for other kind of files, specially those stored in real tapes: having to rewind the tape to the begining for just updating the LABEL can prove impractical in certain cases.
Encoding can be one of the values: 'A' (textual), 'H' (hexadecimal). This is important because VTFS makes the conversion hex-to-bin as it writes to the memory buffer in case of Enconding 'H'.
File ID or FID, is the way programs refer files. When the tape is mount on the tape drive, a 2-digits 7-segments display shows that ID to tell the operator which file is in which drive. This allows the operator to place tapes in arbitrary drives without getting lost.
'File Description' is optional being its purpose to show some additional information in a terminal, if that were the case.
Each file ends with a End-Of-File mark (EOF) placed after the last data byte of the file. Actual mark is ASCII FS (1CH).
Typically, a tape contains one file only. However, it is possible to "trick" VTFS by placing a LABEL followed by another file, after the EOF mark. In that case, block count must start again from zero.
As many files as can fit in the media can be stored that way, but this comes with a limitation: appending data to files other than the last one will corrupt the file that follows. Most likely this "illegal" practice will be limited to read-only files such as those for program packages and archives.
VTFS supports Read and Write operations on arbitrary blocks. In practice, real tapes can prove difficult to manage if not read and written in a strict sequential fashion but VTFS does not impose limitations to this.
[ ... to be continued ... ]