DIRECTORY Basics USING [logBytesPerWord], Camelot USING [optrT, tidT], IO USING [STREAM], Mach USING [pointerT], YggDID USING [DID], YggDIDMap USING [RunList], YggInternal USING[FileHandle]; YggFile: CEDAR DEFINITIONS = BEGIN RC: TYPE = { -- extension of "Reason" for internal use. ok, inconsistent, -- the volume's (or file's) permanent data structures look inconsistent software, -- i.e. label-check. The page on disk is not the one the software expected. hardware, -- the disk hardware/microcode detected a hard disk error unknownFile, -- the file does not exist (possibly deleted since it was opened) unknownPage, -- the page would be beyond the end of the file volumeFull -- the volume has no free pages (and one is needed!) }; Reason: TYPE = RC[SUCC[ok]..LAST[RC]]; -- error reason Error: ERROR [why: Reason, diskPage: INT _ -1]; PageNumber: TYPE = RECORD[INT]; PageCount: TYPE = INT; Add: PROC[p: PageNumber, n: PageCount] RETURNS[PageNumber] = INLINE { RETURN[ [p+n] ] }; -- "n" may be negative -- bytesPerPage: NAT = 4096; logBytesPerPage: NAT = 12; wordsPerPage: NAT = bytesPerPage/BYTES[WORD]; logWordsPerPage: NAT = logBytesPerPage-Basics.logBytesPerWord; PagesForBytes: PROC [bytes: CARD] RETURNS [pages: PageCount]; BytesForPages: PROC [pages: PageCount] RETURNS [bytes: CARD]; PagesForWords: PROC [words: CARD] RETURNS [pages: PageCount]; WordsForPages: PROC [pages: PageCount] RETURNS [words: CARD]; FileHandle: TYPE = YggInternal.FileHandle; FileHandleRep: TYPE; Open: PROC [runList: YggDIDMap.RunList, did: YggDID.DID, fileUse: ATOM, verifyLeaderNow: BOOL _ FALSE] RETURNS [file: FileHandle]; Create: PROC [size: PageCount, did: YggDID.DID, fileUse: ATOM, nearToDid: YggDID.DID, tid: Camelot.tidT] RETURNS [FileHandle]; Delete: PROC [file: FileHandle, tid: Camelot.tidT]; Info: PROC [file: FileHandle, tid: Camelot.tidT] RETURNS [did: YggDID.DID, size: PageCount, runList: YggDIDMap.RunList]; SetSize: PROC [file: FileHandle, size: PageCount, tid: Camelot.tidT]; SetByteSize: PROC [file: FileHandle, byteSize: PageCount, tid: Camelot.tidT]; Locate: PROC [file: FileHandle, tid: Camelot.tidT, from: PageNumber, nPages: PageCount] RETURNS [runList: YggDIDMap.RunList]; FileFromComponentFiles: PROC [componentFiles: LIST OF YggInternal.FileHandle, fileUse: ATOM] RETURNS [file: YggInternal.FileHandle]; FileUseFromComponentFiles: PROC [componentFiles: LIST OF YggInternal.FileHandle] RETURNS [fileUses: LIST OF ATOM]; StreamFromOpenFileAndTid: PROC[file: FileHandle, tid: Camelot.tidT] RETURNS [stream: IO.STREAM]; OpenDIDMapFile: PROC RETURNS [file: YggInternal.FileHandle]; GetMaxDIDAddress: PROC RETURNS [optr: Camelot.optrT, address: Mach.pointerT]; PreCommit: PROC[tid: Camelot.tidT]; Commit: PROC[tid: Camelot.tidT]; Abort: PROC[tid: Camelot.tidT] END. ΤYggFile.mesa Copyright Σ 1988 by Xerox Corporation. All rights reserved. Bob Hagmann October 17, 1988 11:40:25 am PDT Introduction This interface provides for creating, accessing and deleting files. Files are permanent objects recorded on Camelot recoverable backing storage segments. Each file consists of a number of pages from a variety of segments. The data pages of a file can be read and written. Files can be extended or contracted. Errors Types and Constants Actually, [0..LAST[INT]). The file-relative number of a data page. The first data page of a file is numbered 0. Actually [0..LAST[INT]]. Represents file sizes. The number of bytes in each data page of a file. The runtime representation of a file. NIL never represents a valid file. Files Open the file with this run list. If verifyLeaderNow is true, verify that the leader matches the runList now, instead of delaying the access. Destroys the file. Read: UNSAFE PROC [file: FileHandle, tid: Camelot.tidT, from: PageNumber, nPages: PageCount, to: LONG POINTER]; Write: UNSAFE PROC [file: FileHandle, tid: Camelot.tidT, to: PageNumber, nPages: PageCount, from: LONG POINTER]; Streams Select a file Find the uses of all the files DID Map Transactions ΚK˜codešœ ™ Kšœ<™Kšœ0™0—K˜K˜Kš  œœ œœ˜=Kš  œœœ œ˜=Kš  œœ œœ˜=Kš  œœœ œ˜=K˜Kšœ œ˜*šœœ˜KšœI™I—K˜—šœ™š œœ)œ œœœœ˜‚KšœŽ™Ž—K˜Kš  œœœ œœœ ˜~K˜š œœ&˜3Kšœ™—K˜Kš œœ&œœ/˜xK˜Kš œœ7˜EK˜Kš  œœ;˜MK˜Kš œœKœ˜}K˜Kš  œœœOœœ™oK™Kš œ œOœœ™pK˜—™š  œœœœ"œœ ˜„K™ —K˜š œœœœœ œœœ˜rK™K˜—Kš  œœ&œ œœ˜`K˜—šœ™Kš œœœ ˜