-- file Core.mesa
-- Last edited by Brotz, November 20, 1981 2:39 PM.
DIRECTORY
AltoFileDefs USING [FP],
VMDefs USING [FileHandle];
Core: DEFINITIONS =
BEGIN
-- Core is a remnant of the once mighty Laurel CoreDefs. It now provides a thin veneer
-- over the VM package to make it suitable for use in Laurel. The major functions
-- provided by this interface are:
-- (1) To give a uniform way to open files on the local disk or on remote servers.
-- The file name format is: [Site]<Directory>SimpleName.Extension
-- (2) To guard against opening files illegally, both those files that should never be touched
-- by a client (such as DiskDescriptor, Laurel.run, etc.) and those files that are currently
-- open by the client.
-- Core provides a file name cache, which contains the names of all currently open files, the
-- names of files that must not be opened under any circumstances, and if room permits
-- (up to the cache limits), a mapping of file name to Alto FP for certain commonly used
-- files that are not currently open.
-- Exported variable --
localCacheHead: CacheHeader;
-- Procedures --
Login: PROCEDURE [user: DMSUser];
-- Notifies the Core of the new name, registry and password to be used on subsequent
-- Open’s.
Open: PROC [filename: STRING, mode: OpenMode] RETURNS [handle: VMDefs.FileHandle];
-- Opens "filename" in "mode", and returns a handle to the opened file.
-- ERRORS:
-- VMDefs.CantOpen (notFound, alreadyExists, accessDenied, illegalFileName)
-- VMDefs.Error (io, resources, credentials) [io = unrecoverable disk error or communications
-- failure for remote files, resources = disk full or directory limit on remote server,
-- credentials = credentials presented at Login were not sufficient to permit this Open].
Close: PROCEDURE [handle: VMDefs.FileHandle];
-- Closes the file associated with "handle". "handle" must not be re-used by the caller.
Delete: PROCEDURE [handle: VMDefs.FileHandle];
-- Deletes the file associated with "handle". "handle" must not be re-used by the caller.
InsertInFileCache: PROC [name: STRING, fp: AltoFileDefs.FP, open: BOOLEAN ← TRUE]
RETURNS [entry: LocalCacheEntry];
-- Inserts "name" and "fp" in the Alto file name cache.
-- To protect a file from being opened, "open" should be TRUE. In this case, subsequent
-- Open’s on this file will fail with VMDefs.Error[alreadyExists].
-- Possible uses of this procedure are to provide faster Open’s and to protect critical files as
-- described above.
LookupInFileCache: PROCEDURE [name: STRING] RETURNS [fp: AltoFileDefs.FP];
-- Returns the FP associated with the name (or NullFP if no such file).
FreeCacheEntry: PROCEDURE [name: STRING];
-- Removes the cache entry for "name" from the local file cache (if it existed).
-- May call SysBug if that file is marked open.
-- Data Structures and Types.
DMSUserBlk: TYPE = RECORD [name: STRING, registry: STRING, password: STRING];
DMSUser: TYPE = POINTER TO DMSUserBlk;
OpenMode: TYPE = {read, update};
-- read: Read only; the file must exist
-- update: Read + Write + Append; if the file exists then the old version is referenced,
-- otherwise, a new file is created.
CacheHeaderBlk: TYPE = RECORD
[server: STRING,
firstEntry: CacheEntry,
lastEntry: CacheEntry,
next: CacheHeader,
prev: CacheHeader];
CacheHeader: TYPE = POINTER TO CacheHeaderBlk;
CacheEntryBlk: TYPE = RECORD
[next: CacheEntry,
prev: CacheEntry,
name: STRING,
handle: VMDefs.FileHandle,
open: BOOLEAN,
vp: SELECT location: Location FROM
local => [fp: AltoFileDefs.FP],
remote => [loginEpoch: CARDINAL],
ENDCASE];
CacheEntry: TYPE = POINTER TO CacheEntryBlk;
LocalCacheEntry: TYPE = POINTER TO local CacheEntryBlk;
RemoteCacheEntry: TYPE = POINTER TO remote CacheEntryBlk;
Location: TYPE = {local, remote};
END. -- of Core --