return -EPERM;
while (sum<len) {
- rlen =fp->f_op->read(fp, (char __force __user *)buf+sum, len-sum, &fp->f_pos);
+ rlen = kernel_read(fp, buf + sum, len - sum, &fp->f_pos);
if (rlen>0)
sum+=rlen;
else if (0 != rlen)
break;
}
- return sum;
+ return sum;
}
{
struct file *fp;
int ret = 0;
- mm_segment_t oldfs;
char buf;
fp =filp_open(path, O_RDONLY, 0);
- if (IS_ERR(fp)) {
- ret = PTR_ERR(fp);
- }
- else {
- oldfs = get_fs(); set_fs(KERNEL_DS);
+ if (IS_ERR(fp))
+ return PTR_ERR(fp);
- if (1!=readFile(fp, &buf, 1))
- ret = -EINVAL;
+ if (readFile(fp, &buf, 1) != 1)
+ ret = -EINVAL;
- set_fs(oldfs);
- filp_close(fp, NULL);
- }
+ filp_close(fp, NULL);
return ret;
}
static int retriveFromFile(char *path, u8 *buf, u32 sz)
{
int ret =-1;
- mm_segment_t oldfs;
struct file *fp;
if (path && buf) {
if (0 == (ret =openFile(&fp, path, O_RDONLY, 0))) {
DBG_871X("%s openFile path:%s fp =%p\n", __func__, path , fp);
- oldfs = get_fs(); set_fs(KERNEL_DS);
ret =readFile(fp, buf, sz);
- set_fs(oldfs);
closeFile(fp);
DBG_871X("%s readFile, ret:%d\n", __func__, ret);