什么是文件序列号?

What's file serial number?

我从 Gnu C library [dirent.h] 中找到了 'struct dirent' 的一个结构成员(名字是 d_fileno) .
我阅读了文档,但我不明白文件序列号的含义。我在 Google 上找不到满意的答案。
所以,我决定编写一个程序来查看文件序列号。

输出

$./fileno ..
file_serial_number   file_name
[6838726]        [source]
[6562883]        [..]
[6838661]        [lstfl]
[6838718]        [.]
[6826161]        [research]
[6838720]        [starcase]

那么,这些数字的含义是什么?

程序中的相关部分:

...
while((pDirent = readdir(pDir)) != NULL)
    {
      printf("[%li]\t\t [%s]\n",pDirent->d_fileno, pDirent->d_name);
    }

  closedir(pDir);
...

根据文档:

The file serial number, which distinguishes this file from all other files on the same device.

可以用inode个数来理解。使用 inode 编号,我们可以引用文件的 inode data structure,其中包含有关文件的元数据,例如

  • 文件大小
  • 设备 ID
  • 文件的用户 ID
  • 文件的组 ID
  • 所有者、组和其他人的文件模式信息和访问权限
  • 文件保护标志
  • 文件创建、修改等的时间戳

inodes