YggNaming.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Bob Hagmann January 24, 1989 10:32:33 am PST
DIRECTORY
BTree USING [UpdateType],
Rope USING [ROPE],
YggDID USING [DID],
YggEnvironment USING [TransID];
Directories
MkDir:
PROC [trans: YggEnvironment.TransID, did: YggDID.
DID] RETURNS [directoryAlreadyExists: BOOL];
! $commitFailed => bug; should always commit.
Make a new directory. If trans is not null, then a directory lock on the did is held. Caller should commit soon.
RmDir:
PROC [trans: YggEnvironment.TransID, did: YggDID.
DID] RETURNS [directoryDoesNotExist: BOOL];
! $nullTransaction => RmDir needs a real transaction
! $cantGetDirectoryLock => could not get write lock; retry might work
Destroy a directory. trans has to be a valid transaction. A directory lock on the did is held. Caller should commit soon.
Files
UpdateItem:
PROC [trans: YggEnvironment.TransID, directoryDid: YggDID.
DID, name:
ROPE, version:
ROPE, did: YggDID.
DID, updateType: BTree.UpdateType ← insertOrReplace]
RETURNS [notADirectory:
BOOL, nameFound:
BOOL];
! $nullTransaction => UpdateItem needs a real transaction
! $cantGetDirectoryLock => could not get write lock; retry might work
! $badVersionSpec => version specification is bogus
Update the name/version in the directory property of the directoryDid. If nameFound is TRUE, then the name/version specifies a file that already exists and updateType was insert; no update occured. The version must be an explicit version or the string "h". An updateType = insert with a version of "h" means insert a new version with its version number one more than the highest version found.
DeleteItem:
PROC [trans: YggEnvironment.TransID, directoryDid: YggDID.
DID, name:
ROPE, version:
ROPE]
RETURNS [found:
BOOLEAN];
! $nullTransaction => UpdateItem needs a real transaction
! $cantGetDirectoryLock => could not get write lock; retry might work
! $badVersionSpec => version specification is bogus
Delete the name/version's in the directory property of the directoryDid.
Lookup:
PROC [trans: YggEnvironment.TransID, directoryDid: YggDID.
DID, namePattern:
ROPE, version:
ROPE]
RETURNS [nameFound:
BOOL, moreThanOneMatch:
BOOL, didFound: YggDID.
DID, nameMatched:
ROPE, versionMatched:
ROPE];
Look up the name/version in the directory property of the directoryDid. The namePattern may include "*" characters. The version is either NIL (highest version), "h" (highest version), "l" (lowest version), or the ASCII string for a number (base 10). If nameFound is TRUE, then the name/version specifies a single file and it's did is returned in didFound while its name/version is returned in nameMatched and versionMatched. If nameFound is FALSE but moreThanOneMatch is TRUE, then the name/version specifies more than one file. didFound is not interesting. If both nameFound and moreThanOneMatch are FALSE, then no names match the name/version and didFound is not interesting.
Version: TYPE = RECORD [CARDINAL];
EnumProc: TYPE = PROC [name: REF TEXT, version: Version, did: YggDID.DID] RETURNS [stop: BOOL ← FALSE];
EnumerateEntries:
PROC [trans: YggEnvironment.TransID, directoryDid: YggDID.
DID, namePattern:
ROPE, version:
ROPE, nameToStart:
ROPE, nameToStartVersion:
ROPE, proc: EnumProc] RETURNS [notADirectory:
BOOL, completedEnumerate: BOOL];
! $cantGetDirectoryLock => could not get read lock; retry might work
Calls `proc' for each entry in the specified matching key values (see Lookup above). The enumeration is halted when either the matching of entries is exhausted or `proc' returns FALSE. If non-NIL, nameToStart/nameToStartVersion is less than or equal to all the names presented.
HasDirectory:
PROC [trans: YggEnvironment.TransID, directoryDid: YggDID.
DID]
RETURNS [isDirectory:
BOOL];
Returns TRUE iff there is a directory contents
Transactions
PreCommit: PROC[tid: YggEnvironment.TransID];
Commit: PROC[tid: YggEnvironment.TransID];
Abort:
PROC[tid: YggEnvironment.TransID];