Trying a file creation under /tmp like below:
struct file *fp;
fp = file_open("/tmp/sample-logfile",O_CREAT|O_WRONLY|O_TRUNC, 0666);
if (IS_ERR(fp))
printk("<0>Create record file error!\n\r");
file_close(fp);
After the kernel comes-up, there is no file visible. There are no errors also shown during kernel bootup. Now sure what is going wrong here?
My file_open is like this:
struct file *file_open(const char *path, int flags, int rights)
{
struct file *filp = NULL;
mm_segment_t oldfs;
int err = 0;
oldfs = get_fs();
set_fs(get_ds());
filp = filp_open(path, flags, rights);
set_fs(oldfs);
if (IS_ERR(filp)) {
err = PTR_ERR(filp);
return NULL;
}
return filp;
}