Commodore‎ > ‎Disk‎ > ‎

File

A standard Commodore ("CBM") file consists of 1 or more blocks of data.  A "block" is a carefully referenced area of 256 (logical) bytes of data somewhere on the storage media ("disk").  There are seven (7) types of files:
  1. DEL = Deleted... these normally do not appear in a directory listing (could be any type listed below)
  2. SEQ = Sequential... these are often raw data files (like a text document)
  3. PRG = Program... almost the same as above (Sequential), except the first 2 bytes (header) hold the host "load address" in little-endian (low byte first) order
  4. USR = User... these are (usually) like Program files, but instead of a 2-byte header (for load address), they (usually) contain a special header that gives an internal "load address"; in this case, each block also includes a checksum.  Except for 1581 and GEOS, these are very rare.  For GEOS, USR files show in the directory, but they are different!  For GEOS, they will contain SEQ-type raw data, or more commonly, contain a single "VLIR" block... the VLIR block will list a set of blocks (a.k.a., streams/forks) that belong to the VLIR file.
  5. REL = Relative... these files allow random access to any byte in the file (all the others [except VLIR] allow only sequential read/write)
  6. CBM = 1581 partition... this "file" simply notes the start track and sector of a 1581-"sub-directory"... however this is not a true sub-directory as most people understand it today... it is actually a specially reserved section of a disk which can hold as many files that will fit within the reserved area (compare with next)
  7. DIR = CMD sub-directory... this "file" simply points to (and names) a directory header.  The referenced directory specifies 3 things: (1) the parent directory, (2) the root directory, and (3) the files in the sub-directory.  The listing of files (#3) is separate from the directory header (which tells #1 and #2)
Note 1: it is the responsibility of CBM DOS to remember which block(s) are assigned to files, such that new file(s) do not destroy saved data and that existing files can be read/written.  Although a logical block holds 256 bytes, the first 2 are "meta-bytes" which (normally [not last block]) point to the next track/sector of the file (link); in particular, each block can only hold 254 data bytes!  The last block does not contain a link; instead the first byte is 0 (an invalid track) and the second byte tells which is the last valid byte in the block.

Note 2: most files only contain a single stream of data, but REL files (classic Commodore) contain two streams of data, while GEOS files contain two or (often) more streams of data.  Below are details on these more complex file types.

  REL (relative)  
This file-type holds 2 data streams.  One is the raw data; it is very much like a SEQ file.  The second is an index file... often called "side-sector(s)" in Commodore literature.  The index file is usually 1 to 6 blocks.  Each "side-sector" block can reference (index) 120 data sectors.  Most CBM disks only allow a maximum of 6 side-sectors... thus a maximum of 6 * 120 = 720 data blocks (which is 720 * 254 = 182 880 bytes of data).  However, the 1581 and CMD disk formats add an extra block known as "super side-sector".  On these disks, up to 126 "groups" of 6-block side-sectors are indexed... thus a maximum of 120 * 6 * 126 = 90 720 blocks can be indexed (this is overkill... REL allows 65 535 blocks max).

 
  GEOS Sequential  
All GEOS files have (at least) two data streams.  GEOS Sequential files have exactly two!
  1. Info Header (holds icon, description, class, etc.)
  2. Raw Data
 In theory, the Info Header could contain multiple blocks, but GEOS has a strict limit of 1 block.

  GEOS VLIR  
Most GEOS files are VLIR files.  In the directory, they hold 2 data streams:
  1. Info Header (icon, etc.)
  2. VLIR table (a single block)
The VLIR table lists, essentially, a set of SEQ/PRG-type files (up to 127; in theory it could hold more, but GEOS has a strict limit).  So conceptually a VLIR file has 2+ data streams:
  • Info Header (icon, etc.)
  • Data 1 (first VLIR entry [required])
  • Data 2 (second VLIR entry [optional])
  • Data 3 [optional]...
  • Data 127 [optional]
A VLIR file must have at least 1 "data entry" (which points to SEQ/PRG-type file), and it almost always has fewer than 127 entries (data forks).

A single VLIR entry is simply a two-byte track/sector "link" to the first block in a SEQ/PRG type of file.  The only difference (see above) is that a PRG begins with a 2-byte "load address"... this is used to load program code into GEOS; SEQ type is raw data without any "load address".  The file system does not distinguish between them!  The software author must know which VLIR stream is program (PRG) or raw data (SEQ).


© H2Obsession, 2015
Comments