File system structures





Structs.fth defines the data structures that are used in the file system.

equ PATH-STRING \ -- len
Maximum size of a full path name.

PATH-LENGTH 1+ field-type lstring       \ len n -- len+n ; addr -- addr+len
Filed type for counted strings.

struct dir-struct       \ -- len
Directory entry in a directory block.

  int      ->file-number        \ the FLD record number
  lstring  ->file-name          \ file name as counted string
end-struct

BLOCK_SIZE DIR-STRUCT / equ DIR/BLOCK   \ -- n
Number of directory entries per block.

struct file-extents     \ -- len
Each extent has the same format.

  int  ->extent-start           \ location of data
  int  ->extent-size            \ size of data
end-struct

NO-OF-EXTENTS file-extents * equ EXTENT_LIST    \ -- len
Size of the extent area in an FCB/FLD.

struct FLD-rec  \ -- len
FILE LIST DESCRIPTOR and FILE CONTROL BLOCK

  int  ->next-fcb               \ FCB, points to next FCB
  int  ->file-size              \ number of bytes used in file
  int  ->file-blocks            \ number of blocks used by file
  short  ->prev-dir
  short  ->file-type            \ data, directory or system
  int  ->file-last-mod          \ data last written
  int  ->file-expansion         \ size of increase
  int  ->open-tables            \ FCB, current number of open tables
  int  ->fld-no                 \ FCB, ptr to FLD
  int  ->extent-start-0         \ location of data
  int  ->extent-size-0          \ size of data
  EXTENT_LIST file-extents - +  \ remaining extents
  int  ->indirect-block         \ points to indirect block.
  3 cells +                     \ currently unused
end-struct

BLOCK_SIZE FLD-REC / equ FLD/BLOCK      \ -- len
Number of FLDs in a disk block.

struct indir-extent     \ -- len
Indirect extents are not the same as direct extents.

    int  ->ind-extent-start     \ start sector
    int  ->ind-logical-end      \ last+1
end-struct

struct open-table-struct        \ -- len
Defines details of a file that a task has open.

    int  ->next-otb             \ chain of OTBs
    int  ->r/w-data-ptr         \ read/write pointer
    int  ->valid-otb            \ marker for validity check
    int  ->fcb-number           \ FCB address
end-struct

$5a1234a5 equ CEM_FORMAT        \ -- x
A code to show its DOS type.

struct root-block       \ -- len
Layout of the start of the root block.

    int ->CEM_FORMAT            \ file type indicator
    int ->USAGE_BLOCK0          \ start of bitmap
    int ->FLD0_BLOCK            \ start of FLDs
    int ->DATA_BLOCK0           \ first data block
    int ->init-time             \ disk format time
    lstring ->vol-name          \ volume name
    int ->vol-size              \ max blocks
    int ->fd-size               \ unused
end-struct

struct boot-block       \ -- len
Layout of start of boot block.

    int ->primary-boot          \ location of primary application
    int ->primary-size          \ size
    int ->backup-boot           \ location of secondary application
    int ->backup-size           \ size
    int ->CEM_FORMAT-B          \ marker
end-struct

struct block-alloc      \ -- len
This structure is used when grabbing or freeing disk sectors.

    int ->last-amount
    int ->#blocks
    int ->start-block
    int ->start-address
    int ->first-amount
end-struct

struct file-extension   \ -- len
This structure is used when extending a file.

    int ->ext-fid
    int ->ext-size
    int ->ext-start
    int ->ext-no
end-struct

struct CACHE-INFO       \ -- len
Data structure controlling each cached disk sector.

  int ->cache-link      \ link to next structure in chain; MUST be first
  int ->mem-block       \ pointer to data
  int ->disk-block      \ disk block number
  int ->cache-valid     \ nz = cache valid
  int ->cache-time      \ last read/write time
  int ->cache-dirty     \ nz = modified
end-struct