- 论坛徽章:
- 0
|
内核中当然有这样的需求咯
比如loader,就需要把可执行文件从存储设备上把可执行文件头读入内核buff中,分析文件格式等等操作
2.6.12
- int kernel_read(struct file *file, unsigned long offset,
- char *addr, unsigned long count)
- {
- mm_segment_t old_fs;
- loff_t pos = offset;
- int result;
- old_fs = get_fs();
- set_fs(get_ds());
- /* The cast to a user pointer is valid due to the set_fs() */
- result = vfs_read(file, (void __user *)addr, count, &pos);
- set_fs(old_fs);
- return result;
- }
- EXPORT_SYMBOL(kernel_read);
复制代码
都会用到这个函数,其中addr就是内核中分配的缓冲区了
当然之前根据路径名获取file结构体的部分哈
[ 本帖最后由 augustusqing 于 2009-12-24 22:19 编辑 ] |
|