- 論壇徽章:
- 0
|
定義在file_operations, 那只有打開操作已經(jīng)完畢了, 才能調(diào)用這個open方法。。 象ext2和ext3文件系統(tǒng), 其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干脆設(shè)置為NULL, 表示不實現(xiàn)。 我用模塊把ext3的open設(shè)置為NULL, 系統(tǒng)還是正常工作。
在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簡單在哪里啊~ |
|