未验证 提交 74fd07a5 编写于 作者: W winfenggao 提交者: GitHub

lseek()函数中,当seek到文件的位置和当前位置相同时,不需要调用dfs_file_lseek()函数,直接返回当前位置即可。 (#6498)

当seek到文件的位置和当前位置相同时,不需要调用dfs_file_lseek()函数,直接返回当前位置即可。
同时,以lseek(fd,0,SEEK_CUR)的方式执行函数可以返回文件当前读去位置,可以实现
ftell()的功能.
以lseek(fd,0,SEEK_CUR)的方式执行函数返回文件当前位置,实现ftell()的功能时不用调用dfs_file_lseek()函数,提高效率;seek(fd,0,SEEK_CUR)本来就能返回当前位置。
上级 0eba85ee
......@@ -248,15 +248,17 @@ off_t lseek(int fd, off_t offset, int whence)
return -1;
}
result = dfs_file_lseek(d, offset);
if (result < 0)
if(offset != d->pos)
{
fd_put(d);
rt_set_errno(result);
result = dfs_file_lseek(d, offset);
if (result < 0)
{
fd_put(d);
rt_set_errno(result);
return -1;
return -1;
}
}
/* release the ref-count of fd */
fd_put(d);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册