Dear all
我嘗試在 kernel 中開啟一個檔案來做 dump,
其中在 filp_open 這個函數有點疑惑
// Open & Create file
static struct file *dump_fp = NULL;
struct file *OpenFile(char *path, int flag, int mode){
struct file *fp;
InitKernelEnv();
fp = filp_open(path, flag, 0);
printk(KERN_ERR "filp_open at %p\n", fp);
DinitKernelEnv();
if (IS_ERR(fp)) {
long err = PTR_ERR(fp);
printk(KERN_ERR "Occurs error: %ld\n", err);
return NULL;
}
return fp;
}
我傳入的參數如下:
dump_fp = OpenFile(MY_FILE, (O_RDWR | O_CREAT), 0666);
不過生成的 MY_FILE 權限卻是