-- DirectoryInternal.mesa (last edited by: Keith on: October 8, 1980 11:06 PM)

DIRECTORY
Directory USING [maxDirectoryNameLength, maxPathNameLength],
Environment USING [wordsPerPage],
File USING [Capability, nullCapability],
Space USING [Handle, PageCount];

DirectoryInternal: DEFINITIONS =
--
this interface defines the global data types used by the directory system

BEGIN

--
Monitor/Module Control

DirectoryLock: MONITORLOCK;
swapUnitSize: Space.PageCount = 1; --
size of uniform swap units assigned by directory

--
Directory B-Tree definitions

DirectoryPageHandle: TYPE = LONG BASE POINTER TO DirectoryPage;
PagePointer: TYPE = DirectoryPageHandle RELATIVE POINTER [0..65535] TO
DirectoryPage;
nilPagePointer: PagePointer = LAST[PagePointer];

DirectoryEntryHandle: TYPE = LONG POINTER TO DirectoryEntry;

DirectoryEntry: TYPE = MACHINE DEPENDENT RECORD [
cap: File.Capability,
pointer: PagePointer,
name: StringBody ← [length: 0, maxlength: Directory.maxDirectoryNameLength, text:]];

DirectoryPage: TYPE = MACHINE DEPENDENT RECORD [
size(0:0..8): [0.. 256], --
number of words used in this page
free(0:9.. 9): BOOLEAN,
-- TRUE if page is not in use
filler(0: 10.. 15): [0.. 64), --
used for B-Tree validation
top(1:0..15): PagePointer, --
if this is the first page, this field points to the root
parent(2:0..15): PagePointer, --
the parent of this page
lastPointer(3:0..15): PagePointer, --
the last pointer in this page
entries(emptySize:0..(Environment.wordsPerPage-emptySize)*16 - 1):
ARRAY [0..Environment.wordsPerPage-emptySize) OF UNSPECIFIED --
the entries
];

emptySize: CARDINAL = 4; --
the size of an empty page
overhead: CARDINAL = SIZE[File.Capability] + SIZE[PagePointer];

DirectoryDescriptor: TYPE = RECORD [
base: DirectoryPageHandle ← NIL,
top: PagePointer ← nilPagePointer,
size: CARDINAL, --
in pages
space: Space.Handle];

--
Directory Tree Definitions
--
The directory tree (or D-Tree) is a multiway tree which is used to store the subdirectory structure of
-- a volume. This way, we don’t have to open up a bunch of directories in order to translate a path
-- name. The format of the tree is:
-- Node 0 (top): level -1. Son pointer points to
RootDir, bro pointer to free node list. Capability
-- is capability of the directory tree file (with full permissions). Name is empty.

--
Node 1, level 0. RootDir. Bro pointer points to self, son pointer to first son.
-- Subsequent nodes. Son pointer points to first son, bro to sibling. If no son, son pointer points to self.
-- If no sibling, bro pointer points to parent.


PDT: TYPE = LONG BASE POINTER TO DTNode;
PDTNode: TYPE = PDT RELATIVE POINTER [0.. 65535] TO DTNode;
pDTnil: PDTNode = LAST[PDTNode];

DTNode: TYPE = RECORD [
name: StringBody ← [length: 0, maxlength: Directory.maxDirectoryNameLength, text: ],
array: PACKED ARRAY [0.. Directory.maxDirectoryNameLength) OF CHARACTER ← ALL [’ ],
cap: File.Capability ← File.nullCapability,
son: PDTNode ← pDTnil,
bro: PDTNode ← pDTnil,
level: CARDINAL ← 0];

--
Directory Contexts Definitions

Context: TYPE = RECORD [
wdName: StringBody ← [length: 0, maxlength: Directory.maxPathNameLength, text:],
array: PACKED ARRAY [0.. Directory.maxPathNameLength) OF CHARACTER ← ALL [’ ],
pDC: CARDINAL ← 0,
valid: BOOLEAN ← FALSE,
pSP: LONG POINTER TO SPRecord ← NIL];

SPRecord: TYPE = RECORD [
spName: StringBody ← [length: 0, maxlength: Directory.maxPathNameLength, text:],
array: PACKED ARRAY [0.. Directory.maxPathNameLength) OF CHARACTER ← ALL[’ ],
pSP: LONG POINTER TO SPRecord ← NIL,
pDC: CARDINAL ← 0, -- the SP element directory
defined: BOOLEAN ← FALSE,
v: SELECT type: * FROM
noWD => NULL,
withWD => [
cap: File.Capability ← File.nullCapability, -- what we think the WD cap is
pWD: LONG POINTER TO Context -- the qualifying working Directory-- ],
ENDCASE
];

--
Directory Leader Page Constants and others

leaderPageSize: CARDINAL = 1;
leaderPageOffset: CARDINAL = 64;
-- word in leader page at which the Directory Prop List starts
initDirSize: Space.PageCount = 16; --
initial size of a directory
initDTSize: Space.PageCount = 16; --
initial size of a directory tree file
directoryIncrement: CARDINAL = 10; -- number of pages the directories and D-Trees will grow
maxDirSize: CARDINAL = 256 - leaderPageSize;
-- number of data pages in directory/D-Tree
-- note that the module DirectoryTreesImpl makes the assumption that
-- maxDirSize = n * directoryIncrement + initDirSize (or initDTSize) for some integer n.


END.


LOG

Time: August 21, 1980 10:52 AM By: Keith
Action: Created File
Time: October 6, 1980 5:34 PM By: KeithAction: Changed WD length in Context to maxPathNameLength. Added documentation (!).