은 내가이 책의 예제는 매우 사용되지 않는 것을 깨달았다 그러나 리눅스 커널 모듈 프로그래밍 가이드proc_dir_entry에 대해 inode_operation을 정의하는 방법은 무엇입니까?
를 사용하여 리눅스 커널 모듈을 작성하는 방법을 배우려고 노력하고있다. 다음은이 책의 예제 중 하나입니다. 나는 소스 코드를 보았을 때
static struct proc_dir_entry *Our_Proc_File;
static int module_permission(struct inode *inode, int op, struct nameidata *nd)
{
if (op == 4 || (op == 2 && current−>euid == 0))
return 0;
return −EACCES;
}
static struct inode_operations Inode_Ops_4_Our_Proc_File = {
.permission = module_permission
}
static struct file_operations File_Ops_4_Our_Proc_File = {
// ...
};
int init_module()
{
Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
// above line should use proc_create()
if (Our_Proc_File == NULL) {
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
return −ENOMEM;
}
Our_Proc_File−>owner = THIS_MODULE;
Our_Proc_File−>proc_iops = &Inode_Ops_4_Our_Proc_File;
Our_Proc_File−>proc_fops = &File_Ops_4_Our_Proc_File;
}
, 나는 proc_iops
이
그래서 어떻게이 proc_dir_entry
'proc_iops' 필드는 여전히'struct proc_dir_entry'에 존재합니다. [fs/proc/internal.h] (http://lxr.free-electrons.com/source/fs/proc/internal.h?v)를보십시오. = 4.9). 다른 것은 struct가 외부 코드에 의해 액세스되어서는 안되기 때문에 "internal"헤더에 정의되어있는 이유입니다. '/ proc' 파일 시스템의 일반적인 개념은 커널과 커널 모듈에 ** content **와 ** group ** 디렉토리를 생성 할 수있는 ** 파일 **을 쉽게 생성 할 수있게하는 것입니다. inode와 dentries를 커널에 남겨두기. ** inode ** 연산을 원한다면, 자신 만의 파일 시스템을 구현하십시오. – Tsyvarev
@Tsyvarev 정말 고마워요! 대답 부분에 넣을 수 있습니까? –