recentpopularlog in

kme : systemcalls   3

What is the difference between unlink and rm?
No trees were killed in the sending of this message. However a large
number of electrons were terribly inconvenienced.

In the ancient past, creating a directory consisted of three steps
(now done with mkdir()):

1. create an empty directory node with mknod().
2. Link (hard) a "." entry to that directory node.
3. Link (hard) a ".." entry to the directory's parent.

Removing a directory consisted of three steps (now done with rmdir(),
which also does some type checks first):

1. unlink() the ".." entry
2. unlink() the "." entry
3. unlink() the directory itself

unlink (run as root) would remove a name entry regardless of its type.

With a combination of link() and unlink() you could do all sorts
of evil things to the directory tree by repointing "." and ".."
entries. You could also orphan subtrees that take disk space but
have no references from the outside.
unlink  rm  unix  systemcalls  reference 
may 2015 by kme

Copy this bookmark:

to read