2013-05-08 73 views
1

我想要了解Linux如何處理EXT3文件。 我在看fs/ext3/file.c那裏有與文件處理文件操作存在:EXT3文件操作

const struct file_operations ext3_file_operations = { 
    .llseek   = generic_file_llseek, 
    .read   = do_sync_read, 
    .write   = do_sync_write, 
    .aio_read  = generic_file_aio_read, 
    .aio_write  = generic_file_aio_write, 
    .unlocked_ioctl = ext3_ioctl, 
#ifdef CONFIG_COMPAT 
    .compat_ioctl = ext3_compat_ioctl, 
#endif 
    .mmap   = generic_file_mmap, 
    .open   = dquot_file_open, 
    .release  = ext3_release_file, 
    .fsync   = ext3_sync_file, 
    .splice_read = generic_file_splice_read, 
    .splice_write = generic_file_splice_write, 
}; 

我怎麼能找到什麼時候。開由函數「dquot_file_open」,例如更換? 我應該遵循fs/open.c定義的系統調用:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) 

或者我應該看什麼其他功能?

我在Linux上工作3.7.6用戶模式Linux的

回答

2

Linux內核是一個面向對象的方式組織(雖然用C語言編寫)。 struct file_operations實際上是一個類,成員(函數指針)是類的函數成員(Java頭的「方法」)。您引用的代碼用於通過填充函數指針來設置ext3對象。這是在編譯/鏈接時完成的。

系統調用open(2)通過查找與當前文件系統相關的struct file_operations並調用其open成員來間接調用此方法。

我建議你看看kernelnewbies頁面,以獲得全面的看法和更詳細的幫助。

+0

是的我知道這些信息。我的問題是open函數與EXT3的「file_operations」交互的地方在哪裏? – user19570 2013-05-08 13:43:18