#include <linux/fs.h>
#include <linux/uaccess.h>
static int write_file(char *f_name,char *buf,size_t count)
{
struct file *fp;
mm_segment_t fs;
loff_t pos;
printk("%s:%s\n", __func__, f_name);
fp =filp_open(f_name,O_RDWR | O_CREAT,0644);
if (IS_ERR(fp)){
printk("create file error\n");
return -1;
}
fs =get_fs();
set_fs(KERNEL_DS);
pos =0;
vfs_write(fp,buf, count, &pos);
filp_close(fp,NULL);
set_fs(fs);
return 0;
}