【问题标题】:access to superblock in vdi, ext2访问 vdi、ext2 中的超级块
【发布时间】:2016-07-12 09:00:18
【问题描述】:

我试图在从 vdi 文件打开和读取 ext2 文件系统时访问超级块。我想使用存在于 ext2.h 文件中的 struct ext2_super_block(参见http://lxr.free-electrons.com/source/fs/ext2/ext2.h 的第 415 行)。我只想#include <ext2.h>,但由于我当前的 unix 操作系统是 ext3/ext4,所以头文件不在我的系统中,ext2.h 需要包含的任何文件也没有。

我怎样才能包含这个文件来得到那个结构?我应该自己构建它(读入时保存超级块的结构)吗?如果我自己构建它,读取内容会有什么不同?

这是我到目前为止的系统调用来完成这个(显然目前不工作):

fd = open (argv[1], O_RDONLY);
    .......check for errors in open
lseek(fd, OFFSET, SEEK_SET); //to skip to superblock
read (fd, &mySB, sizeof(struct ext2_superblock));

【问题讨论】:

    标签: c++ unix struct ext2 vdi


    【解决方案1】:

    您可能最好使用 libext2fs 而不是内核头文件。它了解所有结构,旨在用于用户空间,并且可以移植到非 GNU 非 Linux 主机。

    【讨论】:

      猜你喜欢
      • 2018-02-15
      • 2020-03-28
      • 2013-11-28
      • 1970-01-01
      • 2019-02-22
      • 2013-09-01
      • 2020-12-04
      • 1970-01-01
      • 2019-04-10
      相关资源
      最近更新 更多