【问题标题】:Linux: Difference between inode and file_inode(file)?Linux:inode 和 file_inode(file) 之间的区别?
【发布时间】:2013-09-13 03:38:52
【问题描述】:

在 source/arch/x86/kernel/msr.c 中,字符设备的 msr_open 回调使用以下构造来提取所用字符设备文件的次要编号:

static int msr_open(struct inode *inode, struct file *file)
{
    unsigned int cpu = iminor(file_inode(file));

    [...]
}

我的问题是: 为什么不直接用函数的第一个参数调用 minor,比如:

unsigned int cpu = iminor(inode);

该构造也用于其他回调(例如读取和写入),其中 inode 没有作为参数传递,所以我猜这是由于复制/粘贴,还是它有更深层次的含义?

【问题讨论】:

    标签: linux file kernel character inode


    【解决方案1】:

    inode 是传统 Unix 样式文件系统(如 UFS 或 ext3)上的数据结构。 inode 存储有关常规文件、目录或其他文件系统对象的基本信息。 - http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-inodes.html

    同样的交易。

    【讨论】:

      猜你喜欢
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      相关资源
      最近更新 更多