【发布时间】:2014-10-02 23:30:09
【问题描述】:
在 ext2 中,有许多保留的 inode,例如 inode 2 是根目录。在Linux ext2 header file 中,inode 5 被定义为“Boot loader inode”。
是否有操作系统实际使用它?
你如何读取和写入这个inode?p>
【问题讨论】:
标签: bootloader ext2
在 ext2 中,有许多保留的 inode,例如 inode 2 是根目录。在Linux ext2 header file 中,inode 5 被定义为“Boot loader inode”。
是否有操作系统实际使用它?
你如何读取和写入这个inode?p>
【问题讨论】:
标签: bootloader ext2
可以从linux/fs/ext2.h的超级块结构中提取保留inode的数量
/*
* 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,它用于交换引导代码,如您所见here),以便轻松放置和定位引导代码,因此您不必搜索。
正如之前的链接所说,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的代码。
【讨论】: