Skip to content
SashaCrofter edited this page Jul 13, 2012 · 1 revision

CAT

CAT is the default file system for cubeOS. It is based on the Harry's Allocation Table file system format.

In order to act on a file or directory, it must be "opened." This copies the inode's contents to a temporary position (as provided by the program opening it.) Some of the subroutines below act on opened directories, so as to add links. When one is finished with a directory or file, one must "write" it back into its strip.

High-level Commands

The high-level commands provide a smooth interface with the filesystem that can be used easily by modules and the rest of the operating system.

cat.newFile (currentSector, pathPointer, type)

Creates a new, empty file of type at pathPointer. Type can be either 1, for directory, or 0, for file.

assumes there is open space at 0xa000 currently only supports making files in the current directory

returns the sector number of the new file

cat.getSector (currentSector, pathPointer)

Uses lower-level subroutines to parse either relative or absolute paths.

assumes there is open space at 0xa000

returns the start sector of the given file (via pathPointer,) or 0xffff if it doesn't exist

Low-level Commands

The low-level commands are used by the high level commands to provide fast and efficient access to the framework of the filesystem itself.

cat.mountSystem (location, length, sectorSize)

Mounts / directory at location, reserving length words after it. It then initializes a cat filesystem with the given sectorSize.

returns location of first word in header

cat.open (stripStartSector, continuousMemoryLocation)

Obeying sector joins, copies the entire file or directory (including inode) specified by stripStartSector to continuousMemoryLocation.

cat.write (inputPointer, sectorNumber)

Obeying sector joins, copies the entire contents of an open file at inputPointer to the sector at sectorNumber, linking new sectors as needed and unlinking old ones if they become unnecessary.

cat.linkNewSector (sectorNumber)

If sectorNumber does not link to another sector, link the first open sector to it.

modifies A
returns the sector number joined

cat.getJoinedSector (sectorNumber)

modifies A
returns the sector joined to sectorNumber, or 0 if unjoined or unused

cat.getOpenSector ()

Finds the first open sector in the filesystem. Does not detect when the system is full.

modifies A returns sector number

cat.getSectorPointer (sector)

modifies A returns a pointer to the location of the given sector in memory

cat.newInode (sector, type, parentSector)

Creates a new inode of type and length 0 at sector. It also marks the corresponding sector in sector map as used. Types are 0, for unused, 1, for directory, and 2, for file.

modifies A, B
returns the sector of the inode

cat.rmInode (sector)

Marks sector unused in the sector map, unlinks the rest of the strip, and marks its inode unused.

modifies A
returns sector

cat.freeStrip (startSector)

Unlinks all of the sectors in a strip and marks them each as free

cat.markSectorUsed (sector)

Marks a sector used in the bitmap.

modifies A
returns sector

cat.markSectorUnused (sector)

Marks a sector unused in the bitmap.

modifies A
returns sector

cat.newLink (directoryPointer, targetStripStartSector, namePointer)

Creates a new link under the given open file, extending the length of the inode automatically. The first word is the targetStripStartSector, and the remaining fifteen words are copied literally (maximum length fourteen) from the null-terminated word at namePointer. returns 0 if successful, and 1 if the given sector does not contain a directory

Low-Level Parsing Commands

cat.getSectorFromRelative (currentSector, spaceForOpenFile, relativePath)

cat.getSectorFromSingleRelative (currentOpenDirectoryPointer, relativePath)

Gets the sector pointed to by the link in currentOpenDirectoryPointer by relativePath. This is not recursive. relativePath is considered terminated by a slash null.

returns the target sector if found, or 0xffff if not

Clone this wiki locally