BigDiskImpl.mesa
L. Stewart, April 19, 1983 2:31 pm
DIRECTORY
BigDisk,
ConvertUnsafe USING [ToRope],
Device USING [nullType, Type],
IO,
PhysicalVolume,
Rope USING [Equal, ROPE],
Volume;
BigDiskImpl: PROGRAM
IMPORTS ConvertUnsafe, IO, PhysicalVolume, Rope, Volume
EXPORTS BigDisk =
BEGIN
BringVolumesOnline: PUBLIC PROC [out: IO.STREAM] = {
deviceType: Device.Type ← Device.nullType;
deviceIndex: CARDINAL ← PhysicalVolume.nullDeviceIndex;
DO
[nextType: deviceType, nextIndex: deviceIndex] ← PhysicalVolume.GetNextDrive[
deviceType, deviceIndex];
IF deviceIndex = PhysicalVolume.nullDeviceIndex THEN EXIT
ELSE {
physicalVolumeHandle: PhysicalVolume.Handle ←
PhysicalVolume.GetHandle[deviceType, deviceIndex];
IF PhysicalVolume.IsReady[physicalVolumeHandle] THEN {
physicalVolumeID: PhysicalVolume.ID;
logicalVolumeID: Volume.ID;
asserted: BOOL;
volumeSize, freePageCount: Volume.PageCount;
volumeType: Volume.Type;
label: STRING ← [100];
label.length ← 0;
asserted ← FALSE;
[] ← PhysicalVolume.GetHints[instance: physicalVolumeHandle, label: label];
out.PutF["Physical Volume: %g", IO.string[label]];
physicalVolumeID ← PhysicalVolume.AssertPilotVolume[
physicalVolumeHandle ! PhysicalVolume.Error =>
IF error = alreadyAsserted THEN {
out.PutRope[" alreadyAsserted"];
asserted ← TRUE;
CONTINUE;
}];
out.PutRope["\n"];
IF asserted THEN {
pvType: PhysicalVolume.VolumeType;
label.length ← 0;
[pvID: physicalVolumeID, volumeType: pvType] ← PhysicalVolume.GetHints[instance: physicalVolumeHandle, label: label];
IF pvType # isPilot THEN {
out.PutRope[" ... not a pilot volume\n"];
LOOP;
};
};
logicalVolumeID ← Volume.nullID;
DO
logicalVolumeStatus: Volume.Status;
logicalVolumeID ← PhysicalVolume.GetNextLogicalVolume[
physicalVolumeID, logicalVolumeID ! PhysicalVolume.Error => {
IF error = physicalVolumeUnknown THEN {
logicalVolumeID ← Volume.nullID;
CONTINUE;
};
}];
IF logicalVolumeID = Volume.nullID THEN EXIT;
logicalVolumeStatus ← Volume.GetStatus[logicalVolumeID];
label.length ← 0;
[volumeSize: volumeSize, freePageCount: freePageCount] ← Volume.GetAttributes[volume: logicalVolumeID];
volumeType ← Volume.GetType[volume: logicalVolumeID];
Volume.GetLabelString[volume: logicalVolumeID, s: label];
out.PutF[" Logical volume %g, size: %d, free: %d ", IO.string[label], IO.card[volumeSize], IO.card[freePageCount]];
out.PutF["type: %g, status: %g\n", IO.refAny[NEW[Volume.Type ← volumeType]], IO.refAny[NEW[Volume.Status ← logicalVolumeStatus]]];
IF NOT asserted AND logicalVolumeStatus = closedAndConsistent THEN {
Volume.Open[logicalVolumeID];
out.PutRope[" ...opened\n"];
};
ENDLOOP;
};
};
ENDLOOP;
};
END.
LCS, April 19, 1983 9:45 am, stolen from Alpine InitProcsImpl