OC-misc/rtfs
Izaya c24689d1a6 fix docs to reflect implementation 2023-10-11 10:19:18 +10:00
..
README.md change the readme to a link to the current version 2023-10-01 13:27:50 +10:00
v1.md fix docs to reflect implementation 2023-10-11 10:19:18 +10:00

README.md

rtfs, version 1

A mutant clone of the RT-11 filesystem for OpenComputers.

Features

  • 2^32 sector maximum volume size
  • 2^32 byte maximum extent size
  • File and free space fragmentation (up to 512 extents per file)

Implementations

Overall structure

An rtfs volume consists of three main areas:

  • The superblock, residing at the start of the volume, and occupying one sector.
  • The data area, occupying the space not used by the superblock and index.
  • The index, growing from the end of the volume towards the start.

The entire contents of the data area are laid out in the index area, including free spaces. While the exact structure of the data area isn't specified, one approach that has worked well is, to quote the RT-11 Volume and File Formats Manual (August 1991), to "allocate for the [new extent] either one-half the largest space available, or the second largest space, whichever is bigger."

Metadata structures

Superblock

The superblock holds some basic data about the filesystem and index.

  • "rtfs" as a string, for identification
  • 1 byte representing a version, currently 1
  • 4 bytes representing the index size, in entries.
  • A 18-byte null-padded string, storing the volume label.

Index

The volume index lives at the end of the volume, and grows towards the start. It contains a description of the entire data section of the volume.

Entry types

The index entry type is a 4-bit number, representing one main division: whether an extent can be overwritten safely. If an extent's type is <= 7, then it can be recycled. Otherwise, it contains live data, and should be preserved. Subtracting or adding 8 to the type will turn it from one to the other. Additionally, the type is used to differentiate initial extents from secondary extents, and tell finalised files, tentative files, and directories apart.

local ftypes = {
 empty = 0,
 dfile = 1,
 dfext = 2,
 ddir = 3,
 ddex = 4,
 tfile = 5,
 text = 6,
 dlink = 7,
 unused = 8,
 file = 9,
 fext = 10,
 dir = 11,
 dex = 12,
 link = 15
}

Index entry

Each index entry describes an extent, or filesystem object that doesn't take up any data space, like a symlink or directory without tags.

  • 4 bits of entry type
  • 3 bits of reserved flags
  • 9 bits of extent ID
    • In the case of an initial extent (that is, type file, tfile, dfile, dir, or ddir), this represents the number of extents contained within the file.
    • In the case of secondary extents (fext, text, dfext, ddex), this represents its position within the file.
    • In the case of a link (or dlink), the first bit specifies whether this is the source or destination path, and the rest is a unique ID to associate it with another index entry containing the other path.
  • 32 bits representing the sector which the extent starts in.
  • 32 bits representing the length of the extent, in bytes.
  • 46 bytes containing the full path to the file within the filesystem, null padded.