WalnutLogExpunge.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Willie-Sue, June 17, 1986 11:44:00 am PDT
Contents: types and procedures which take the current and expunge log streams as implicit parameters
DIRECTORY
IO USING [STREAM];
WalnutLogExpunge: CEDAR DEFINITIONS =
BEGIN
Managing the ExpungeLog
StartExpunge: PROC[pagesNeeded: INT] RETURNS[expungeFileID: INT];
Writes the first log record on the expunge log, from information from the root; returns the internalFileID of the expunge log being written on
RestartExpunge: PROC[currentLogPos, expungeLogLength: INT] RETURNS[ok: BOOL];
Set the length of the expunge log and the read position of the current log to be the given values. If it returns NOT ok, then you must StartExpunge -- StartExpunge is always guaranteed to succeed (if space exists!)
CopyBytesToExpungeLog: PROC[bytesToCopy: INT];
Copies bytesToCopy from the currentLog at its current position onto the end of the expungeLog; does not flush the expungeLog (must use GetExpungeProgress);
GetExpungeProgress: PROC[] RETURNS[currentLogPos, expungeLogLength: INT];
Get the read position of the current log and the length of the expunge log (this information can later be used to restart an expunge that was in progress); forces a flush (commit) of the expunge log - raises WalnutDefs.Error with code = $LogTransAbort if the flush fails
EndExpunge: PROC[];
Clears WalnutLogExpunge's local variables.
ExpShutdown: PROC[];
Clears WalnutLogExpunge's local variables.
Parsing a log for Expunging
ExpSetPosition: PROC[startPos: INT] RETURNS[charsSkipped: INT];
Set the position of the log to begin at the first log entry at or beyond startPos. Each of the parsing operations below take the current position of the log as an implicit argument. This procedure will skip ahead to the beginning of a log entry if startPos is not one -- the number of characters skipped is returned in charsSkipped.
ExpSetIndex: PROC[pos: INT];
sets the current log to the indicated position; used during expunge. The difference with SetPosition is that this asserts that the position is at the beginning of a log entry.
PeekEntry: PROC[] RETURNS[ident: ATOM, msgID: REF TEXT, at: INT];
returns at = -1 if there is not a valid entry at the current position. The entry is not "consumed" so that performing a NextEntry or a CopyEntry after reading the ident & msg ID information will copy or retrieve the entry returned. Performing successive PeekEntry's will NOT advance the log position; use SkipEntry to advance the log
Does not check if ident is for a legal log entry type.
SkipEntry: PROC[] RETURNS[ok: BOOL];
returns NOT ok if there is not a valid entry at the current position, and does not advance the log position. If there is a valid entry, it is "consumed", and the log is advanced.
CopyEntry: PROC[] RETURNS[newPosition, bytesCopied: INT];
Copies the next entry from the current log to the expunge log; it returns the new position that the entry now has in the expunge log; does NOT flush (commit) the expungeLog, raises WalnutDefs.Error with code = $ExpungeTransAbort if the expunge transaction aborts
EndCopyEntry: PROC RETURNS[startCopyPos: INT];
the only two entries that logExpunge needs to be able to parse - raises WalnutDefs.Error if the current entry is not an EndCopyXXInfo entry; does not advance the current position
ExpLogLength: PROC[] RETURNS[length: INT];
returns the length of the current log file
-- the following are used by the WalnutRescue code
EntryStatus: TYPE = { validEntry, noValidEntry, EndOfStream };
GetIndex: PROC RETURNS[curPos: INT];
returns the index of the current log file
CopyBytes: PROC[strm: IO.STREAM, num: INT];
copies num bytes from the current position of the current log to the end of strm
ExamineThisEntry: PROC RETURNS[status: EntryStatus];
returns noValidEntry if there is not a valid entry at the current position, and does not advance the log position. If there is a valid entry, it is "consumed", and the log is advanced.
IF IO.EndOfStream is raised, EndOfStream is returned and log is not advanced.
END.