- 论坛徽章:
- 0
|
内核模块当写日志文件大于2G的时候就无法继续写入了....我是启用内核线程的方法写的..系统是CENTOS6.0 X86_64位的平台.
线程函数如下:- int threadfunc(void *data){
- mm_segment_t fs;
- //int temp=0;
- loff_t pos=0;
- filp = filp_open("/home/accsess",O_RDWR | O_CREAT | O_APPEND,0777);
- if(IS_ERR(filp))
- {
- printk("open error...\n");
- return 0;
- }
- fs=get_fs();
- set_fs(KERNEL_DS);
- while(1){
- if(kthread_should_stop())
- break;
- wait_for_completion(&myWait);
- printk(KERN_ALERT "start log\n");
- pos=0;
- //filp->f_op->write(filp,LOG_BUFF+writestart,writesize,&filp->f_pos);
- vfs_write(filp,LOG_BUFF+writestart,writesize,&pos);
- memset(LOG_BUFF+writestart,writesize,0);
- //set_current_state(TASK_INTERRUPTIBLE);
- }
- set_fs(fs);
- filp_close(filp,NULL);
- return 0;
- }
复制代码 |
|