<> <> <> <> <> <> DIRECTORY IO USING [STREAM], Rope USING [ROPE]; YggDummyFile: CEDAR DEFINITIONS = BEGIN <> <> <> RC: TYPE = { -- extension of "Reason" for internal use. ok, wentOffline, -- volume is not accessible (some drive has been offline) nonCedarVolume, -- the operation is not possible on a non-cedar (Pilot?) volume. 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!) fragmented, -- the file requires too many non-contiguous areas of disk mixedDevices, -- a bootable file is not entirely on one device, or not on correct device wrongVolume -- a bootable file is not on the correct volume }; Reason: TYPE = RC[SUCC[ok]..LAST[RC]]; -- error reason Error: ERROR [why: Reason, diskPage: INT _ -1]; <> <> VolumeID: TYPE[UNITS[CARD32]]; <> NullVolumeRep: PRIVATE TYPE = RECORD[a:CARD32]; nullVolumeID: VolumeID = LOOPHOLE[NullVolumeRep[a:0]]; <> Volume: TYPE = REF VolumeObject; VolumeObject: TYPE; <> VolumeFile: TYPE = MACHINE DEPENDENT { -- root files of a volume checkpoint(0), microcode(1), germ(2), bootFile(3), debugger(4), -- outload file -- debuggee(5), -- outload file -- VM(6), -- virtual memory backing file -- VAM(7), -- volume allocation map -- fs(8), -- client directory system root file -- alpine(9), -- for use by Alpine file servers -- acacia (10), -- for use by Acacia file servers -- namedSpare (11), -- a named entry that is spare -- logFile (12), -- file system log file -- fs2(13), -- client directory system root file copy 2 -- logFile2 (14), -- file system log file copy 2 -- (18) -- spare root page slots -- }; CedarVolumeSubType: TYPE = MACHINE DEPENDENT { other (0), FS(1), -- If volatile then expect FS to compute the VAM Alpine(2), -- If volatile then expect Alpine to compute the VAM FSAndAlpine(3) -- If volatile then expect both FS and Alpine to contribute to computing the VAM }; OldFP: TYPE = MACHINE DEPENDENT RECORD[ <> id(0): FileID, da(WORDS[FileID]): OldDA ]; FP: TYPE = MACHINE DEPENDENT RECORD[ <> id(0): FileID, da(WORDS[FileID]): DA ]; FileID: TYPE[UNITS[CARD32]]; OldDA: TYPE[UNITS[CARD32]]; DA: TYPE = REF DAObj; DAObj: TYPE; NullFileIDRep: PRIVATE TYPE = RECORD[a:CARD32]; NullDARep: PRIVATE TYPE = RECORD[a:CARD32]; nullDA: PRIVATE DA = LOOPHOLE[NullDARep[0]]; NullOldDARep: PRIVATE TYPE = RECORD[a:CARD32]; nullOldDA: PRIVATE OldDA = LOOPHOLE[NullOldDARep[0]]; nullOldFP: OldFP = [id: nullFileID, da: nullOldDA]; <> <<>> nullFP: FP = [id: nullFileID, da: nullDA]; <> nullFileID: FileID = LOOPHOLE[NullFileIDRep[0]]; <> PageNumber: TYPE = RECORD[INT]; <> PageCount: TYPE = INT; <> Add: PROC[p: PageNumber, n: PageCount] RETURNS[PageNumber] = INLINE { RETURN[ [p+n] ] }; -- "n" may be negative -- <> <<>> wordsPerPage: NAT = 256; logWordsPerPage: NAT = 8; <> PagesForWords: PROC[w: INT] RETURNS[PageCount]; SectorsForWords: PROC[w: INT, volume: Volume] RETURNS[PageCount]; WordsForSectors: PROC[pages: PageCount, volume: Volume] RETURNS[INT]; Handle: TYPE = REF Object; Object: TYPE; <> PropertyStorage: TYPE = LONG POINTER TO RECORD[SEQUENCE COMPUTED CARDINAL OF WORD]; <> <> NextVolume: PROC[volume: Volume, wait: BOOL _ FALSE] RETURNS[Volume]; <> LogicalInfo: PROC[volume: Volume] RETURNS[ id: VolumeID, size: INT, rootStatus: RC, <> name: Rope.ROPE, vamStatus: RC, labeled: BOOL, subType: CedarVolumeSubType, -- unlabeled only volatileVAM: BOOL, -- unlabeled only vamStable: BOOL, -- unlabeled only updateNumber: CARD, <> free: INT, freeboard: INT ]; <> GetVolumeID: PROC[volume: Volume] RETURNS[id: VolumeID]; <> <> GetVolumeName: PROC[volume: Volume] RETURNS[Rope.ROPE]; <> <> FindVolumeFromID: PROC[id: VolumeID] RETURNS[Volume]; <> FindVolumeFromName: PROC[name: Rope.ROPE] RETURNS[Volume]; <> SystemVolume: PROC RETURNS[Volume]; <> SetSystemVolume: PROC[Volume]; <> FindSystemVolume: PROC RETURNS[found: BOOL]; <> FindVM: PROC RETURNS[found: BOOL]; <> <> LabeledOpen: PROC[volume: Volume, fp: OldFP] RETURNS[Handle]; <> <> <> <<>> Open: PROC[volume: Volume, fp: FP, name: Rope.ROPE _ NIL, verifyFPNow: BOOL _ FALSE] RETURNS[Handle]; <> <> <> <> Create: PROC[volume: Volume, size: PageCount, report: PROC[OldFP, PropertyStorage, PageCount] _ NIL, name: Rope.ROPE _ NIL, specialFile: BOOL _ FALSE, makeContiguous: BOOL _ FALSE] RETURNS[Handle]; <> <> <> <<"specialFile" should be asserted only for key system files (e.g., the FS root file). These files will be allocated near the center of the volume to decrease disk arm motion and have replicated leader pages. Wizards only.>> <<"makeContiguous" should be asserted only for key system files that must be contiguous (e.g., the germ). If the file is later extended, it not guaranteed to remain contiguous.>> Delete: PROC[file: Handle]; <> <> Info: PROC[file: Handle] RETURNS [volume: Volume, labeled: BOOL, fp: OldFP, newfp: FP, size: PageCount, name: Rope.ROPE]; <> <> SetSize: PROC[file: Handle, size: PageCount]; <> <> Read: UNSAFE PROC[file: Handle, from: PageNumber, nPages: PageCount, to: LONG POINTER]; <> <> Write: PROC[file: Handle, to: PageNumber, nPages: PageCount, from: LONG POINTER]; <> <> GetProperties: PROC[file: Handle] RETURNS[prop:PropertyStorage, nPages: PageCount]; <> <> SetPropertiesSize: PROC[file: Handle, nPages: PageCount]; <> <<>> WriteProperties: PROC[file: Handle]; <> <> <> StreamFromOpenFile: PROC [openFile: Handle] RETURNS [IO.STREAM]; END. <<>> <> <> <> <<>> <> <> <> <> <<>> <> <>