最近想追一下 kernel ,就從網路上常見的 chrdev driver 開始看起
知道在
init_xxx(){
register_chrdev(major, name, &fops)
}
module_init(init_xxx)
註冊 driver 。到 register_chrdev 去看,裡面的內容大致說---註冊 struct cdev
到系統,以及對 cdev 的成員賦值。例如: kobject 或者 file operation 等等..
另外在 write 奧秘這篇網誌我看到,他open file 後會得到 file descriptor,
再透過 file descriptor 得到 file 結構,再透過 file 結構內的 ops 得到
driver method。
綜合上面兩個,我還是不知道他是如何透過 open 將 file 結構和 driver 內的
file_operations 結構關聯在一起,能有大大指點嗎? 謝謝。
--
知道在
init_xxx(){
register_chrdev(major, name, &fops)
}
module_init(init_xxx)
註冊 driver 。到 register_chrdev 去看,裡面的內容大致說---註冊 struct cdev
到系統,以及對 cdev 的成員賦值。例如: kobject 或者 file operation 等等..
另外在 write 奧秘這篇網誌我看到,他open file 後會得到 file descriptor,
再透過 file descriptor 得到 file 結構,再透過 file 結構內的 ops 得到
driver method。
綜合上面兩個,我還是不知道他是如何透過 open 將 file 結構和 driver 內的
file_operations 結構關聯在一起,能有大大指點嗎? 謝謝。
--
All Comments