FSFileOps.mesa
Last Edited by: Schroeder, November 29, 1983 3:04 pm
Last Edited by: Bob Hagmann, May 10, 1984 10:10:33 am PDT
DIRECTORY
BasicTime USING [GMT],
BTree USING [Tree],
BTreeVM USING [Handle],
File USING [FP, Handle, PropertyStorage, Volume],
FSBackdoor USING [Version],
IO USING [STREAM],
Rope USING [ROPE, Text];
FSFileOps: CEDAR DEFINITIONS = BEGIN
Volume Management - implemented in FSFileOpsImpl
VolumeDesc: TYPE = REF VolumeDescObject;
VolumeDescObject: TYPE = RECORD[
next: VolumeDesc, -- for linked list
vName: Rope.ROPE, -- name of this volume
prefix: Rope.ROPE, -- "[]<vName>" for use in lock table (NIL for system volume)
vol: File.Volume, -- volume id
tree: BTree.Tree, -- directory/cache BTree for the volume
treeVM: BTreeVM.Handle -- storage object for the BTree
];
GetVolumeDesc: PROCEDURE [vName: Rope.ROPENIL] RETURNS [VolumeDesc];
Returns a VolumeDesc for the named volume. NIL means the system volume for this Cedar instance. Will generate FS.Error[$unknownVolume] if the a named volume cannot be located, except that if the system volume is desired and no system volume is defined, then NIL is returned.
Volume Space Management - implemented in FSFileSpaceImpl
RecordUsage: PROCEDURE [fp: File.FP, time: BasicTime.GMT];
Informs the space management machinery that the global file identified by "fp" was used at the given "time", and therefore should be promoted in the lru list. "time" should be the same as the used-time in the corresponding BTree entry.
RegisterVolumeFlusher: PROCEDURE [svDesc: VolumeDesc];
Registers the volume flusher for the system volume with the File package. Is called internally by GetVolumeDesc the first time the system volume is gotten. It's ok to register a new volume flusher on top of an old one. If the argument is NIL then any existing volume flusher is deregistered and turned off.
File Access - implemented in FSFileOpsImpl
CreateFile: PROCEDURE [vol: File.Volume, pages: INT, VMBackingFile: BOOLFALSE] RETURNS [fp: File.FP, h: File.Handle];
Creates a new file of the indicated length. Maps any File.Error's generated into FS.Error's.
OpenFile: PROCEDURE [vol: File.Volume, fp: File.FP] RETURNS [File.Handle];
Opens the indicated file. Maps any File.Error's generated into FS.Error's.
LPCreatedTime: PROCEDURE [vol: File.Volume, fp: File.FP] RETURNS [BasicTime.GMT];
Returns the created-time from the leader page of the indicated file. Maps any File.Error's generated into FS.Error's.
GetFileInfo: PROCEDURE [h: File.Handle] RETURNS [pages: INT, fp: File.FP];
Gets the page count of the indicated file. Maps any File.Error's generated into FS.Error's.
SetFilePages: PROCEDURE [h: File.Handle, pages: INT];
Sets the page count of the indicated file. Maps any File.Error's generated into FS.Error's.
DeleteFile: PROCEDURE [h: File.Handle];
Delete the indicated file. Maps any File.Error's generated into FS.Error's.
Property Page Access - implemented in FSPropertiesImpl
GetProps: PROCEDURE [f: File.Handle] RETURNS [bytes: INT, keep: CARDINAL, created: BasicTime.GMT];
Returns properties associated with the file whose handle is presented. Can produce FS.Error[$invalidPropertyPage]. Maps any File.Error's generated into FS.Error's.
GetNameBodyAndVersion: PROCEDURE [f: File.Handle] RETURNS [nameBody: Rope.Text, version: FSBackdoor.Version];
Returns the nameBody and version number for the file whose handle is presented. Can produce FS.Error[$invalidPropertyPage]. Maps any File.Error's generated into FS.Error's.
InitializePropertyStorage: PROCEDURE [fp: File.FP, propStorage: File.PropertyStorage];
To be passed to File.Create as the "report" call back procedure. Sets the validation stamp in the property page to mark the file as belonging to FS.
SetProps: PROCEDURE [f: File.Handle, bytes: INT, keep: CARDINAL, created: BasicTime.GMT, nameBody: Rope.Text, version: FSBackdoor.Version];
Sets the properties associated with the file whose handle is presented. "bytes" = -1 means don't change the byte count. "created" = BasicTime.nullGMT means don't change the created-time. Maps any File.Error's generated into FS.Error's.
SetBytesAndCreated: PROCEDURE [f: File.Handle, bytes: INT, created: BasicTime.GMT];
Sets the bytes count and created time in the leader page of the file whose handle is presented. The byte count is not altered if "bytes" = -1. The created-time is not altered if "created" is BasicTime.nullGMT. Can produce FS.Error[$invalidPropertyPage]. Maps any File.Error's generated into FS.Error's.
SetKeep: PROCEDURE [f: File.Handle, keep: CARDINAL];
Sets the keep in the leader page of the file whose handle is presented. Can produce FS.Error[$invalidPropertyPage]. Maps any File.Error's generated into FS.Error's.
File Streams - implemented in FSFileStreamImpl
FileStreamMode: TYPE = {oldReadOnly, newAppendOnly};
CreateFileStream: PROCEDURE [file: File.Handle, mode: FileStreamMode] RETURNS [IO.STREAM];
Produces a stream on the indicated file. If the "mode" is "oldReadOnly" then endOf, getIndex, setIndex, getChar, and getBlock are implemented. If the "mode" is "newAppendOnly" then getIndex and putBlock (at the end of the stream only!) are implemented.
Copy: PROCEDURE [from, to: File.Handle] RETURNS [bytes: INT, createdTime: BasicTime.GMT];
The number of bytes indicated by the byte count property of the "from" file are transfered from that file to the "to" file. The byte transfered and the created-time property of the "from" file are returned. Maps any File.Error's generated into FS.Error's.
END.