FSDir.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Bob Hagmann February 4, 1985 9:44:11 am PST
Schroeder, November 15, 1983 1:19 pm
Levin, August 9, 1983 11:22 am
DIRECTORY
Basics USING [Comparison],
BasicTime USING [GMT],
BTree USING [Entry, EntSize, Key, UpdateType],
File USING [FP],
FSBackdoor USING [EntryPtr, EntryType, Version],
FSFileOps USING [VolumeDesc],
FSLock USING [ActiveFile],
Rope USING [Text];
FSDir: CEDAR DEFINITIONS = BEGIN
VersionMatching: TYPE = {all, bangHOnly, bangLOnly};
EnumerateEntries: PROCEDURE [vDesc: FSFileOps.VolumeDesc, start: Rope.Text ← NIL, versions: VersionMatching ← all, matchProc: UNSAFE PROC [entry: FSBackdoor.EntryPtr] RETURNS [accept, stop: BOOLEAN], acceptProc: PROC RETURNS [stop: BOOLEAN]];
Enumerates the directory/cache, starting from the name prefix "start", in increasing order. "matchProc" is called for the versions of each entry as selected by "versions". If ""stop" is returned as TRUE then the enumeration terminates. Otherwise, if "accept" is returned as TRUE then "acceptProc" is called. The "acceptProc" can also stop the enumeration. The dir/cache is read locked while "matchProc" is called, but not while "acceptProc" is called.
AcquireOldFName: PROC [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, wantedVersion: FSBackdoor.Version, wantedTime: BasicTime.GMT] RETURNS [type: FSBackdoor.EntryType, version: FSBackdoor.Version, keep: CARDINAL, fp: File.FP, time: BasicTime.GMT, attachedTo: Rope.Text, a: FSLock.ActiveFile];
Looks-up an old entry in the directory/cache BTree and sets its record lock. Will do a created-time search if "wantedTime" is not BasicTime.nullGMT, treating the version as a hint. Any waiting is done before the return.
When "type" does not return "notFound" then "a" is valid. If a local entry is found then the "version", "keep" and "fp" are meaningful. If an attached entry is found then the "version", "keep", "time" (created-time), and "attachedTo" are meaningful. If a cached entry is found then the "version", "time" (used-Time) and "fp" are meaningful.
AcquireNextLName: PROC [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, newKeep: CARDINAL ← 0] RETURNS [a: FSLock.ActiveFile, keep: CARDINAL, fp: File.FP];
Sets the record lock on the !N version of "nameBody". Use only for LNames. Any waiting is done before the return. Any existing version of "nameBody" that are beyond the "keep" are deleted. If "newKeep" is 0 then the keep on the highest existing version is in control; otherwise "newKeep" is used. If one of the deleted entries contains an File.FP suitable for reuse, then it is returned as "fp" (which otherwise is File.nullFP). The client should either reuse the file or destroy it. If "a.version" is # 1, then "keep" is the new controlling keep.
DoKeeps: PROC [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text];
Does the keep processing for the given LName. Any unopen files beyond the keep for the highest version will be deleted.
AcquireOldGName: PROC [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, wantedVersion: FSBackdoor.Version] RETURNS [type: FSBackdoor.EntryType, time: BasicTime.GMT, fp: File.FP, a: FSLock.ActiveFile];
Tries to set the record lock on the indicated version of "nameBody". Use only on GNames. No created-time searching is done. Never waits. It is intended for use in locking GNames when considering flushing them to make space on the volume. Returns "type" = "notFound" if the GName was missing from the cache. Returns "a" = NIL if the record lock could not be set. Generate ERROR if a local or an attached entry is found.
AcquireOldOrNewGName: PROC [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, wantedVersion: FSBackdoor.Version] RETURNS [fp: File.FP, a: FSLock.ActiveFile];
Sets the record lock on the indicated version of "nameBody", whether or not it already exists. Use only on GNames. No created-time searching is done. Any waiting is done before the return. It is intended for use in locking GNames prior to retrieval of the remote file. Possible results are:
"fp" is File.nullFP and "a.h" is NIL => "wantedVersion" is not in the cache, so must be retrieved; a "name" lock is set and "a.h" must be filled in.
"fp" is valid and "a.h" is NIL => "wantedVersion" is in the cache, so need not be retrieved; a "name" lock is set and "a.h" must be filled in.
"fp" is valid and "a.h" is NOT NIL => "wantedVersion" is in the cache, so need not be retrieved; a "read" lock is set and "a.h" is already filled-in; client should verify that the created time of the file is as expected before finishing opening it.
Procedures to update the directory/cache BTree.
UpdateLocalEntry: PROCEDURE [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, version: FSBackdoor.Version, keep: CARDINAL, fp: File.FP, update: BTree.UpdateType];
Creates/updates an entry for a local file to the directory BTree. Will generate BTree.Error[wrongUpdateType] if the "BTree.UpdateType" cannot be realized.
UpdateCachedEntry: PROCEDURE [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, version: FSBackdoor.Version, used: BasicTime.GMT, fp: File.FP, update: BTree.UpdateType];
Creates/updates an entry for a cached global file to the directory BTree. Will generate BTree.Error[wrongUpdateType] if the "BTree.UpdateType" cannot be realized.
UpdateAttachedEntry: PROCEDURE [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, version: FSBackdoor.Version, keep: CARDINAL, created: BasicTime.GMT, attachedTo: Rope.Text, update: BTree.UpdateType];
Creates/updates an entry for an attached LName file to the directory BTree. Will generate BTree.Error[wrongUpdateType] if the "BTree.UpdateType" cannot be realized.
DeleteEntry: PROCEDURE [vDesc: FSFileOps.VolumeDesc, nameBody: Rope.Text, version: FSBackdoor.Version];
Removes an entry from the directory BTree.
For use with the BTree package.
Compare: UNSAFE PROC [key: BTree.Key, entry: BTree.Entry] RETURNS [Basics.Comparison];
Matches requirements of a BTree.Compare proc.
EntrySize: UNSAFE PROC [entry: BTree.Entry] RETURNS [words: BTree.EntSize];
Matches requirements of a BTree.EntrySize proc.
END.
Bob Hagmann February 4, 1985 9:43:46 am PST
Copyright