在 ext2 中,有许多保留的 inode,例如 inode 2 是根目录。在Linux ext2 头文件中,inode 5 被定义为“Boot loader inode”。
是否有任何操作系统实际使用它?
你如何读取和写入这个inode?
在 ext2 中,有许多保留的 inode,例如 inode 2 是根目录。在Linux ext2 头文件中,inode 5 被定义为“Boot loader inode”。
是否有任何操作系统实际使用它?
你如何读取和写入这个inode?
保留 inode 的数量可以从linux/fs/ext2.h的超级块结构中提取
/*
* Structure of the super block
*/
struct ext2_super_block {
...
__le32 s_first_ino; /* First non-reserved inode */
...
}
所以保留的 inode 的数量是 s_first_ino - 1。这个数量取决于你使用的版本。
旧版本的第一个非保留 inode 的数量是:
/* First non-reserved inode for old ext2 filesystems */
#define EXT2_GOOD_OLD_FIRST_INO 11
所有保留的 inode 也在这里定义:
/*
* Special inode numbers
*/
#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 */
EXT2_BOOT_LOADER_INO 指向放置引导加载程序的位置,当前未使用。它只是一个未使用的机制(直到内核版本 3.10,它用于交换引导代码,如您在此处看到的),以便轻松放置和定位引导代码,因此您不必搜索。
正如前面的链接所说,GRUB 想在未来使用 EXT2_BOOT_LOADER_INO 作为控制机制:
* Support embedding a Stage 1.5 in the EXT2_BOOT_LOADER_INO of an ext2fs
partition, so that it won't be accidentally erased or modified by
the kernel.
...即使当时没有代码来读取或修改 inode。