Hardware manual
CreateDiskFile(disk, name, filePtr, dirFilePtr, word1 [0], useOldFp [false], pageBuf[0])
Creates a new disk file and writes its leader page. It returns the serial number and leader disk address in
the FP structure filePtr. A newly created file has one data page (page 1) with numChars eq 0.
The arguments beyond filePtr are optional, and have the following significance:
If dirFilePtr is supplied, it should be a file pointer to the directory which owns the file. This file
pointer is written into the leader page, and is used by the disk Scavenger to put the file back into the
directory if it becomes lost. It defaults to the root directory, SysDir.
The value of word1 is "or"ed into the filePtr>>FP.serialNumber.word1 portion of the file pointer.
This allows the directory and random bits to be set in the file id.
If useOldFp is true, then filePtr already points to a legal file; the purpose of calling CreateDiskFile is
to re-write all the labels of the existing file with the new serial number, and to re-initialize the leader
page. The data contents of the original file are lost. Note that this process effectively "deletes" the file
described by filePtr when CreateDiskFile is called, and makes a new file; the FP for the new file is
returned in filePtr.
If pageBuf is supplied, it is written on the leader page of the new file after setting the creation date and
directory FP hint (if supplied). If pageBuf is omitted, a minimal leader page is created.
DeleteDiskPages(disk, CA, firstDA, filePtr, firstPage, newFp, hintLastPage)
Arguments beyond firstPage are optional. Deletes the pages of a file, starting with the page whose number
is firstPage and whose disk address is firstDA. CA is a page-sized buffer which is clobbered by the routine.
hintLastPage is as described under ActOnDiskPages.
If newFp is supplied and nonzero, it (rather than freePageFp) is installed as the FP of the file, and the
pages are not deallocated.
6. Allocating Disk Space
The disk class also contains routines for allocating space and for converting between virtual and real disk
addresses. In most cases, users need not call these routines directly, as the four routines given above
(ActOnDiskPages, WriteDiskPages, DeleteDiskPages, CreateDiskFile) manage disk addresses and disk
space internally.
AssignDiskPage(disk, virtualDA, nil) returns the virtual disk address of the first free page following
virtualDA, according to the bit table, and sets the corresponding bit. It does not do any checking that the
page is actually free (but WriteDiskPages does). If there are no free pages it returns -1. If it is called with
three arguments, it returns true if (virtualDA+1) is available without assigning it.
If virtualDA is eofDA, AssignDiskPage makes a free-choice assignment. The disk object remembers the
virtual DA of the last page assigned and uses it as the first page to attempt to assign next time
AssignDiskPage is called with a virtualDA of eofDA. This means that you can force a file to be created
starting at a particular virtual address by means of the following strategy:
ReleaseDiskPage(disk, AssignDiskPage(disk, desiredVDA-1))
CreateDiskFile(disk, ...) // or whatever (e.g., OpenFile)
ReleaseDiskPage(disk, virtualDA) marks the page as free in the bit table. It does not write anything on the
disk (but DeleteDiskPages does).
VirtualDiskDA(disk, lvRealDA) returns the virtual disk address, given a real disk address in rv lvRealDA.
Disks & Bfs August 10, 1980 58
For Xerox Internal Use Only -- December 15, 1980










