18.21 bmap (6415)

A general description of the function of “bmap” may be found on Page 2 of “FILE SYSTEM (V)” of the UPM.

6423:

Files of more than 2**15 blocks (2**24 characters) are not supported;

6427:

Start with the “small” file algorithm (file is not greater than eight blocks i.e. 4096 characters);

6431:

If the block number is 8 or more, the “small” file must converted into a large file. Note this is a side effect of “bmap”, and should occur only when “bmap” has been called by “writei” (and never by “readi” – see line 6245). Thus all files start life as “small” files and are never explicitly changed to “large” files. Note also that the change is irreversible!

6435:

“alloc” (6956) allocates a block on device “d” from the device’s free list. It then assigns a buffer to this block and returns a pointer to the buffer header;

6438:

The eight buffer addresses in the “i_addr” array for the “inode” are copied into the buffer area and then erased;

6442:

“i_addr[0]” is set to point to the buffer which is set up for a “delayed” write;

6448:

The file is still small. Get the next block if necessary;

6456:

Note the setting of “rablock”;