我在定製的內核模塊中在securityfs
中創建了多個dentry
對象。下面是我如何做它:對VFS中的不同文件使用相同的file_operation
inst->output_file = securityfs_create_file("1",
S_IRUSR | S_IRGRP, uprp_dir, NULL,
&my_file_ops);
inst->output_file = securityfs_create_file("2",
S_IRUSR | S_IRGRP, uprp_dir, NULL,
&my_file_ops);
// and so on
我有my_file_ops
實現通常的順序操作。但問題是,下面的函數被調用爲所有dentry
對象:
static int ct_open(struct inode *inode, struct file *file)
,然後繼續使用方法:
static void *my_seq_ops_start (struct seq_file *m, loff_t *pos)
的問題是,我該如何找出哪些目錄項用戶想要讀取的對象(在任何這些函數中)? - 意思是我想爲文件1
和2
輸出不同的東西。
非常感謝。我更喜歡第二種方法,因爲它更容易實施。如果您推薦兩種方案中的「更好」,那就太好了,僅供參考。 – recluze 2013-05-07 04:30:20