// RWDD.bcpl - Read/Write DiskDescriptor
//	temporary until I can fit this into the new BFS somehow
// Copyright Xerox Corporation 1979
// Last modified October 11, 1978  5:55 PM by Boggs

get "AltoFileSys.d"
get "Disks.d"
get "BFS.d"

external
[
//outgoing procedures
WriteDiskDescriptor; ReadDiskDescriptor

//incoming procedures
OpenFile; Closes; ReadBlock; PositionPage; GetCurrentFa
BFSWriteDiskDescriptor

//incoming statics
sysDisk; fpDiskDescriptor
]

// These routines only work on a BFSDSK
// and will be moved into a BFS module eventually.

//---------------------------------------------------------------------------
let WriteDiskDescriptor() = BFSWriteDiskDescriptor(sysDisk)
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
and ReadDiskDescriptor() be
//---------------------------------------------------------------------------
[
let dds = OpenFile("DiskDescriptor", 0, 0, 0, fpDiskDescriptor)
ReadBlock(dds, sysDisk>>DSK.diskKd, lKDHeader)

// Save virtual disk addresses of disk descriptor pages
for i = 1 to (lKDHeader+sysDisk>>BFSDSK.diskBTsize-1) rshift BFSlnWordsPerPage +1 do
   [
   PositionPage(dds, i)
   let fa = vec lFA
   GetCurrentFa(dds, fa)
   sysDisk>>BFSDSK.VDAdiskDD↑i = fa>>FA.da
   ]

Closes(dds)
]