20.12 alloc (6965)

This is called by “bmap” (6435, 6448, 6468, 6480, 6497) whenever a new storage block is needed to store part of a file.

6961:

Convert knowledge of the device name into a pointer to the “super block”;

6962:

If “s_flock” is set, the list of available blocks is currently being updated by another process;

6967:

Obtain the block number of the next available storage block;

6968:

If the last block number on the list is zero, the entire list is now empty;

6970:

“badblock” (7040) is used to check that the block number obtained from the list seems reasonable;

6971:

If the list of available blocks in the “super block” is now empty, then the block just located will contain the addresses of the next group of

6972:

Set “s_flock” to delay any other process from getting a “no space” indication before the list of available blocks in the “super block” can be replenished;

6975:

Determine the number of valid entries in the list to be copied;

6978:

Reset “s_flock”, and “wakeup” anyone waiting;

6982:

Clear the buffer so that any information recorded in the file by default will be all zeros;

6983:

Set the “modified” flag to ensure that the “super block” will be written out by “update” (7213).