-- File: IFSFilePrivate.mesa -- Last edited by: -- Levin - 13-Oct-81 9:59:49 DIRECTORY IFSFile USING [AccessFailure, Buffer, Completer, CompleterArg, Position], Leaf USING [FileAddress, Handle, LeafType, OpSpecificFileAddress], PupDefs USING [PupAddress], Sequin USING [Buffer, Handle]; IFSFilePrivate: DEFINITIONS = BEGIN OPEN IFSFile; -- Types and Related Constants -- FSObject: TYPE = MONITORED RECORD [ primaryName, primaryPassword: LONG STRING, secondaryName, secondaryPassword: LONG STRING, serverAddr: PupDefs.PupAddress, fileList: FileHandle _ NIL, changeInOpenState: CONDITION _ [timeout: 0], cachedSequin: Sequin.Handle _ NULL, haveSequin: BOOLEAN _ FALSE]; FSInstance: TYPE = LONG POINTER TO FSObject; FileObject: TYPE = MONITORED RECORD [ sequin: Sequin.Handle _ NULL, ioPending: IORequest _ NIL, ioSynch: CONDITION _ [timeout: 0], length: Position _ NULL, openCount: [0..128) _ 1, locked: BOOLEAN _ FALSE, seal: FileSeal _ underwaySeal, state: FileState _ alive, link: FileHandle, leafHandle: Leaf.Handle _ NULL, name: LONG STRING, fs: FSInstance, watcher: PROCESS RETURNS [BOOLEAN] _ NULL]; FileHandle: TYPE = LONG POINTER TO FileObject; FileState: TYPE = {alive, flush, closing, closed}; FileSeal: TYPE = MACHINE DEPENDENT {underwaySeal (22B), openSeal (41B), closedSeal (55B), (77B)}; IORequestBlock: TYPE = RECORD [ link: IORequest _ NULL, buffer: Buffer, address: Leaf.FileAddress, op: Leaf.LeafType, bytesToGo: CARDINAL, proc: Completer _ NULL, arg: CompleterArg _ NULL]; IORequest: TYPE = LONG POINTER TO 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; -- Variables -- zone: UNCOUNTED ZONE; mdsZone: MDSZone; -- File Manipulation Procedures -- GetSequinForFS: PROCEDURE [fs: FSInstance] RETURNS [sequin: Sequin.Handle, fromCache: BOOLEAN]; -- acquires a sequin for use under the specified file system. FreeSequinForFS: PROCEDURE [ fs: FSInstance, sequin: Sequin.Handle, toCache: BOOLEAN _ TRUE]; -- releases a sequin previously in use under the specified file system. InsertFile: PROCEDURE [fs: FSInstance, name: LONG STRING, openProc: PROCEDURE [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: PROCEDURE [file: FileHandle, closeProc: PROCEDURE [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: PROCEDURE [file: FileHandle, destroyProc: PROCEDURE [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: PROCEDURE [file: FileHandle]; -- I/O -- DoRead: PROCEDURE [file: FileHandle, request: IORequest]; -- initiates a read operation as described by 'file' and 'request'. DoWrite: PROCEDURE [file: FileHandle, request: IORequest]; -- initiates a write operation as described by 'file' and 'request'. FileWatcher: PROCEDURE [file: FileHandle] RETURNS [BOOLEAN]; -- handles responses from the server to operations requested by StartRead and -- StartWrite. The return value indicates whether the file operations -- were shut down normally or abnormally. -- FreeList Management -- InitializeFreeList: PROCEDURE; FinalizeFreeList: PROCEDURE; GetIORequestBlock: PROCEDURE RETURNS [IORequest]; FreeIORequestBlock: PROCEDURE [request: IORequest]; -- Miscellaneous Utilities -- CopyString: PROCEDURE [s: LONG STRING] RETURNS [ns: LONG STRING]; -- copies 's' to the heap zone, returning 'ns'. (s = NIL => ns = NIL) AddStringToBuffer: PROCEDURE [buffer: POINTER TO Sequin.Buffer, s: LONG STRING]; FileAddressToPosition: PROCEDURE [fa: Leaf.FileAddress] RETURNS [Position]; PositionToFileAddress: PROCEDURE [ pos: Position, opSpecific: Leaf.OpSpecificFileAddress _ [read[]]] RETURNS [Leaf.FileAddress]; END.