问题描述
C语言约定从0开始统计数组的索引。为什么inode数从1开始,而不是从0开始?如果保留inode 0是为了某些特殊用途,那么inode 0的含义是什么?解决方案通常情况下,inode 0是保留的,因为返回值0通常表示信号错误。 Linux内核中的多种方法 - 特别是在所有文件系统共享的VFS层中 - 返回一个ino_t,例如, 。
有更多的保留inode号码。例如在:
$ b $ pre $
#define EXT2_BAD_INO 1 / *坏块inode * /
#define EXT2_ROOT_INO 2 / * Root inode * /
#定义EXT2_BOOT_LOADER_INO 5 / *引导加载程序inode * /
#define EXT2_UNDEL_DIR_INO 6 / *取消删除目录inode * /
和有:
#define EXT3_BAD_INO 1 / *坏块inode * /
#define EXT3_ROOT_INO 2 / * Root inode * /
#define EXT3_BOOT_LOADER_INO 5 / *引导加载程序inode * /
#define EXT3_UNDEL_DIR_INO 6 / *取消删除目录inode * /
#define EXT3_RESIZE_INO 7 / *保留组描述符inode * /
#define EXT3_JOURNAL_INO 8 / *日志inode * /
和 has:
#define EXT4_BAD_INO 1 / *坏块inode * /
#define EXT4_ROOT_INO 2 / * Root inode * /
#define EXT4_USR_QUOTA_INO 3 / *用户配额inode * /
#define EXT4_GRP_QUOTA_INO 4 / *组配额inode * /
#define EXT4_BOOT_LOADER_INO 5 / *引导加载程序inode * /
#define EXT4_UNDEL_DIR_INO 6 / *取消删除目录inode * /
#define EXT4_RESIZE_INO 7 / *保留组描述符inode * /
#定义EXT4_JOURNAL_INO 8 / *日志inode * /
其他文件系统使用ino 1作为根节点号。一般来说,一个文件系统可以自由选择它的索引节点号和保留的ino值(0除外)。
The C language convention counts array indices from 0. Why do inode numbers start from 1 and not 0?
If inode 0 is reserved is for some special use, then what is the significance of inode 0?
Usually, the inode 0 is reserved because a return value of 0 usually signals an error. Multiple method in the Linux kernel -- especially in the VFS layer shared by all file systems -- return an ino_t, e.g. find_inode_number.
There are more reserved inode numbers. For example in ext2:
#define EXT2_BAD_INO 1 /* Bad blocks inode */
#define EXT2_ROOT_INO 2 /* Root inode */
#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
and ext3 has:
#define EXT3_BAD_INO 1 /* Bad blocks inode */
#define EXT3_ROOT_INO 2 /* Root inode */
#define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
#define EXT3_JOURNAL_INO 8 /* Journal inode */
and ext4 has:
#define EXT4_BAD_INO 1 /* Bad blocks inode */
#define EXT4_ROOT_INO 2 /* Root inode */
#define EXT4_USR_QUOTA_INO 3 /* User quota inode */
#define EXT4_GRP_QUOTA_INO 4 /* Group quota inode */
#define EXT4_BOOT_LOADER_INO 5 /* Boot loader inode */
#define EXT4_UNDEL_DIR_INO 6 /* Undelete directory inode */
#define EXT4_RESIZE_INO 7 /* Reserved group descriptors inode */
#define EXT4_JOURNAL_INO 8 /* Journal inode */
Other fileystems use the ino 1 as root inode number. In general, a file system is free to choose its inode numbers and its reserved ino values (with the exception of 0).
这篇关于为什么inode号从1开始而不是0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!