Linux文件、硬链接和软链接的心理模型

I always felt bothered about my superficial understanding of inode, hard and soft links in Linux. Here I attempt to structure my learnings into a simplified mental model. Corrections are welcome.

我一直对自己对 Linux 中 inode、硬链接和软链接的肤浅理解感到困扰。在这里,我试图将我的学习结构化为一个简化的心理模型。欢迎纠正。

At the storage level, a file is a block of data. There is more to it than just that, but I won't delve deep into it.

在存储层面上,文件是一块数据块。它不仅仅是这样,但我不会深入探讨。

At the filesystem level, this block of data is represented as a an abstraction called inode. Think of inode as a data structure that stores metadata about the underlying data block.

在文件系统层面,这个数据块被表示为一种称为inode的抽象。可以将inode视为一个数据结构,用于存储关于底层数据块的元数据。

A pathname makes this pair of (inode, data block) accessible and usable for humans.

一个pathname使这对(inode,数据块)对人类可访问和可用。

I wanted a single-word term to refer to a filepath+filename combination. filename or filepath didn't feel like they conveyed the contextual meaning properly.

我想要一个单词来指代文件路径+文件名的组合。文件名文件路径似乎没有恰当地传达上下文的含义。

RFC 959 - File Transfer Protocol gave me a decent term - pathname, defined as:

RFC 959 - 文件传输协议给了我一个不错的术语 - 路径名,定义为:

Pathname is defined to be the character string which must be input to a file system by a user in order to identify a file. Pathname normally contains device and/or directory names, and file name specification.

路径名被定义为用户必须输入到文件系统中的字符字符串,以便识别文件。路径名通常包含设备和/或目录名称,以及文件名规范。

Think of the whole this way - the data block of a file lies in a lower level of abstraction than the pathname (which lives at the filesystem level). inode acts as a bridge - a representative to the data block at the filesystem level.

这样考虑整个问题 - 文件的数据块位于比路径名更低的抽象层次(路径名位于文件系统级别)。inode 充当桥梁 - 在文件系统级别代表数据块。

Man, its difficult to keep a high level overview simple, without diving into details.

人啊,保持高层次的概述简单而不深入细节是很困难的。

Components of a file. From bottom up, data block, inode, and pathname

文件的组成部分。从下到上,数据块、inode和路径名

Roughly, file = pathname + inode + data block.

大致来说,文件 = 路径名 + inode + 数据块

So, when you talk about a file, you may be referring to any or all of these components.

因此...

开通本站会员,查看完整译文。

- 위키
Copyright © 2011-2025 iteam. Current version is 2.142.1. UTC+08:00, 2025-03-12 22:28
浙ICP备14020137号-1 $방문자$