19.8 unlink (3510)

This procedure implements a system call which deletes a file name from the directory structure. (When all references to a file are deleted, the file itself will be deleted.)

3515:

Search for a file with the specified name, and if it exists, return a pointer to the “inode” of the immediate parent directory;

3518:

Unlock the parent directory;

3519:

Get an “inode” pointer to the file itself;

3522:

Unlinking directories is forbidden, except for super-users;

3528:

Rewrite the directory entry with the “inode” value set to zero;

3529:

Decrement the “link” count.

Note that there is no attempt to reduce the size of a directory below its “high water” mark.