1,unlink is a system call, rm is a shell utility that calls unlink.
2,On some flavors of Unix, unlink can delete things that rm can't, such
as
directories, if you're running as superuser
3,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.
阅读(652) | 评论(0) | 转发(0) |