Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
274a4886
Commit
274a4886
authored
Apr 02, 2015
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ncpfs: switch to ->read_iter/->write_iter
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
6e242a1c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
63 deletions
+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
No files found.
fs/ncpfs/file.c
View file @
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
View file @
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
View file @
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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment