- 论坛徽章:
- 0
|
定义在file_operations, 那只有打开操作已经完毕了, 才能调用这个open方法。。 象ext2和ext3文件系统, 其open方法都定义为generic_file_open (见ext2_file_operations和ext3_file_operations的定义):
- int generic_file_open(struct inode * inode, struct file * filp)
- {
- if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
- return -EFBIG;
- return 0;
- }
复制代码
而vfat的open干脆设置为NULL, 表示不实现。 我用模块把ext3的open设置为NULL, 系统还是正常工作。
在vfs.txt中说:
open: called by the VFS when an inode should be opened. When the VFS
opens a file, it creates a new "struct file". It then calls the
open method for the newly allocated file structure. You might
think that the open method really belongs in
"struct inode_operations", and you may be right. I think it's
done the way it is because it makes filesystems simpler to
implement. The open() method is a good place to initialize the
"private_data" member in the file structure if you want to point
to a device structure
作者对我这种疑问, 只说了一个理由:简单! 可我怎么就看不出来比放在inode_operations简单在哪里啊~ |
|