2

in source/arch/x86/kernel/msr.c, the msr_open callback for the character device uses the following construct to extract the minor number of the character device file used:

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

    [...]
}

My question is: Why not directly call iminor with the first argument of the function, like:

unsigned int cpu = iminor(inode);

The construct is used in other callbacks (e.g. read and write) as well,, where the inode is not passed as an argument, so I guess this is due to copy/paste, or is there a deeper meaning to it?

4

1 回答 1

0

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

同样的交易。

于 2013-09-09T18:16:36.033 回答