Linux 内核文件系统与设备操作流程分析(5) file_move(f, &inode->i_sb->s_files); // // 注意:这里调用了 struct file->f_op->open 函数,也就是说调用了 // struct inode->i_fop->open 函数。这里有必要注解一下,在 struct // inode 结构中,有两套回调函数的方法集,一个是 struct // file_operations 一个是 struct inode_operations。而对于 open 函数 // 只是存在 file_operations 当中,另一个则不存在。那么在 struct inode // 这个 i_fop 函数集中有可能使用的是实际文件系统的函数,如 // ext3_file_operations 函数集。也有可能是一个设备驱动所提供的函数 // 方法如 def_chr_fops 函数集。 // if (!open && f->f_op) open = f->f_op->open; if (open) { error = open(inode, f); if (error) goto cleanup_all; } // // 去掉相关标志位。 // f->f_flags &= ~(O_CREAT O_EXCL O_NOCTTY O_TRUNC); file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); /* NB: we're sure to have correct a_ops only after f_op->open */ if (f->f_flags & O_DIRECT) { if (!f->f_mapping->a_ops