经典书籍翻译——深入理解Linux内核25

An Overview of the Unix Filesystem
The Unix operating system design is centered on its filesystem, which has several interesting characteristics. We’ll review the most significant ones, since they will be mentioned quite often in forthcoming chapters.
Files
A Unix file is an information container structured as a sequence of bytes; the kernel does not interpret the contents of a file. Many programming libraries implement higher-level abstractions, such as records structured into fields and record addressing based on keys. However, the programs in these libraries must rely on system calls
offered by the kernel. From the user’s point of view, files are organized in a tree-structured namespace, as shown in Figure 1-1.
在这里插入图片描述

UNIX 文件系统概述
UNIX操作系统设计集中在它的文件系统上,它有几个有趣的特性;我们将介绍其中最重要的几个特性,因为这些特性将在后续章节中频繁提到。
文件
一个UNIX文件是封装字节序一个信息容器;而内核并不会解释文件的内容。许多变成库实现了更高层次的抽象,例如基于字段封装的记录和基于键值的记录寻址。但是,这些库中的程序必须依赖内核提供的系统调用。从用户的角度来说,文件按照图1-1中所示的树形结构组织而成。

All the nodes of the tree, except the leaves, denote directory names. A directory node contains information about the files and directories just beneath it. A file or directory name consists of a sequence of arbitrary ASCII characters, * with the exception of / and of the null character \0. Most filesystems place a limit on the length of a filename, typically no more than 255 characters. The directory corresponding to the root of the tree is called the root directory. By convention, its name is a slash ( / ).
Names must be different within the same directory, but the same name may be used in different directories.
Unix associates a current working directory with each process (see the section “The Process/Kernel Model” later in this chapter); it belongs to the process execution context, and it identifies the directory currently used by the process. To identify a specific file, the process uses a pathname, which consists of slashes alternating with a sequence of directory names that lead to the file. If the first item in the pathname is a slash, the pathname is said to be absolute, because its starting point is the root directory. Otherwise, if the first item is a directory name or filename, the pathname is said to be relative, because its starting point is the process’s current directory. While specifying filenames, the notations “.” and “…” are also used. They denote the current working directory and its parent directory, respectively. If the current working directory is the root directory, “.” and “…” coincide.
上图的树形结构中除了叶子节点外,其他所有节点都标示为目录名,一个目录节点包含其下面文件和路径的有关信息;一个文件或目录由任意ASCII字符序列组成,’*’、‘\’和’\0’除外。大多数文件系统会限定文件名的长度,典型的时不超过255个字符。与这棵树形结构根节点相对应的是跟目录。按照惯例,用一个/来命名。
在同一目录下,文件名/目录名必须唯一标识,但是在不同的目录中可以有同名文件/目录名。
UNIX将当前工作路径和每个进程关联起来(见本章后续的“进程/内核态”部分);该路径属于进程执行上下文,并且标识进程当前所在的路径。为了标识一个特定的文件,进程使用了路径名——该路径名由/和指向该文件的一系列路径名交错组成。如果第一个标识是/,那么该路径名就是一个绝对路径,因为它的起点是根路径;否则它的第一个标识是路径名或文件名,那么该路径就是相对路径,因为他的起点是进程的当前路径。在指定文件名时与’.‘和’…'同时使用,则它们表示分别当前工作路径以及其父目录。如果当前工作路径时根路径,那么‘.’和‘…’则重名。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

存墨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值