IFSFilePrivate.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Levin - 13-Oct-81 9:59:49
Russ Atkinson, March 7, 1985 2:11:01 pm PST
DIRECTORY
IFSFile USING [AccessFailure, Buffer, Completer, CompleterArg, Position],
Leaf USING [FileAddress, Handle, LeafType, OpSpecificFileAddress],
PupDefs USING [PupAddress],
Rope USING [ROPE],
Sequin USING [Buffer, Handle];
Types and Related Constants
FSObject:
TYPE =
MONITORED
RECORD [
primaryName, primaryPassword: ROPE ← NIL,
secondaryName, secondaryPassword: ROPE ← NIL,
serverAddr: PupDefs.PupAddress,
fileList: FileHandle ← NIL,
changeInOpenState: CONDITION ← [timeout: 0],
cachedSequin: Sequin.Handle ← NIL,
haveSequin: BOOL ← FALSE];
FSInstance: TYPE = REF FSObject;
FileObject:
TYPE =
MONITORED
RECORD [
sequin: Sequin.Handle ← NIL,
ioPending: IORequest ← NIL,
ioSynch: CONDITION ← [timeout: 0],
length: Position ← NULL,
openCount: [0..128) ← 1,
locked: BOOL ← FALSE,
seal: FileSeal ← underwaySeal,
state: FileState ← alive,
link: FileHandle,
leafHandle: Leaf.Handle ← NULL,
name: ROPE,
fs: FSInstance,
watcher: PROCESS RETURNS [BOOL] ← NULL];
FileHandle: TYPE = REF FileObject;
FileState: TYPE = {alive, flush, closing, closed};
FileSeal:
TYPE =
MACHINE
DEPENDENT {
underwaySeal (22B), openSeal (41B), closedSeal (55B), (77B)};
IORequestBlock:
TYPE =
RECORD [
link: IORequest ← NIL,
buffer: Buffer,
address: Leaf.FileAddress,
op: Leaf.LeafType,
bytesToGo: CARDINAL,
proc: Completer ← NULL,
arg: CompleterArg ← NULL];
IORequest: TYPE = REF IORequestBlock;
IFSTimes: TYPE = MACHINE DEPENDENT RECORD [create, write, read: IFSTIME];
IFSTIME: TYPE = MACHINE DEPENDENT RECORD [high, low: CARDINAL];
fileTimeAddress: Leaf.FileAddress = [high: 3777B, low: 174000B];
the following values are in seconds
fileLockTimeout: CARDINAL = 2*60;
connectionTimeout: CARDINAL = 10*60;
File Manipulation Procedures
GetSequinForFS:
PROC [fs: FSInstance]
RETURNS [sequin: Sequin.Handle, fromCache:
BOOL];
acquires a sequin for use under the specified file system.
FreeSequinForFS:
PROC [ fs: FSInstance, sequin: Sequin.Handle, toCache:
BOOL ←
TRUE];
releases a sequin previously in use under the specified file system.
InsertFile:
PROC [fs: FSInstance, name:
ROPE, openProc:
PROC [FileHandle]
RETURNS [IFSFile.AccessFailure]]
RETURNS [FileHandle];
The file 'name' is checked against files presently open under file system 'fs'. If the file is not already open, 'openProc' is called. If 'openProc' returns an AccessFailure other than 'ok', the open is considered to have failed, otherwise, the use count of the file handle is incremented.
ReleaseFile:
PROC [file: FileHandle, closeProc:
PROC [FileHandle]];
The use count on the indicated file is decremented and, if zero, 'closeProc' is called. The FileHandle then becomes invalid. If the use count is still greater than zero, closeProc is not called and the FileHandle remains usable.
PurgeFile:
PROC [file: FileHandle, destroyProc:
PROC [FileHandle]];
The use count on the indicated file must be zero, otherwise an error occurs. 'destroyProc' is called and it is expected to remove all traces of the file.
ValidateFile: PROC [file: FileHandle];
Miscellaneous Utilities
AddRopeToBuffer: PROC [buffer: Sequin.Buffer, r: ROPE] RETURNS [Sequin.Buffer];
FileAddressToPosition: PROC [fa: Leaf.FileAddress] RETURNS [Position];
PositionToFileAddress: PROC [pos: Position, opSpecific: Leaf.OpSpecificFileAddress ← [read[]]] RETURNS [Leaf.FileAddress];
END.