Hi,
You want to write the data in a file. According to your earlier post I have assumed you want to copy the data. It is right you should first copy the data from kernel space to user space using copy_to_user() and then for creating a file you can use filp_open() call. This function is used to create a file or to open a file from kernel module. Then you get a struct file * from this function. This function return not NULL value on successful return.
You can write using vfs_write() function.
mm_segment_t user_fs;
user_fs = get_fs(); // Necessary for before segment for KERNEL
set_fs(KERNEL_DS); // set the segment to KERNEL Data Segment
struct file * filp = filp_open(filename, O_CREAT | O_RDWR, 0644);
vfs_write(filp,buf,size,filp->f_pos);
set_fs(user_fs);
You can copy the data in buffer using
copy_to_user();
|