Chinaunix首页 | 论坛 | 博客
  • 博客访问: 84596
  • 博文数量: 25
  • 博客积分: 1990
  • 博客等级: 上尉
  • 技术积分: 365
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-14 14:16
文章分类

全部博文(25)

文章存档

2011年(1)

2010年(13)

2008年(11)

我的朋友

分类: LINUX

2010-08-18 14:03:18

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) |
给主人留下些什么吧!~~