-- Volume.mesa (last edited by: Levin on: August 25, 1982 9:33 am)

DIRECTORY
  File USING [Capability],
  System USING [NetworkAddress, nullID, VolumeID];

Volume: DEFINITIONS =

BEGIN


-- Volume identifiers

ID: TYPE = System.VolumeID; -- = RECORD[System.UniversalID]

nullID: ID = ID[System.nullID];
systemID: READONLY ID; -- ID of system volume

SystemID: SAFE PROC RETURNS [ID] = CHECKED INLINE { RETURN[systemID] };


-- Volume addressing

maxPagesPerVolume: LONG CARDINAL = 8388607;	-- = 223 - 1
PageCount: TYPE = LONG CARDINAL;	-- simulates TYPE = [0..maxPagesPerVolume]
firstPageCount: PageCount = 0;
lastPageCount: PageCount = maxPagesPerVolume;


-- Attributes

Type: TYPE = MACHINE DEPENDENT {normal(0), debugger(1), debuggerDebugger(2), nonPilot(3)};

maxNameLength: CARDINAL = 40; -- maximum name length of a volume's labelString.

GetAttributes: SAFE PROC [volume: ID]
  RETURNS [volumeSize, freePageCount: PageCount, rootFile: File.Capability];

GetLabelString: PROC [volume: ID, s: STRING];

GetType: SAFE PROC [volume: ID] RETURNS [type: Type];

SetRootFile: PROC [volume: ID, file: File.Capability];


-- Mounting and unmounting volumes

Status: TYPE = {unknown, partiallyOnLine, closedAndInconsistent, closedAndConsistent, open};

BooleanDefaultFalse: TYPE = BOOLEAN ← FALSE;
TypeSet: TYPE = PACKED ARRAY Type OF BooleanDefaultFalse;
onlyEnumerateCurrentType: TypeSet = []; -- all false

Close: PROC [volume: ID];
Open: SAFE PROC [volume: ID];

GetNext: SAFE PROC [volume: ID, includeWhichVolumes: TypeSet ← onlyEnumerateCurrentType]
  RETURNS [nextVolume: ID]; 
  -- returns ID's of all completely online (but not necessarily open) volumes.  If all elements of includeWhichVolumes are FALSE, returns only volumes satisfying GetType[nextVolume]=GetType[systemID]; if any elements of includeWhichVolumes are TRUE, returns only volumes satisfying includeWhichVolumes[GetType[nextVolume]]=TRUE.

GetStatus: SAFE PROC [volume: ID] RETURNS [Status];


-- Locating volumes

IsOnServer: SAFE PROC [volume: ID, netAddress: System.NetworkAddress];


-- Signals and errors

InsufficientSpace: ERROR;
NeedsScavenging: ERROR;
NotOpen: ERROR [volume: ID];
Unknown: ERROR [volume: ID];

END.

LOG

Time: January 25, 1980  7:53 PM	By: Forrest	Action: Deleted InvalidLabelString
Time: May 15, 1980  4:28 PM	By: McJones	Action: Added NeedsScavenging
Time: July 13, 1980  10:12 PM	By: Forrest	Action: Moved in GetStatus (originally in PhysicalVolume)
Time: July 15, 1980  10:27 PM	By: Forrest	Action: Move in GetType, expand GetNext
Time: August 15, 1980  2:49 PM	By: McJones	Action: VolumeSet=>TypeSet
Time: August 25, 1982 9:33 am	By: Levin	Action: Make things SAFE.