-- File: FileDefs.mesa
-- Last edited by Levin:  27-Feb-81 11:35:30


DIRECTORY
  VMDefs USING [defaultTime, FileTime, OpenOptions, PageNumber, Position, Problem];

FileDefs: DEFINITIONS =

  BEGIN

  -- This interface defines the common properties for file systems used at
  -- the VM level.


  -- Types --

  Operations: TYPE = POINTER TO OperationsRecord;

  OperationsRecord: TYPE = RECORD [
    login: PROC [server, userName, password,
		 secondaryName, secondaryPassword: STRING ← NIL] RETURNS [FSInstance],
    logout: PROC [FSInstance],
    checkpoint: PROC [FSInstance],
    abort: PROC [FSInstance],
    open: PROC [instance: FSInstance, name: STRING, options: OpenOptions ← oldReadOnly]
	  RETURNS [FileHandle],
    close: PROC [FileHandle],
    abandon: PROC [FileHandle],
    destroy: PROC [FileHandle],
    getLength: PROC [FileHandle] RETURNS [Position],
    setLength: PROC [FileHandle, Position],
    extend: PROC [FileHandle, Position, Buffer],
    truncate: PROC [FileHandle, Position],
    startRead: PROC [FileHandle, PageNumber, Buffer, Completer, CompleterArg],
    startWrite: PROC [FileHandle, PageNumber, Buffer, Completer, CompleterArg],
    getTimes: PROC [FileHandle] RETURNS [read, write, create: FileTime],
    setCreation: PROC [FileHandle, FileTime]];

  FSInstance: TYPE = POINTER TO FSObject;
  FSObject: TYPE;

  FileHandle: TYPE = POINTER TO FileObject;
  FileObject: TYPE;

  OpenOptions: TYPE = VMDefs.OpenOptions;

  Buffer: TYPE = POINTER;
  Position: TYPE = VMDefs.Position;
  PageNumber: TYPE = VMDefs.PageNumber;

  Completer: TYPE = PROCEDURE [arg: CompleterArg, outcome: Problem];
  CompleterArg: TYPE = UNSPECIFIED;
  Problem: TYPE = VMDefs.Problem;

  Comparison: TYPE = MACHINE DEPENDENT {less, equal, greater};

  FileTime: TYPE = VMDefs.FileTime;

  defaultTime: FileTime = VMDefs.defaultTime;


  -- Miscellaneous --

  bytesPerPage: CARDINAL = 512;


  -- Procedures and Signals --

  ComparePositions: PROCEDURE [pos1, pos2: Position] RETURNS [Comparison];

  IncrementPosition: PROCEDURE [pos: Position, bytes: CARDINAL] RETURNS [Position];

  -- Alto File System --

  InitializeAlto: PROCEDURE RETURNS [Operations];
  -- called from VM initialization to perform once-only initialization of the
  -- local file system.

  FinalizeAlto: PROCEDURE;
  -- called from VM finalization to shut down the local file system.

  -- IFS File System --

  InitializeIFS: PROCEDURE RETURNS [Operations];
  -- called from VM initialization to perform once-only initialization of the
  -- IFS file system.

  FinalizeIFS: PROCEDURE;
  -- called from VM finalization to shut down the IFS file system.

  -- Juniper File System --

  InitializeJuniper: PROCEDURE RETURNS [Operations];
  -- called from VM initialization to perform once-only initialization of the
  -- Juniper file system.

  FinalizeJuniper: PROCEDURE;
  -- called from VM finalization to shut down the Juniper file system.


  END.