20.13 itrunc (7414)

This procedure is called by “core” (4112), “openl” (5825) and “iput” (7353). In the first two cases, the contents of the “file” are about to be replaced. In the third case, the file is about to be abandoned.

7421:

If the file is a character or block special file then there is nothing to do;

7423:

Search backwards the list of block numbers stored in the “inode”;

7425:

If the file is large, then an indirect fetch is needed. (A double indirect fetch is needed for blocks numbered seven and higher.);

7427:

Reference all 257 elements of the buffer in reverse order. (Note this seems to be the only place where characters #512, #513 of the buffer area are referenced. Since they will presumably contain zero, they will contribute nothing to the calculation. Hence if “510” were substituted for “512” here, and again on line 7432, a general improvement all round would result (?));

7438:

“free” returns an individual block to the available list;

7439:

This is the end of the “for” statement commencing on line 7427. (Likewise the statement which begins at 7432 ends at 7435.);

7443:

Clear the entry in “i_addr[ ]”;

7445:

Reset size information, and flag the “inode” as “updated”.