Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
cloud-kernel
提交
274a4886
cloud-kernel
项目概览
openanolis
/
cloud-kernel
1 年多 前同步成功
通知
160
Star
36
Fork
7
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
cloud-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
274a4886
编写于
4月 02, 2015
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ncpfs: switch to ->read_iter/->write_iter
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
6e242a1c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
37 addition
and
63 deletion
+37
-63
fs/ncpfs/file.c
fs/ncpfs/file.c
+33
-59
fs/ncpfs/ncplib_kernel.c
fs/ncpfs/ncplib_kernel.c
+3
-3
fs/ncpfs/ncplib_kernel.h
fs/ncpfs/ncplib_kernel.h
+1
-1
未找到文件。
fs/ncpfs/file.c
浏览文件 @
274a4886
...
...
@@ -98,30 +98,24 @@ int ncp_make_open(struct inode *inode, int right)
}
static
ssize_t
ncp_file_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
ncp_file_read
_iter
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
to
)
{
struct
file
*
file
=
iocb
->
ki_filp
;
struct
inode
*
inode
=
file_inode
(
file
);
size_t
already_read
=
0
;
off_t
pos
;
off_t
pos
=
iocb
->
ki_pos
;
size_t
bufsize
;
int
error
;
void
*
freepage
;
void
*
freepage
;
size_t
freelen
;
ncp_dbg
(
1
,
"enter %pD2
\n
"
,
file
);
pos
=
*
ppos
;
if
((
ssize_t
)
count
<
0
)
{
return
-
EINVAL
;
}
if
(
!
count
)
if
(
!
iov_iter_count
(
to
))
return
0
;
if
(
pos
>
inode
->
i_sb
->
s_maxbytes
)
return
0
;
if
(
pos
+
count
>
inode
->
i_sb
->
s_maxbytes
)
{
count
=
inode
->
i_sb
->
s_maxbytes
-
pos
;
}
iov_iter_truncate
(
to
,
inode
->
i_sb
->
s_maxbytes
-
pos
);
error
=
ncp_make_open
(
inode
,
O_RDONLY
);
if
(
error
)
{
...
...
@@ -138,31 +132,29 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
goto
outrel
;
error
=
0
;
/* First read in as much as possible for each bufsize. */
while
(
already_read
<
count
)
{
while
(
iov_iter_count
(
to
)
)
{
int
read_this_time
;
size_t
to_read
=
min_t
(
unsigned
in
t
,
size_t
to_read
=
min_t
(
size_
t
,
bufsize
-
(
pos
%
bufsize
),
count
-
already_read
);
iov_iter_count
(
to
)
);
error
=
ncp_read_bounce
(
NCP_SERVER
(
inode
),
NCP_FINFO
(
inode
)
->
file_handle
,
pos
,
to_read
,
buf
,
&
read_this_time
,
pos
,
to_read
,
to
,
&
read_this_time
,
freepage
,
freelen
);
if
(
error
)
{
error
=
-
EIO
;
/* NW errno -> Linux errno */
break
;
}
pos
+=
read_this_time
;
buf
+=
read_this_time
;
already_read
+=
read_this_time
;
if
(
read_this_time
!=
to_read
)
{
if
(
read_this_time
!=
to_read
)
break
;
}
}
vfree
(
freepage
);
*
p
pos
=
pos
;
iocb
->
ki_
pos
=
pos
;
file_accessed
(
file
);
...
...
@@ -173,42 +165,26 @@ ncp_file_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
}
static
ssize_t
ncp_file_write
(
struct
file
*
file
,
const
char
__user
*
buf
,
size_t
count
,
loff_t
*
ppos
)
ncp_file_write
_iter
(
struct
kiocb
*
iocb
,
struct
iov_iter
*
from
)
{
struct
file
*
file
=
iocb
->
ki_filp
;
struct
inode
*
inode
=
file_inode
(
file
);
size_t
already_written
=
0
;
off_t
pos
;
loff_t
pos
=
iocb
->
ki_pos
;
size_t
count
=
iov_iter_count
(
from
);
size_t
bufsize
;
int
errno
;
void
*
bouncebuffer
;
void
*
bouncebuffer
;
ncp_dbg
(
1
,
"enter %pD2
\n
"
,
file
);
if
((
ssize_t
)
count
<
0
)
return
-
EINVAL
;
pos
=
*
ppos
;
if
(
file
->
f_flags
&
O_APPEND
)
{
pos
=
i_size_read
(
inode
);
}
if
(
pos
+
count
>
MAX_NON_LFS
&&
!
(
file
->
f_flags
&
O_LARGEFILE
))
{
if
(
pos
>=
MAX_NON_LFS
)
{
return
-
EFBIG
;
}
if
(
count
>
MAX_NON_LFS
-
(
u32
)
pos
)
{
count
=
MAX_NON_LFS
-
(
u32
)
pos
;
}
}
if
(
pos
>=
inode
->
i_sb
->
s_maxbytes
)
{
if
(
count
||
pos
>
inode
->
i_sb
->
s_maxbytes
)
{
return
-
EFBIG
;
}
}
if
(
pos
+
count
>
inode
->
i_sb
->
s_maxbytes
)
{
count
=
inode
->
i_sb
->
s_maxbytes
-
pos
;
}
errno
=
generic_write_checks
(
file
,
&
pos
,
&
count
,
0
);
if
(
errno
)
return
errno
;
iov_iter_truncate
(
from
,
count
);
if
(
!
count
)
return
0
;
errno
=
ncp_make_open
(
inode
,
O_WRONLY
);
if
(
errno
)
{
ncp_dbg
(
1
,
"open failed, error=%d
\n
"
,
errno
);
...
...
@@ -216,8 +192,6 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
}
bufsize
=
NCP_SERVER
(
inode
)
->
buffer_size
;
already_written
=
0
;
errno
=
file_update_time
(
file
);
if
(
errno
)
goto
outrel
;
...
...
@@ -227,13 +201,13 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
errno
=
-
EIO
;
/* -ENOMEM */
goto
outrel
;
}
while
(
already_written
<
count
)
{
while
(
iov_iter_count
(
from
)
)
{
int
written_this_time
;
size_t
to_write
=
min_t
(
unsigned
in
t
,
bufsize
-
(
pos
%
bufsize
),
count
-
already_written
);
size_t
to_write
=
min_t
(
size_
t
,
bufsize
-
(
(
off_t
)
pos
%
bufsize
),
iov_iter_count
(
from
)
);
if
(
copy_from_
user
(
bouncebuffer
,
buf
,
to_write
)
)
{
if
(
copy_from_
iter
(
bouncebuffer
,
to_write
,
from
)
!=
to_write
)
{
errno
=
-
EFAULT
;
break
;
}
...
...
@@ -244,16 +218,14 @@ ncp_file_write(struct file *file, const char __user *buf, size_t count, loff_t *
break
;
}
pos
+=
written_this_time
;
buf
+=
written_this_time
;
already_written
+=
written_this_time
;
if
(
written_this_time
!=
to_write
)
{
if
(
written_this_time
!=
to_write
)
break
;
}
}
vfree
(
bouncebuffer
);
*
p
pos
=
pos
;
iocb
->
ki_
pos
=
pos
;
if
(
pos
>
i_size_read
(
inode
))
{
mutex_lock
(
&
inode
->
i_mutex
);
...
...
@@ -277,8 +249,10 @@ static int ncp_release(struct inode *inode, struct file *file) {
const
struct
file_operations
ncp_file_operations
=
{
.
llseek
=
generic_file_llseek
,
.
read
=
ncp_file_read
,
.
write
=
ncp_file_write
,
.
read
=
new_sync_read
,
.
write
=
new_sync_write
,
.
read_iter
=
ncp_file_read_iter
,
.
write_iter
=
ncp_file_write_iter
,
.
unlocked_ioctl
=
ncp_ioctl
,
#ifdef CONFIG_COMPAT
.
compat_ioctl
=
ncp_compat_ioctl
,
...
...
fs/ncpfs/ncplib_kernel.c
浏览文件 @
274a4886
...
...
@@ -1001,8 +1001,8 @@ ncp_read_kernel(struct ncp_server *server, const char *file_id,
*/
int
ncp_read_bounce
(
struct
ncp_server
*
server
,
const
char
*
file_id
,
__u32
offset
,
__u16
to_read
,
char
__user
*
target
,
int
*
bytes_read
,
void
*
bounce
,
__u32
bufsize
)
__u32
offset
,
__u16
to_read
,
struct
iov_iter
*
to
,
int
*
bytes_read
,
void
*
bounce
,
__u32
bufsize
)
{
int
result
;
...
...
@@ -1025,7 +1025,7 @@ ncp_read_bounce(struct ncp_server *server, const char *file_id,
(
offset
&
1
);
*
bytes_read
=
len
;
result
=
0
;
if
(
copy_to_
user
(
target
,
source
,
len
)
)
if
(
copy_to_
iter
(
source
,
len
,
to
)
!=
len
)
result
=
-
EFAULT
;
}
}
...
...
fs/ncpfs/ncplib_kernel.h
浏览文件 @
274a4886
...
...
@@ -53,7 +53,7 @@ static inline int ncp_read_bounce_size(__u32 size) {
return
sizeof
(
struct
ncp_reply_header
)
+
2
+
2
+
size
+
8
;
};
int
ncp_read_bounce
(
struct
ncp_server
*
,
const
char
*
,
__u32
,
__u16
,
char
__user
*
,
int
*
,
void
*
bounce
,
__u32
bouncelen
);
struct
iov_iter
*
,
int
*
,
void
*
bounce
,
__u32
bouncelen
);
int
ncp_read_kernel
(
struct
ncp_server
*
,
const
char
*
,
__u32
,
__u16
,
char
*
,
int
*
);
int
ncp_write_kernel
(
struct
ncp_server
*
,
const
char
*
,
__u32
,
__u16
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录