FSBackdoor.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reserved.
Created by M. D. Schroeder
Schroeder, September 15, 1983 1:56 pm
Bob Hagmann May 6, 1988 1:38:47 pm PDT
Tim Diebert: January 14, 1987 10:00:46 am PST
Doug Wyatt, January 19, 1987 11:14:04 am PST
Backdoors to the Cedar File System
DIRECTORY
BasicTime USING [GMT],
FS USING [FileType, Lock, OpenFile],
Rope USING [ROPE];
FSBackdoor: CEDAR DEFINITIONS
= BEGIN
ROPE: TYPE = Rope.ROPE;
Client-provided open files
FS provides a way for clients to implement objects with the TYPE FS.OpenFile. The client provides procedures that implement the operations on an FS.OpenFile. Refer to FS.mesa for the semantics of these procedures. The client procedures should raise FS.Error as appropriate. Client procedures can generate code ATOM's used by FS and can produce additional code ATOM's if needed. FS.Error's with existing code ATOM's should be generated using FSBackdoor.ProduceError (see below). The client is responsible for associating any new code ATOM's with the appropriate FS.ErrorGroup. Note that no locking is done by FS on client-provided FS.OpenFile's. FS produces FS.Error[client, $notImplemented] when an attempt is make to use any client procedures that are NIL.
FileProcs: TYPE;
CreateFileProcs: PROC [
GetClass: PROC [clientFile: REF] RETURNS [ATOM] ← NIL,
SameFile: PROC [clientFile1, clientFile2: REF] RETURNS [BOOL] ← NIL,
GetName: PROC [clientFile: REF] RETURNS [fullFName, attachedTo: Rope.ROPE] ← NIL,
GetInfo: PROC [clientFile: REF] RETURNS [keep: CARDINAL, pages, bytes: INT,
created: BasicTime.GMT, lock: FS.Lock, fileType: FS.FileType] ← NIL,
SetPageCount: PROC [clientFile: REF, pages: INT] ← NIL,
SetByteCountAndCreatedTime: PROC [clientFile: REF, bytes: INT,
created: BasicTime.GMT] ← NIL,
Read: UNSAFE PROC [clientFile: REF, from, nPages: INT, to: LONG POINTER] ← NIL,
Write: PROC [clientFile: REF, to: INT, nPages: INT, from: LONG POINTER] ← NIL,
Close: PROC [clientFile: REF] ← NIL
] RETURNS [REF FileProcs];
SameFile will only get called for two clientFiles with equal "REF FileProcs".
Client errors: none
User errors: none
CreateProcsOpenFile: PROC [clientFile: REF, fileProcs: REF FileProcs] RETURNS [FS.OpenFile];
Whenever any of the procedures above are called for the FS.OpenFile returned by FSBackdoor.CreateProcsOpenFile, the "clientFile" argument to CreateProcsOpenFile is passed on as the identification of the open file that is to be operated upon.
Client errors: none
User errors: none
GetClientFileAndProcs: PROC [file: FS.OpenFile]
RETURNS [clientFile: REF, fileProcs: REF FileProcs];
If "file" is a client-provided FS.OpenFile then the "clientFile" and "fileProcs" are returned, otherwise NIL is returned for both results.
Client errors: $invalidOpenFile
User error: none
ErrorCode: TYPE = {ok -- used internally-- , inconsistent, software, badFP, wentOffline, hardware, volumeFull, fragmented, noMoreVersions, serverInaccessible, connectionRejected, connectionTimedOut, badCredentials, accessDenied, quotaExceeded, invalidPropertyPage, badBTree, outOfPropertySpace, lockConflict, fileBusy, noCache, wrongLock, globalWriteLock, zeroKeep, badByteCount, unknownPage, invalidOpenFile, notImplemented, fileTypeMismatch, nonCedarVolume, unknownServer, unknownVolume, unknownFile, unknownCreatedTime, illegalName, patternNotAllowed, versionSpecified, globalCreation, badWorkingDir, noKeeps, cantUpdateTiogaFile };
ProduceError: PROC [code: ErrorCode, explanation: Rope.ROPE];
Raises FS.Error for the code ATOM that corresponds lexically to the "code". The FS.ErrorGroup in the error is properly set. The error will contain "explanation". Clients should use this procedure to generate FS.Error's for existing codes to avoid spelling the ATOM's wrong and getting the wrong FS.ErrorGroup.
END.