# 如果删除程序正在打开的文件会发生什么

## 简介

Linux 对文件的存储和访问是通过一种被称为 inode 即 i 节点的机制来实现的，它存储着除了文件名和文件内容之外的文件的全部信息，（”An inode stores all the information about a regular file, directory, or other file system object, except its data and name. “）

i 节点中主要有两大部分:

• 一部分是 i 节点号与文件名的对应表
• 另一部分就是i 节点对应文件的元信息

## 链接

Why are hard links to directories not allowed in UNIX/Linux?

Allowing hard links to directories would break the directed acyclic graph structure of the filesystem, possibly creating directory loops and dangling directory subtrees, which would make fsck and any other file tree walkers error prone.

Now, if you were allowed to do this for directories, two different directories in different points in the filesystem could point to the same thing. In fact, a subdir could point back to its grandparent, creating a loop.

rm 的底层调用：