gpt4 book ai didi

c - 为什么 inode 编号从 1 而不是 0 开始?

转载 作者:太空宇宙 更新时间:2023-11-04 12:09:32 24 4
gpt4 key购买 nike

C 语言约定从 0 开始计算数组索引。为什么 inode 编号从 1 而不是 0 开始?

如果保留inode 0是为了一些特殊用途,那么inode 0有什么意义呢?

最佳答案

0 用作 sentinel value指示空或无 inode。类似于 C 中指针可以为 NULL 的方式。没有哨兵,您需要额外的位来测试结构中的 inode 是否已设置。

更多信息在这里:

All block and inode addresses start at 1. The first block on the disk is block 1. 0 is used to indicate no block. (Sparse files can have these inside them)

http://uranus.chrysocome.net/explore2fs/es2fs.htm

例如,在旧文件系统中,目录表示为文件条目的固定数组,删除文件会导致将该条目的 inode val 设置为 0。遍历目录时,inode 为 0 的任何条目都将被忽略.

关于c - 为什么 inode 编号从 1 而不是 0 开始?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49443953/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com