目录
正在加载目录…
正在阅读专栏 OSTEP 操作系统专栏 第 31 篇 · 共 62 篇 · 50%

OSTEP:Files and Directories

发布于 2026-09-17 21:40 · 最后编辑于 2026-09-17 22:08 · 版本 v2 · 字数 13,110 · 预计阅读 27 分钟 👁 23 次阅读

OSTEP:Files and Directories

本篇对应 OSTEP Version 1.10 的 “Interlude: Files and Directories”。它介绍 UNIX file system 的用户可见 abstraction:file、directory、pathname、file descriptor 以及相关 system call。

类型与定位

  • 笔记类型:深度分析
  • 翻译基准:官方 file-intro.pdf,Version 1.10。
  • 图件说明:原文的 directory tree、system-call trace、open-file table 与代码 listing 按原位置保留为 Mermaid、表格和代码块;没有独立 raster image。

TL;DR

  • file 是可读写的 byte array;directory 是 user-readable name 到 inode number 的映射表。
  • pathname 从 root directory 开始,把 directory hierarchy 中的对象命名出来。
  • open 返回 per-process file descriptor,之后 read/write/close 都通过它访问 open file。
  • file descriptor 指向 system-wide open file table entry,其中保存 current offset、权限和 inode reference。
  • lseek 只修改 OS 中的 current offset,不直接执行 disk seek;fork/dup 可能共享 open file table entry。
  • unlink 删除 name 与 directory entry,不一定立即释放 file,取决于 link count 和 open references。

目录

章节内容
Files 与 directories两个核心 abstraction
创建与打开 fileopen、flags、descriptor
读写与 closeread/write/EOF
随机访问lseek 与 current offset
Open file tabledescriptor、offset、reference
Directories 与 linksmkdir、link、unlink
权限与错误protection 和 system-call contract

Files 与 directories

file 是线性的 byte array,file system 负责持久保存这些 bytes。每个 file 有低层 name,通常是 inode number。directory 也有 inode number,但内容是 name/inode pairs:

mermaid
flowchart TD
  A[/ root] --> B[foo directory]
  A --> C[bar directory]
  B --> D[bar.txt file]
  C --> E[bar directory]
  E --> F[foo directory]
  F --> G[bar.txt file]

pathname 将 user-readable names 串起来,例如 /foo/bar.txt。UNIX 将 files、devices、pipes,甚至部分 process interface 都放入统一命名层次中,降低使用不同资源时的概念成本。extension 如 .c、.jpg 通常只是 convention,file system 不保证内容与名字一致。

创建与打开 file

c
int fd = open("foo", O_CREAT|O_WRONLY|O_TRUNC,
              S_IRUSR|S_IWUSR);

O_CREAT 在不存在时创建 file,O_WRONLY 只允许写,O_TRUNC 在已存在时清空内容;第三个参数指定权限。open 返回 file descriptor,一个 per-process integer capability。标准输入、标准输出、标准错误通常占用 0、1、2,因此第一次打开的普通 file 常得到 descriptor 3。

file descriptor table 将 descriptor 映射到 open file table:

mermaid
flowchart LR
  A[Process fd table] --> B[fd 3]
  B --> C[Open file table entry]
  C --> D[Current offset / flags / inode pointer]
  D --> E[File-system inode]

读写与 close

text
echo hello > foo
cat foo
hello

cat 的典型 system-call trace:

text
open("foo", O_RDONLY) = 3
read(3, "hello
", 4096) = 6
write(1, "hello
", 6) = 6
read(3, "", 4096) = 0
close(3) = 0

read 的返回值是实际读取的 bytes;返回 0 表示 EOF。write 可能需要多次调用;完成后 close descriptor。system-call tracing 工具如 strace/dtruss 能显示调用、参数和返回值,是理解 file API 的实用工具。

随机访问

每个 open file table entry 保存 current offset。read/write 成功传输 N bytes 后,offset 增加 N。lseek 可显式修改它:

c
off_t lseek(int fildes, off_t offset, int whence);
  • SEEK_SET:offset 设置为给定位置;
  • SEEK_CUR:在当前位置上加 offset;
  • SEEK_END:从 file size 加 offset。

lseek 只改变 OS memory 中的变量,本身不产生 disk I/O;后续从远处位置读写时,HDD 才可能需要 seek。

Open file table

c
struct file {
    int ref;
    char readable;
    char writable;
    struct inode *ip;
    uint off;
};

一个 process 可以多次 open 同一 file,每次得到不同 open-file-table entries,因而各自拥有独立 current offset。fork 后,parent/child 的 descriptor table 会指向同一个 open file table entry,共享 offset;child lseek 后,parent 看到的 offset 也随之改变。reference count 只有在所有共享 descriptor 都 close 或 process exit 后才归零。

directory 是特殊 file,保存 names 到 inode numbers 的映射。mkdir 创建 directory;路径解析从 root 或 current working directory 开始,逐级查找 component。

hard link 为同一个 inode 增加另一个 directory name;unlink 删除某个 name。inode 只有在 link count 为零且没有 open references 时,才可以回收其 data blocks。这个语义允许一个 process 继续使用已 unlink 但仍 open 的 file。

symbolic link 则把一个 pathname 作为 link 的内容。它可以跨 file system,也可以指向 directory,但目标被删除或移动后会变成 dangling link;hard link 直接引用 inode,因此不会有这种 pathname 层面的断裂。rename() 在同一 file system 中通常提供原子地替换 name 的语义,很多编辑器会先写临时 file,再 rename 到目标位置,以避免读者看到半写入的结果。

权限与错误

file system API 必须同时定义 naming、permission、lifetime 与 failure behavior:

  • open 可能因不存在、权限不足、descriptor table 已满而失败;
  • read 可能返回部分内容或 EOF;
  • write 可能遇到 space 不足、设备错误;
  • close 应释放 descriptor,但不等同于保证数据已经 durable;
  • unlink 操作 directory name,不是简单地立即擦除所有 file data。

Shared open-file entries:fork 与 dup

通常,一个 process 的 file descriptor 会指向一个独立的 open file table entry,因此同一个 file 被打开两次时,两次 access 有各自的 current offset:

text
fd1 = open("file", O_RDONLY);  // offset 0
fd2 = open("file", O_RDONLY);  // another entry, offset 0
read(fd1, buf, 100);            // fd1 offset 100, fd2 remains 0

但 fork() 会复制 parent 的 descriptor table,并让 parent 与 child 的 descriptor 指向同一个 open file table entry。于是 entry 中的 offset 和 refcnt 是共享的:child 调用 lseek(fd, 10, SEEK_SET) 后,parent 从同一 descriptor 继续读时也会看到 offset 10。

mermaid
flowchart LR
  P[Parent fd table: fd 3] --> O[Shared open file entry]
  C[Child fd table: fd 3] --> O
  O --> R[refcnt: 2 / offset: 10]
  O --> I[Inode]

dup()、dup2() 与 dup3() 也会创建指向同一 open file table entry 的新 descriptor。它们在 shell 的 output redirection 中很有用:shell 可以先打开目标 file,再把标准输出 descriptor 复制或替换为该 entry,随后 child process 的普通 write(1, ...) 就会写入目标 file。

fsync() 与真正的持久化

普通 write() 通常只是把 data 交给 file system,file system 为了性能会先把 dirty data buffer 在 memory 中,稍后再发给 persistent-storage device。因此 write() 返回并不总是意味着 data 已经到达 durable media。

需要明确持久化边界的应用(例如 DBMS)可以调用:

c
int fd = open("foo", O_CREAT|O_WRONLY|O_TRUNC,
              S_IRUSR|S_IWUSR);
write(fd, buffer, size);
fsync(fd);       // force dirty data for this file to storage
close(fd);

fsync() 返回后,针对该 descriptor 的 dirty data 应已经被强制写出;但创建新 file 时,仅同步 file data 还不一定同步了包含它的 directory entry。若要保证“这个新名字也已经持久存在”,通常还要对 parent directory 执行 fsync()。这一点经常被应用程序忽略。

rename():原子替换 file

rename(old, new) 通常提供 crash-atomic 的 name replacement:系统在 rename 过程中崩溃,file 应该表现为仍使用 old name 或已经使用 new name,而不会出现一个奇怪的中间名字。编辑器因此常采用临时 file + fsync() + rename() 的更新模式:

text
fd = open("foo.txt.tmp", O_WRONLY|O_CREAT|O_TRUNC, ...)
write(fd, new_contents, size)
fsync(fd)
close(fd)
rename("foo.txt.tmp", "foo.txt")

这个模式先构造完整的新版本,再用一次 name-level 的原子切换替换旧版本;它与“直接覆盖原 file”相比,能避免读者看到半写入内容。若还要求新目录项在断电后存在,则需要把 directory 的 durability 也纳入同步协议。

Metadata:stat() 与 inode

stat(path) 或 fstat(fd) 可以取得 file metadata,例如 size、inode number、owner、group、permission mode、hard-link count、block size、allocated blocks,以及 access/modify/status-change timestamps:

c
struct stat {
    dev_t     st_dev;
    ino_t     st_ino;
    mode_t    st_mode;
    nlink_t   st_nlink;
    uid_t     st_uid;
    gid_t     st_gid;
    off_t     st_size;
    blksize_t st_blksize;
    blkcnt_t  st_blocks;
    time_t    st_atime;
    time_t    st_mtime;
    time_t    st_ctime;
};

file system 通常把这些信息放在 inode 这样的 persistent data structure 中;活跃 inode 会被 cache 在 memory 中。directory entry 主要负责 name 到 inode number 的映射,详细 metadata 则由 inode 保存。

Directory API

directory 不能像普通 file 那样由应用直接 write();它包含 file-system metadata,必须由 file system 通过 mkdir()、创建 child、link() 或 unlink() 等操作间接修改。新建的空 directory 至少包含 .(自身)和 ..(parent)两个 entry。

读取 directory 使用专门的 API:

c
DIR *dp = opendir(".");
struct dirent *d;
while ((d = readdir(dp)) != NULL)
    printf("%lu %s\\n", (unsigned long)d->d_ino, d->d_name);
closedir(dp);

struct dirent 通常包含 d_name、d_ino、下一个 entry 的 offset、record length 与 file type。由于 directory entry 本身信息有限,ls -l 还会对每个 entry 调用 stat() 获取 size、permission 等 metadata。

删除 directory 使用 rmdir(),并且要求 directory 为空(只剩 . 与 ..)。这个限制让一个看似单一的操作不会递归删除大量未知内容;递归删除由 rm -rf 等 user-level 工具显式完成,也因此必须谨慎对待。

hard link 不是复制 file data,而是在 directory 中增加一个指向同一 inode 的新 name:

text
ln file file2
ls -i file file2
67158084 file
67158084 file2

inode 中的 link count 记录仍有多少 directory names 指向它。unlink(name) 只删除一个 name 与 inode 的连接,并减少 link count;只有 link count 为零且没有 open references 时,inode 与 data blocks 才能回收。因此一个 file 可以已经没有可见 pathname,却仍被某个 process 打开并继续读写。

symbolic link 是一种真正的 file,其内容是目标 pathname。它可以跨 file system,也能指向 directory,但目标被删除或移动后会成为 dangling link。hard link 直接指向 inode,不会产生同样的 pathname dangling 问题;但它通常不能跨 file system,也不允许随意指向 directory。

Permission bits、ACL 与 superuser

传统 UNIX permission mode 的九个 bit 分成 owner、group、other 三组,每组包含 read、write、execute:

text
-rw-r--r--
  rw- owner
  r-- group
  r-- other

对 regular file,execute 表示是否可以作为 program 运行;对 directory,execute 主要表示能否 traverse(例如 cd),与 write 结合后还影响能否在其中创建或删除 names。chmod 600 foo.txt 将权限设为 owner 可读写,group 与 other 无权限。

某些 file system(例如 AFS)使用 per-directory ACL,比 owner/group/other 更精确地列出哪些 user 或 group 可以 lookup、insert、delete、read、write 或 administer。root 等 superuser 通常可以绕过本地 file system 的普通 permission,这种集中式特权也因此是重要的 security risk。

Mount:把多个 file system 拼成一棵树

mkfs 在某个 device partition 上创建一个空 file system;mount 则把它接入已有 directory tree:

text
mount -t ext3 /dev/sda1 /home/users

执行后,/home/users 不再只是原来那个 directory,而是新 file system 的 root;其中的 /home/users/a/foo 等 pathname 可以像本地路径一样访问。一个系统可以把 disk file system、proc、sysfs、tmpfs、AFS 等不同类型的 file system mount 到同一棵统一的 namespace 中。

TOCTTOU:检查与使用之间的竞态

特权服务如果先检查 pathname,再根据同一个 pathname 执行操作,就可能遭遇 TOCTTOU(Time Of Check To Time Of Use):攻击者在检查完成、使用开始前替换 directory entry 或 symbolic link,使服务最终操作了另一份敏感 file。

例如以 root 运行的 mail service 先用 lstat() 确认 inbox 是普通 file,随后再打开它写入;攻击者可以在两次操作之间用 rename() 把 inbox 换成 /etc/passwd,诱导服务向敏感 file 写入内容。O_NOFOLLOW 可以阻止某些通过 symbolic link 的攻击,但通用解决方案仍然需要减少不必要的 privilege,并使用能把检查与使用绑定起来的更安全 API/设计。

官方 Code Homework:实现 UNIX 文件工具

原文的 Code Homework 通过实现几个小型 UNIX utility 熟悉本篇 API;具体 build/run 方法以 homework download 中的 README 为准。

  1. Stat:实现一个自有版本的 stat,对给定 file 或 directory 调用 stat(),打印 size、allocated blocks、link count 等信息;观察 directory 中 entry 数变化时 directory 的 link count 如何变化。
  2. List Files:实现列出指定 directory 内容的程序。无参数时打印 file names;带 -l 时,使用 stat() 打印 owner、group、permissions 和其他 metadata;默认使用 current working directory。可使用 stat()、opendir()、readdir()、getcwd()。
  3. Tail:实现 mytail -n file,打印 file 最后 n 行。先用 stat() 和 lseek() 定位到接近末尾,读取一个 block,再向后扫描到足够的 newline,最后按原顺序输出。可使用 stat()、lseek()、open()、read()、close()。
  4. Recursive Search:从给定 root 开始递归打印 file system tree 中的所有 files 和 directories;无参数时以 current working directory 为 root,并可进一步增加类似 find 的过滤、匹配和输出选项。

这些练习应特别验证 descriptor 的 close、目录遍历终止条件、symlink/目录环、partial read 与错误返回;它们把“file 是 byte array、directory 是 name-to-inode mapping”的抽象落实成可运行的系统程序。

本章小结

UNIX file-system interface 用 file、directory、pathname 和 file descriptor 把 persistent storage 组织成统一 namespace。open() 将 pathname 解析为 per-process descriptor,descriptor 再指向 open file table entry,其中保存 current offset、访问模式和 inode reference;read()、write()、lseek() 与 close() 围绕这个状态工作。

directory entry、inode、link count 和 open reference 共同决定 file 的 lifetime;hard link 与 symbolic link 具有不同语义。fsync()、rename() 与 directory sync 则决定更新何时真正 durable。理解这些 API 的关键不是记住调用名,而是同时推导 naming、offset、permission、ownership、lifetime、crash 和 failure behavior。

逐段翻译说明:原文 Figure 39.1–39.5、fork-seek.c、dup.c、directory listing、stat 结构与 mmap aside 已按对应语义位置保留为 Mermaid、表格和代码块;官方 PDF 未提供需另存的 raster image,因此没有遗漏图片文件或尺寸调整。

与已有笔记的关系

参考资料

原文逐段补充(Version 1.10)

本章在 virtualization 主线中的位置

前文通过 process 虚拟化 CPU、通过 address space 虚拟化 memory,使 program 看起来像拥有自己的 processor 和 memory。本章再加入 persistent storage:与 power loss 后内容消失的 memory 不同,persistent-storage device 会长期保留 data,因此 OS 必须格外谨慎地管理用户真正关心的内容。

CRUX:如何管理 persistent device

如何为 persistent device 构建一个易于使用的 abstraction?OS 应如何管理文件、目录、路径和持久化更新?

UNIX file system 的统一 namespace 将 disk、USB stick、CD-ROM,甚至其他类型的对象放到一棵 directory tree 下;应用不必为每种 storage device 使用完全不同的命名方式。

creat() 旁注与 file descriptor capability

旧式 UNIX 代码可以使用 creat():

c
// option: add a second argument to set permissions
int fd = creat("foo");

可以把它理解为带有 O_CREAT | O_WRONLY | O_TRUNC 的 open()。因为 open() 已经能完成创建,creat() 现在较少使用;但它在 UNIX lore 中仍很有名:Ken Thompson 曾说,如果重新设计 UNIX,他会把 creat 拼成带 e 的 create。

open() 返回的是 per-process integer,而不是 file 的 pathname。它是一个 capability:这个 opaque handle 授予 process 对指定 open object 执行 read()、write() 等操作的能力。xv6 中,process 通过 descriptor index 访问自己的 open-file array:

c
struct proc {
    // ...
    struct file *ofile[NOFILE]; // Open files
    // ...
};

数组的每个 entry 是指向 struct file 的 pointer;descriptor 0/1/2 通常预先对应 standard input/output/error,所以新 open() 通常返回 3。

strace 旁注

strace 能显示 program 调用的 system call、参数与 return code,是理解 file API 的直接工具。常用选项包括:-f 跟踪 fork 出来的 children,-t 打印每次调用的时间,-e trace=open,close,read,write 只关注指定 calls;Linux 之外可使用 macOS 的 dtruss 或旧 UNIX 的 truss。

Figure 39.1–39.5 的关键执行轨迹

对一个大小为 300 bytes 的 file,每次读取 100 bytes:

System callReturn codeCurrent offset
fd = open("file", O_RDONLY)30
read(fd, buffer, 100)100100
read(fd, buffer, 100)100200
read(fd, buffer, 100)100300
read(fd, buffer, 100)0300
close(fd)0—

两个独立 open() 会创建两个不同的 open file table entries,因此 offset 独立:

System callReturn codeOFT[10] offsetOFT[11] offset
fd1 = open("file", O_RDONLY)30—
fd2 = open("file", O_RDONLY)400
read(fd1, buffer1, 100)1001000
read(fd2, buffer2, 100)100100100
close(fd1)0—100
close(fd2)0——

使用同一个 descriptor lseek(fd, 200, SEEK_SET) 后再读 50 bytes,则 offset 从 200 变为 250。lseek() 本身只修改 OS memory 中的 offset,不执行 disk I/O;后续 read/write 若访问了不同 track,才可能触发实际 disk seek。

Figure 39.2–39.4:fork() 与 dup() 的精确关系

c
int main(int argc, char *argv[]) {
    int fd = open("file.txt", O_RDONLY);
    assert(fd >= 0);
    int rc = fork();
    if (rc == 0) {
        rc = lseek(fd, 10, SEEK_SET);
        printf("child: offset %d\\n", rc);
    } else if (rc > 0) {
        (void) wait(NULL);
        printf("parent: offset %d\\n",
               (int) lseek(fd, 0, SEEK_CUR));
    }
    return 0;
}

输出为:

text
prompt> ./fork-seek
child: offset 10
parent: offset 10
prompt>

fork() 复制 private descriptor array,但 parent/child 的 descriptor 指向同一个 open file table entry;该 entry 的 refcnt 变为 2,offset 也共享。只有两个 process 都 close 或 exit 后,entry 才可移除。这个共享有时很有用:协作中的多个 processes 可以写同一个 output file,而不需要额外 coordination。

dup() 及 dup2()/dup3() 也共享同一 entry:

c
int main(int argc, char *argv[]) {
    int fd = open("README", O_RDONLY);
    assert(fd >= 0);
    int fd2 = dup(fd);
    // fd and fd2 can now be used interchangeably
    return 0;
}

这正是 shell 实现 output redirection 的基础:先打开目标 file,再让 standard output descriptor 指向同一个 open file。原文也承认,这个知识点如果放在 shell project 之前讲会更有帮助,但操作系统课程很难让所有内容都以完美顺序出现。

mmap() 与 persistent memory 旁注

mmap() 建立 file byte offset 与 process virtual address 的对应关系。file 是 backing file,memory 中的映像可以像普通 memory 一样通过 CPU load/store 访问;结合 persistent storage 的 durability,这形成 persistent-memory programming abstraction。

c
p = mmap(NULL, file_size, PROT_READ | PROT_WRITE,
         MAP_SHARED, fd, 0);
assert(p != MAP_FAILED);

mmap() 将 file 的 byte offset 与 process 的 virtual address 建立对应关系;之后 CPU 对映像执行 load/store,就能访问 backing file。原文的 pstack.c 示例把 ps.img 当作一个持久化 stack:文件中保存元素数量 n 与整数数组,某次 invocation push 的数据可以由下一次 invocation pop。这里的方便也带来一致性问题:如果 crash 发生在更新 n 与写入 stack element 之间,persistent image 可能处于不一致状态。

c
// pstack.c 的核心逻辑(保留原文执行顺序)
if (strcmp(argv[i], "pop") == 0) {       // pop
    if (p->n > 0)                         // stack not empty
        printf("%d\n", p->stack[--p->n]);
} else {                                  // push
    if (sizeof(pstack_t) + (1 + p->n) * sizeof(int)
        <= file_size)                     // stack not full
        p->stack[p->n++] = atoi(argv[i]);
}

rm foo 通常只发出 unlink("foo") = 0。名称叫 unlink,是因为 file 的生命周期涉及两件事:inode 保存 file 的 metadata/data-block location,directory 则保存 human-readable name 到 inode number 的 link。unlink() 删除的是后一条 link;只有 inode 的 link count 为零,并且没有仍然打开该 file 的 reference 时,inode 与 data blocks 才会真正释放。

directory 不能由应用直接 write(),因为其格式属于 file-system metadata;应用通过 mkdir()、创建 child、link()、unlink() 等操作间接修改它。新 directory 虽然被称为空,却至少包含 . 和 .. 两个 entry。rmdir() 只删除空 directory,以避免一个命令意外递归删除大量 data;rm -rf 的强大也正是它的危险所在。

读取 directory 使用 opendir()、readdir()、closedir()。struct dirent 的主要字段如下:

c
struct dirent {
    char d_name[256];          // filename
    ino_t d_ino;               // inode number
    off_t d_off;               // offset to next dirent
    unsigned short d_reclen;   // length of this record
    unsigned char d_type;      // type of file
};

directory entry 只提供有限信息;ls -l 还要对每个 entry 调用 stat(),取得 size、permissions 等 metadata。hard link 通过 link(old, new) 增加一个指向同一 inode 的 name,file data 不会复制;symbolic link 则是一个独立类型的 file,其 data 是目标 pathname。它能跨 file system 或指向 directory,但目标被删除后会留下 dangling reference。

39.16–39.17:permission、ACL 与 mount

传统 UNIX permission bits 将 owner、group、other 各自的 read/write/execute 组合在九个 bit 中。对 regular file,execute 决定能否运行;对 directory,execute 允许 traverse(例如 cd),与 write 一起影响能否创建 entry。AFS 等系统使用更细粒度的 per-directory ACL;root 或 AFS 的 system:administrators 代表另一种 superuser 权限,同时也构成集中的 security risk。

mkfs 将指定 file-system type 的空 file system 写入 device partition;mount 再把它的 root 接到已有 directory tree 的 mount point。例如 /dev/sda1 挂载到 /home/users 后,/home/users/a/foo 就是该新 file system 中的 file。ext3、proc、sysfs、tmpfs、AFS 等不同 file systems 因此可以统一呈现在同一棵 namespace 中。

TIP:BE WARY OF TOCTTOU

特权服务若先用 lstat() 检查 pathname,再根据同一 pathname 执行更新,就可能在两步之间被攻击者通过 rename() 替换成 /etc/passwd 等敏感 file。O_NOFOLLOW 能阻挡一部分 symbolic-link attack;更根本的方向是减少 root privilege,并采用把检查与使用绑定起来的安全 API。原文的结论很朴素:编写高权限代码时要格外小心。

原文 References 补充

  • [BD96] Matt Bishop、Michael Dilger,Checking for Race Conditions in File Accesses,Computing Systems 9:2,1996。
  • [CK+08] Russ Cox 等,The xv6 Operating System,xv6-public。
  • [H+18] Y. Hu 等,TxFS: Leveraging File-System Crash Consistency to Provide ACID Transactions,USENIX ATC ’18。
  • [K19] Terence Kelly,Persistent Memory Programming on Conventional Hardware,ACM Queue,2019。
  • [K20] Terence Kelly,Is Persistent Memory Persistent?,Communications of the ACM,2020。
  • [K84] Tom J. Killian,Processes as Files,USENIX,1984。
  • [L84] Henry M. Levy,Capability-Based Computer Systems,1984。
  • [MJLF84] Marshall K. McKusick 等,A Fast File System for UNIX,ACM TOCS,1984。
  • [P+13] Thanumalayan S. Pillai 等,Towards Efficient, Portable Application-Level Consistency,HotDep ’13。
  • [P+14] Thanumalayan S. Pillai 等,All File Systems Are Not Created Equal,OSDI ’14。
  • [SK09] Jerome H. Saltzer、M. Frans Kaashoek,Principles of Computer System Design,2009。
  • [SR05] W. Richard Stevens、Stephen A. Rago,Advanced Programming in the UNIX Environment,2005。
  • [T+08] D. Tsafrir 等,Portably Solving File TOCTTOU Races with Hardness Amplification,FAST ’08。

源文档核验记录

  • 官方源文档:Interlude: Files and Directories — Version 1.10
  • 核验范围:PDF 共 29 页,正文章节覆盖 39.1 Files And Directories 至 39.18 Summary,并包含 mmap() aside、Key File System Terms、References 与 Code Homework。
  • 图件核验:Figure 39.1–39.5、fork-seek.c、dup.c、stat、directory listing 与 mmap/persistent-stack 示例均已按原文顺序保留语义位置;官方 PDF 未包含需要另存的独立 raster image,因此没有遗漏图片文件或可调整的原图尺寸。
  • 练习核验:Stat、List Files、Tail、Recursive Search 四项 Code Homework 均已翻译,保留 API、参数和实现约束。
← 返回列表
← 上一篇 OSTEP:RAID 下一篇 → OSTEP:File System Implementation

评论 (0)

暂无评论,来留下第一条吧。
登录 或 注册 后才能发表评论