This is called by “bmap” (6435, 6448, 6468, 6480, 6497) whenever a new storage block is needed to store part of a file.
Convert knowledge of the device name into a pointer to the “super block”;
If “s_flock” is set, the list of available blocks is currently being updated by another process;
Obtain the block number of the next available storage block;
If the last block number on the list is zero, the entire list is now empty;
“badblock” (7040) is used to check that the block number obtained from the list seems reasonable;
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
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;
Determine the number of valid entries in the list to be copied;
Reset “s_flock”, and “wakeup” anyone waiting;
Clear the buffer so that any information recorded in the file by default will be all zeros;
Set the “modified” flag to ensure that the “super block” will be written out by “update” (7213).